blockchain

package
v0.0.0-...-a0a9112 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 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

	*tnmblocks.BlockStore
	*tnmstate.State

	Network tnmtypes.Network
}

func Init

func Init(db *bbolt.DB, network tnmtypes.Network, store *tnmblocks.BlockStore, state *tnmstate.State) *Chain

func (*Chain) ApplyBlock

func (chain *Chain) ApplyBlock(block *tnmtypes.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 tnmtypes.Block) error

CheckBlock checks block before putting into chain.

func (*Chain) CheckHealth

func (chain *Chain) CheckHealth(network tnmtypes.Network)

func (*Chain) ForceApplyBlocks

func (chain *Chain) ForceApplyBlocks(blocks []*tnmtypes.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) (tnmtypes.Block, error)

GetBlockByHash returns a block by hash inputted.

func (*Chain) GetBlockByHeight

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

GetBlockByHeight returns a block by height inputted.

func (*Chain) GetLatestBlock

func (chain *Chain) GetLatestBlock() tnmtypes.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() *tnmtypes.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() *tnmtypes.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) (*tnmtypes.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