blockchain

package
v0.0.0-...-e87e1d8 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 10 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 {
	*bbolt.DB

	*ngblocks.BlockStore
	*ngstate.State

	Network ngtypes.Network
}

func Init

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

func (*Chain) ApplyBlock

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

ApplyBlock checks the block and then calls blockchain's PutNewBlock, and then auto-upgrade the state.

func (*Chain) CheckBlock

func (chain *Chain) CheckBlock(b 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.FullBlock) error

ForceApplyBlocks simply checks the block and then calls chain.ForcePutNewBlock but **do not** upgrade the state. so, after this, dev should do a regeneration or import the 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.FullBlock

GetLatestCheckpoint returns the latest checkpoint block.

func (*Chain) GetLatestCheckpointHash

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

GetLatestCheckpointHash returns the hash of the latest checkpoint.

func (*Chain) GetOriginBlock

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

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.FullTx, 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