Documentation ¶
Index ¶
- func GetBlock(hash common.Hash, height uint64) *types.Block
- func GetBlockByHash(hash common.Hash) *types.Block
- func GetBlockByHeight(height uint64) *types.Block
- func GetHeightOfChain() uint64
- type Blockchain
- type Ledger
- func (bc *Ledger) AddBlock(block *types.Block) error
- func (bc *Ledger) AddBlocks(blocks types.Blocks) error
- func (bc *Ledger) CommitBlock(batch tdb.Batch, block *types.Block) error
- func (bc *Ledger) Genesis() *types.Block
- func (bc *Ledger) GetBlock(hash common.Hash, height uint64) *types.Block
- func (bc *Ledger) GetBlockByHash(hash common.Hash) *types.Block
- func (bc *Ledger) GetBlockByHeight(height uint64) *types.Block
- func (bc *Ledger) GetHash(height uint64) common.Hash
- func (bc *Ledger) GetHeader(hash common.Hash, height uint64) *types.Header
- func (bc *Ledger) GetHeaderByHash(hash common.Hash) *types.Header
- func (bc *Ledger) LastBlock() *types.Block
- func (bc *Ledger) LastFinalBlock() *types.Block
- func (bc *Ledger) LastHeight() uint64
- func (bc *Ledger) Purge()
- func (bc *Ledger) Reset() error
- func (bc *Ledger) ResetWithGenesis(genesis *types.Block) error
- func (bc *Ledger) SetGenesis(genesis *types.Block) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBlockByHeight ¶
func GetHeightOfChain ¶
func GetHeightOfChain() uint64
Types ¶
type Blockchain ¶
type Blockchain interface { Genesis() *types.Block LastBlock() *types.Block // Last block in memory LastFinalBlock() *types.Block // Last irreversible block GetBlockByHeight(height uint64) *types.Block GetBlockByHash(hash common.Hash) *types.Block GetHeader(hash common.Hash, height uint64) *types.Header GetHeaderByHash(hash common.Hash) *types.Header AddBlock(block *types.Block) error }
type Ledger ¶
type Ledger struct {
// contains filtered or unexported fields
}
Ledger is the canonical blockchain given a database with a genesis block
func (*Ledger) AddBlock ¶
AddBlock appends block into chain. The blocks passed have been validated by block_pool.
func (*Ledger) CommitBlock ¶
commit persist the block to db.
func (*Ledger) LastFinalBlock ¶
LastFinalBlock returns the last commited block in db
func (*Ledger) LastHeight ¶
Click to show internal directories.
Click to hide internal directories.