blockchain

package
v0.0.0-...-571fd38 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

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.Network
}

func Init

func Init(db *badger.DB, network ngtypes.Network, 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 blockchain's PutNewBlock, and then auto-upgrade 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.Network)

func (*Chain) ForceApplyBlocks

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

ForceApplyBlocks simply checks the block and then calls chain.ForcePutNewBlock but **do not** upgrade the state. so, after this, dev should do a regenerate or import latest sheet.

func (*Chain) GetBlockByHash

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

GetBlockByHash returns a block by hash inputted.

func (*Chain) GetBlockByHeight

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

GetBlockByHeight returns a block by height inputted.

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