Version: v0.0.0-...-8d08d5c Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2021 License: GPL-3.0 Imports: 8 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Chain

type Chain struct {


	Network ngtypes.NetworkType

func Init

func Init(db *badger.DB, network ngtypes.NetworkType, store *ngblocks.BlockStore, state *ngstate.State) *Chain

func (*Chain) ApplyBlock

func (chain *Chain) ApplyBlock(block *ngtypes.Block) error

ApplyBlock checks the block and then calls ngchain's PutNewBlock, after which update the state

func (*Chain) CheckBlock

func (chain *Chain) CheckBlock(block *ngtypes.Block) error

CheckBlock checks block before putting into chain.

func (*Chain) CheckHealth

func (chain *Chain) CheckHealth(network ngtypes.NetworkType)

func (*Chain) ForceApplyBlocks

func (chain *Chain) ForceApplyBlocks(blocks []*ngtypes.Block) error

ForceApplyBlocks checks the block and then calls PutNewBlock, after which update the state

func (*Chain) GetBlockByHash

func (chain *Chain) GetBlockByHash(hash []byte) (*ngtypes.Block, error)

GetBlockByHash returns a block by hash inputed

func (*Chain) GetBlockByHeight

func (chain *Chain) GetBlockByHeight(height uint64) (*ngtypes.Block, error)

GetBlockByHeight returns a block by height inputed

func (*Chain) GetLatestBlock

func (chain *Chain) GetLatestBlock() *ngtypes.Block

GetLatestBlock will return the latest Block in DB.

func (*Chain) GetLatestBlockHash

func (chain *Chain) GetLatestBlockHash() []byte

GetLatestBlockHash will fetch the latest block from chain and then calc its hash

func (*Chain) GetLatestBlockHeight

func (chain *Chain) GetLatestBlockHeight() uint64

GetLatestBlockHeight will fetch the latest block from chain and then return its height

func (*Chain) GetLatestCheckpoint

func (chain *Chain) GetLatestCheckpoint() *ngtypes.Block

GetLatestCheckpoint returns the latest checkpoint block

func (*Chain) GetLatestCheckpointHash

func (chain *Chain) GetLatestCheckpointHash() []byte

GetLatestCheckpointHash returns the hash of latest checkpoint

func (*Chain) GetOriginBlock

func (chain *Chain) GetOriginBlock() *ngtypes.Block

GetOriginBlock returns the genesis block for strict node, but can be any checkpoint for other node

func (*Chain) GetTxByHash

func (chain *Chain) GetTxByHash(hash []byte) (*ngtypes.Tx, error)

GetTxByHash gets the tx with hash from db, so the tx must be applied.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL