Documentation ¶
Index ¶
- type Chain
- func (chain *Chain) ApplyBlock(block *ngtypes.Block) error
- func (chain *Chain) CheckBlock(block *ngtypes.Block) error
- func (chain *Chain) CheckHealth(network ngtypes.NetworkType)
- func (chain *Chain) ForceApplyBlocks(blocks []*ngtypes.Block) error
- func (chain *Chain) GetBlockByHash(hash []byte) (*ngtypes.Block, error)
- func (chain *Chain) GetBlockByHeight(height uint64) (*ngtypes.Block, error)
- func (chain *Chain) GetLatestBlock() *ngtypes.Block
- func (chain *Chain) GetLatestBlockHash() []byte
- func (chain *Chain) GetLatestBlockHeight() uint64
- func (chain *Chain) GetLatestCheckpoint() *ngtypes.Block
- func (chain *Chain) GetLatestCheckpointHash() []byte
- func (chain *Chain) GetOriginBlock() *ngtypes.Block
- func (chain *Chain) GetTxByHash(hash []byte) (*ngtypes.Tx, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct { *badger.DB *ngblocks.BlockStore *ngstate.State Network ngtypes.NetworkType }
func Init ¶
func Init(db *badger.DB, network ngtypes.NetworkType, store *ngblocks.BlockStore, state *ngstate.State) *Chain
func (*Chain) ApplyBlock ¶
ApplyBlock checks the block and then calls ngchain's PutNewBlock, after which update the state
func (*Chain) CheckBlock ¶
CheckBlock checks block before putting into chain.
func (*Chain) CheckHealth ¶
func (chain *Chain) CheckHealth(network ngtypes.NetworkType)
func (*Chain) ForceApplyBlocks ¶
ForceApplyBlocks checks the block and then calls PutNewBlock, after which update the state
func (*Chain) GetBlockByHash ¶
GetBlockByHash returns a block by hash inputed
func (*Chain) GetBlockByHeight ¶
GetBlockByHeight returns a block by height inputed
func (*Chain) GetLatestBlock ¶
GetLatestBlock will return the latest Block in DB.
func (*Chain) GetLatestBlockHash ¶
GetLatestBlockHash will fetch the latest block from chain and then calc its hash
func (*Chain) GetLatestBlockHeight ¶
GetLatestBlockHeight will fetch the latest block from chain and then return its height
func (*Chain) GetLatestCheckpoint ¶
GetLatestCheckpoint returns the latest checkpoint block
func (*Chain) GetLatestCheckpointHash ¶
GetLatestCheckpointHash returns the hash of latest checkpoint
func (*Chain) GetOriginBlock ¶
GetOriginBlock returns the genesis block for strict node, but can be any checkpoint for other node