Documentation ¶
Index ¶
- type BlockIndex
- func (bi *BlockIndex) AddNode(node *BlockNode)
- func (bi *BlockIndex) BestNode() *BlockNode
- func (bi *BlockIndex) BlockExist(hash *bc.Hash) bool
- func (bi *BlockIndex) GetNode(hash *bc.Hash) *BlockNode
- func (bi *BlockIndex) InMainchain(hash bc.Hash) bool
- func (bi *BlockIndex) NodeByHeight(height uint64) *BlockNode
- func (bi *BlockIndex) SetMainChain(node *BlockNode)
- type BlockNode
- type UtxoViewpoint
- func (view *UtxoViewpoint) ApplyBlock(block *bc.Block, txStatus *bc.TransactionStatus) error
- func (view *UtxoViewpoint) ApplyTransaction(block *bc.Block, tx *bc.Tx, statusFail bool) error
- func (view *UtxoViewpoint) DetachBlock(block *bc.Block, txStatus *bc.TransactionStatus) error
- func (view *UtxoViewpoint) DetachTransaction(tx *bc.Tx, statusFail bool) error
- func (view *UtxoViewpoint) HasUtxo(hash *bc.Hash) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockIndex ¶ added in v0.4.6
BlockIndex is the struct for help chain trace block chain as tree
func NewBlockIndex ¶ added in v0.4.6
func NewBlockIndex() *BlockIndex
NewBlockIndex will create a empty BlockIndex
func (*BlockIndex) AddNode ¶ added in v0.4.6
func (bi *BlockIndex) AddNode(node *BlockNode)
AddNode will add node to the index map
func (*BlockIndex) BestNode ¶ added in v0.4.6
func (bi *BlockIndex) BestNode() *BlockNode
func (*BlockIndex) BlockExist ¶ added in v0.4.6
func (bi *BlockIndex) BlockExist(hash *bc.Hash) bool
BlockExist check does the block existed in blockIndex
func (*BlockIndex) GetNode ¶ added in v0.4.6
func (bi *BlockIndex) GetNode(hash *bc.Hash) *BlockNode
GetNode will search node from the index map
func (*BlockIndex) InMainchain ¶ added in v0.4.6
func (bi *BlockIndex) InMainchain(hash bc.Hash) bool
TODO: THIS FUNCTION MIGHT BE DELETED
func (*BlockIndex) NodeByHeight ¶ added in v0.4.6
func (bi *BlockIndex) NodeByHeight(height uint64) *BlockNode
NodeByHeight returns the block node at the specified height.
func (*BlockIndex) SetMainChain ¶ added in v0.4.6
func (bi *BlockIndex) SetMainChain(node *BlockNode)
SetMainChain will set the the mainChain array
type BlockNode ¶ added in v0.4.6
type BlockNode struct { Parent *BlockNode // parent is the parent block for this node. Hash bc.Hash // hash of the block. Seed *bc.Hash // seed hash of the block WorkSum *big.Int // total amount of work in the chain up to Version uint64 Height uint64 Timestamp uint64 Nonce uint64 Bits uint64 TransactionsMerkleRoot bc.Hash TransactionStatusHash bc.Hash }
BlockNode represents a block within the block chain and is primarily used to aid in selecting the best chain to be the main chain.
func NewBlockNode ¶ added in v0.4.6
func NewBlockNode(bh *types.BlockHeader, parent *BlockNode) (*BlockNode, error)
func (*BlockNode) BlockHeader ¶ added in v0.4.6
func (node *BlockNode) BlockHeader() *types.BlockHeader
blockHeader convert a node to the header struct
func (*BlockNode) CalcNextBits ¶ added in v0.4.6
CalcNextBits calculate the bits for next block
func (*BlockNode) CalcNextSeed ¶ added in v0.4.6
CalcNextSeed calculate the seed for next block
func (*BlockNode) CalcPastMedianTime ¶ added in v0.4.6
type UtxoViewpoint ¶ added in v0.3.0
UtxoViewpoint represents a view into the set of unspent transaction outputs
func NewUtxoViewpoint ¶ added in v0.3.0
func NewUtxoViewpoint() *UtxoViewpoint
NewUtxoViewpoint returns a new empty unspent transaction output view.
func (*UtxoViewpoint) ApplyBlock ¶ added in v0.3.0
func (view *UtxoViewpoint) ApplyBlock(block *bc.Block, txStatus *bc.TransactionStatus) error
func (*UtxoViewpoint) ApplyTransaction ¶ added in v0.3.0
func (*UtxoViewpoint) DetachBlock ¶ added in v0.3.0
func (view *UtxoViewpoint) DetachBlock(block *bc.Block, txStatus *bc.TransactionStatus) error
func (*UtxoViewpoint) DetachTransaction ¶ added in v0.3.0
func (view *UtxoViewpoint) DetachTransaction(tx *bc.Tx, statusFail bool) error