block

package
v0.0.0-...-a173fca Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODULENAME = "block"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockExecuteContext

type BlockExecuteContext struct {
	TrieStore store.StoreInterface
	Gp        *utils.GasPool
	DbStore   *store.ChainStore
	Block     *types.Block
	GasUsed   *big.Int
	GasFee    *big.Int
	Logs      []*types.Log
	Receipts  types.Receipts
}

func NewBlockExecuteContext

func NewBlockExecuteContext(trieStore store.StoreInterface, gp *utils.GasPool, dbStore *store.ChainStore, block *types.Block) *BlockExecuteContext

func (*BlockExecuteContext) AddGasFee

func (blockExecuteContext *BlockExecuteContext) AddGasFee(fee *big.Int)

func (*BlockExecuteContext) AddGasUsed

func (blockExecuteContext *BlockExecuteContext) AddGasUsed(gas *big.Int)

type BlockIndex

type BlockIndex struct {
	sync.RWMutex
	Index map[crypto.Hash]*types.BlockNode
	Dirty map[*types.BlockNode]struct{}
}

BlockIndex provides facilities for keeping track of an in-memory Index of the block chain. Although the name block chain suggests a single chain of blocks, it is actually a tree-shaped structure where any node can have multiple children. However, there can only be one active branch which does indeed form a chain from the tip all the way back to the genesis block.

func NewBlockIndex

func NewBlockIndex() *BlockIndex

newBlockIndex returns a new empty instance of a block Index. The Index will be dynamically populated as block nodes are loaded from the database and manually added.

func (*BlockIndex) AddNode

func (bi *BlockIndex) AddNode(node *types.BlockNode)

AddNode adds the provided node to the block Index and marks it as Dirty. Duplicate entries are not checked so it is up to caller to avoid adding them.

This function is safe for concurrent access.

func (*BlockIndex) ClearNode

func (bi *BlockIndex) ClearNode(node *types.BlockNode)

func (*BlockIndex) FlushToDB

func (bi *BlockIndex) FlushToDB(storeBlockNodeFunc func(node *types.BlockNode) error) error

FlushToDB writes all dirty block nodes to the database. If all writes succeed, this clears the dirty set.

func (*BlockIndex) HaveBlock

func (bi *BlockIndex) HaveBlock(hash *crypto.Hash) bool

HaveBlock returns whether or not the block Index contains the provided hash.

This function is safe for concurrent access.

func (*BlockIndex) LookupNode

func (bi *BlockIndex) LookupNode(hash *crypto.Hash) *types.BlockNode

LookupNode returns the block node identified by the provided hash. It will return nil if there is no entry for the hash.

This function is safe for concurrent access.

func (*BlockIndex) NodeStatus

func (bi *BlockIndex) NodeStatus(node *types.BlockNode) types.BlockStatus

NodeStatus provides concurrent-safe access to the status field of a node.

This function is safe for concurrent access.

func (*BlockIndex) SetStatusFlags

func (bi *BlockIndex) SetStatusFlags(node *types.BlockNode, flags types.BlockStatus)

SetStatusFlags flips the provided status flags on the block node to on, regardless of whether they were on or off previously. This does not unset any flags currently on.

This function is safe for concurrent access.

func (*BlockIndex) UnsetStatusFlags

func (bi *BlockIndex) UnsetStatusFlags(node *types.BlockNode, flags types.BlockStatus)

UnsetStatusFlags flips the provided status flags on the block node to off, regardless of whether they were on or off previously.

This function is safe for concurrent access.

Jump to

Keyboard shortcuts

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