Documentation ¶
Index ¶
- type BeaconBlockNode
- func (node *BeaconBlockNode) Ancestor(height int32) IBlockNode
- func (node *BeaconBlockNode) Bits() uint32
- func (node *BeaconBlockNode) BlocksMMRRoot() chainhash.Hash
- func (node *BeaconBlockNode) CalcMedianVoteK() uint32
- func (node *BeaconBlockNode) CalcPastMedianTime() time.Time
- func (node *BeaconBlockNode) CalcPastMedianTimeForN(nBlocks int) time.Time
- func (node *BeaconBlockNode) Difficulty() uint64
- func (node *BeaconBlockNode) GetHash() chainhash.Hash
- func (node *BeaconBlockNode) Header() wire.BlockHeader
- func (node *BeaconBlockNode) Height() int32
- func (node *BeaconBlockNode) K() uint32
- func (node *BeaconBlockNode) NewHeader() wire.BlockHeader
- func (node *BeaconBlockNode) Parent() IBlockNode
- func (node *BeaconBlockNode) RelativeAncestor(distance int32) IBlockNode
- func (node *BeaconBlockNode) SerialID() int64
- func (node *BeaconBlockNode) SetStatus(status BlockStatus)
- func (node *BeaconBlockNode) Status() BlockStatus
- func (node *BeaconBlockNode) Timestamp() int64
- func (node *BeaconBlockNode) Version() int32
- func (node *BeaconBlockNode) VoteK() uint32
- func (node *BeaconBlockNode) WorkSum() *big.Int
- type BlockStatus
- type IBlockNode
- type ShardBlockNode
- func (node *ShardBlockNode) Ancestor(height int32) IBlockNode
- func (node *ShardBlockNode) Bits() uint32
- func (node *ShardBlockNode) BlocksMMRRoot() chainhash.Hash
- func (node *ShardBlockNode) CalcMedianVoteK() uint32
- func (node *ShardBlockNode) CalcPastMedianTime() time.Time
- func (node *ShardBlockNode) CalcPastMedianTimeForN(nBlocks int) time.Time
- func (node *ShardBlockNode) Difficulty() uint64
- func (node *ShardBlockNode) GetHash() chainhash.Hash
- func (node *ShardBlockNode) Header() wire.BlockHeader
- func (node *ShardBlockNode) Height() int32
- func (node *ShardBlockNode) K() uint32
- func (node *ShardBlockNode) NewHeader() wire.BlockHeader
- func (node *ShardBlockNode) Parent() IBlockNode
- func (node *ShardBlockNode) RelativeAncestor(distance int32) IBlockNode
- func (node *ShardBlockNode) SerialID() int64
- func (node *ShardBlockNode) SetStatus(status BlockStatus)
- func (node *ShardBlockNode) Status() BlockStatus
- func (node *ShardBlockNode) Timestamp() int64
- func (node *ShardBlockNode) Version() int32
- func (node *ShardBlockNode) VoteK() uint32
- func (node *ShardBlockNode) WorkSum() *big.Int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BeaconBlockNode ¶
type BeaconBlockNode struct {
// contains filtered or unexported fields
}
BeaconBlockNode represents a block within the block chain and is primarily used to aid in selecting the best chain to be the main chain. The main chain is stored into the block database.
func NewBeaconBlockNode ¶
func NewBeaconBlockNode(blockHeader wire.BlockHeader, parent IBlockNode, genesisBits uint32) *BeaconBlockNode
NewBeaconBlockNode returns a new block node for the given block header and parent node, calculating the height and workSum from the respective fields on the parent. This function is NOT safe for concurrent access.
func (*BeaconBlockNode) Ancestor ¶
func (node *BeaconBlockNode) Ancestor(height int32) IBlockNode
Ancestor returns the ancestor block node at the provided height by following the chain backwards from this node. The returned block will be nil when a height is requested that is after the height of the passed node or is less than zero.
This function is safe for concurrent access.
func (*BeaconBlockNode) Bits ¶
func (node *BeaconBlockNode) Bits() uint32
func (*BeaconBlockNode) BlocksMMRRoot ¶
func (node *BeaconBlockNode) BlocksMMRRoot() chainhash.Hash
func (*BeaconBlockNode) CalcMedianVoteK ¶
func (node *BeaconBlockNode) CalcMedianVoteK() uint32
func (*BeaconBlockNode) CalcPastMedianTime ¶
func (node *BeaconBlockNode) CalcPastMedianTime() time.Time
CalcPastMedianTime calculates the median time of the previous few blocks prior to, and including, the block node.
This function is safe for concurrent access.
func (*BeaconBlockNode) CalcPastMedianTimeForN ¶
func (node *BeaconBlockNode) CalcPastMedianTimeForN(nBlocks int) time.Time
CalcPastMedianTimeForN calculates the median time of the previous N blocks prior to, and including, the block node.
This function is safe for concurrent access.
func (*BeaconBlockNode) Difficulty ¶
func (node *BeaconBlockNode) Difficulty() uint64
func (*BeaconBlockNode) GetHash ¶
func (node *BeaconBlockNode) GetHash() chainhash.Hash
func (*BeaconBlockNode) Header ¶
func (node *BeaconBlockNode) Header() wire.BlockHeader
Header constructs a block header from the node and returns it.
This function is safe for concurrent access.
func (*BeaconBlockNode) Height ¶
func (node *BeaconBlockNode) Height() int32
func (*BeaconBlockNode) K ¶ added in v0.3.8
func (node *BeaconBlockNode) K() uint32
func (*BeaconBlockNode) NewHeader ¶
func (node *BeaconBlockNode) NewHeader() wire.BlockHeader
func (*BeaconBlockNode) Parent ¶
func (node *BeaconBlockNode) Parent() IBlockNode
func (*BeaconBlockNode) RelativeAncestor ¶
func (node *BeaconBlockNode) RelativeAncestor(distance int32) IBlockNode
RelativeAncestor returns the ancestor block node a relative 'distance' blocks before this node. This is equivalent to calling Ancestor with the node's height minus provided distance.
This function is safe for concurrent access.
func (*BeaconBlockNode) SerialID ¶
func (node *BeaconBlockNode) SerialID() int64
func (*BeaconBlockNode) SetStatus ¶
func (node *BeaconBlockNode) SetStatus(status BlockStatus)
func (*BeaconBlockNode) Status ¶
func (node *BeaconBlockNode) Status() BlockStatus
func (*BeaconBlockNode) Timestamp ¶
func (node *BeaconBlockNode) Timestamp() int64
func (*BeaconBlockNode) Version ¶
func (node *BeaconBlockNode) Version() int32
func (*BeaconBlockNode) VoteK ¶
func (node *BeaconBlockNode) VoteK() uint32
func (*BeaconBlockNode) WorkSum ¶
func (node *BeaconBlockNode) WorkSum() *big.Int
type BlockStatus ¶
type BlockStatus byte
BlockStatus is a bit field representing the validation state of the block.
const ( // StatusDataStored indicates that the block's payload is stored on disk. StatusDataStored BlockStatus = 1 << iota // StatusValid indicates that the block has been fully validated. StatusValid // StatusValidateFailed indicates that the block has failed validation. StatusValidateFailed // StatusInvalidAncestor indicates that one of the block's ancestors has // has failed validation, thus the block is also invalid. StatusInvalidAncestor // StatusNone indicates that the block has no validation state flags set. // // NOTE: This must be defined last in order to avoid influencing iota. StatusNone BlockStatus = 0 )
func (BlockStatus) HaveData ¶
func (status BlockStatus) HaveData() bool
HaveData returns whether the full block data is stored in the database. This will return false for a block node where only the header is downloaded or kept.
func (BlockStatus) KnownInvalid ¶
func (status BlockStatus) KnownInvalid() bool
KnownInvalid returns whether the block is known to be invalid. This may be because the block itself failed validation or any of its ancestors is invalid. This will return false for invalid blocks that have not been proven invalid yet.
func (BlockStatus) KnownValid ¶
func (status BlockStatus) KnownValid() bool
KnownValid returns whether the block is known to be valid. This will return false for a valid block that has not been fully validated yet.
type IBlockNode ¶
type IBlockNode interface { GetHash() chainhash.Hash BlocksMMRRoot() chainhash.Hash Height() int32 SerialID() int64 Version() int32 Bits() uint32 Difficulty() uint64 K() uint32 VoteK() uint32 Status() BlockStatus SetStatus(status BlockStatus) NewHeader() wire.BlockHeader // required only for tests Header() wire.BlockHeader Parent() IBlockNode Ancestor(height int32) IBlockNode CalcPastMedianTime() time.Time CalcPastMedianTimeForN(nBlocks int) time.Time CalcMedianVoteK() uint32 RelativeAncestor(distance int32) IBlockNode WorkSum() *big.Int Timestamp() int64 }
type ShardBlockNode ¶
type ShardBlockNode struct {
// contains filtered or unexported fields
}
ShardBlockNode represents a block within the block chain and is primarily used to aid in selecting the best chain to be the main chain. The main chain is stored into the block database.
func NewShardBlockNode ¶
func NewShardBlockNode(blockHeader wire.BlockHeader, parent IBlockNode, genesisBits uint32) *ShardBlockNode
NewShardBlockNode returns a new block node for the given block ShardHeader and parent node, calculating the height and workSum from the respective fields on the parent. This function is NOT safe for concurrent access.
func (*ShardBlockNode) Ancestor ¶
func (node *ShardBlockNode) Ancestor(height int32) IBlockNode
Ancestor returns the ancestor block node at the provided height by following the chain backwards from this node. The returned block will be nil when a height is requested that is after the height of the passed node or is less than zero.
This function is safe for concurrent access.
func (*ShardBlockNode) Bits ¶
func (node *ShardBlockNode) Bits() uint32
func (*ShardBlockNode) BlocksMMRRoot ¶
func (node *ShardBlockNode) BlocksMMRRoot() chainhash.Hash
func (*ShardBlockNode) CalcMedianVoteK ¶
func (node *ShardBlockNode) CalcMedianVoteK() uint32
func (*ShardBlockNode) CalcPastMedianTime ¶
func (node *ShardBlockNode) CalcPastMedianTime() time.Time
CalcPastMedianTime calculates the median time of the previous few blocks prior to, and including, the block node.
This function is safe for concurrent access.
func (*ShardBlockNode) CalcPastMedianTimeForN ¶
func (node *ShardBlockNode) CalcPastMedianTimeForN(nBlocks int) time.Time
CalcPastMedianTimeForN calculates the median time of the previous N blocks prior to, and including, the block node.
This function is safe for concurrent access.
func (*ShardBlockNode) Difficulty ¶
func (node *ShardBlockNode) Difficulty() uint64
func (*ShardBlockNode) GetHash ¶
func (node *ShardBlockNode) GetHash() chainhash.Hash
func (*ShardBlockNode) Header ¶
func (node *ShardBlockNode) Header() wire.BlockHeader
Header constructs a block ShardHeader from the node and returns it.
This function is safe for concurrent access.
func (*ShardBlockNode) Height ¶
func (node *ShardBlockNode) Height() int32
func (*ShardBlockNode) K ¶ added in v0.3.8
func (node *ShardBlockNode) K() uint32
func (*ShardBlockNode) NewHeader ¶
func (node *ShardBlockNode) NewHeader() wire.BlockHeader
func (*ShardBlockNode) Parent ¶
func (node *ShardBlockNode) Parent() IBlockNode
func (*ShardBlockNode) RelativeAncestor ¶
func (node *ShardBlockNode) RelativeAncestor(distance int32) IBlockNode
RelativeAncestor returns the ancestor block node a relative 'distance' blocks before this node. This is equivalent to calling Ancestor with the node's height minus provided distance.
This function is safe for concurrent access.
func (*ShardBlockNode) SerialID ¶
func (node *ShardBlockNode) SerialID() int64
func (*ShardBlockNode) SetStatus ¶
func (node *ShardBlockNode) SetStatus(status BlockStatus)
func (*ShardBlockNode) Status ¶
func (node *ShardBlockNode) Status() BlockStatus
func (*ShardBlockNode) Timestamp ¶
func (node *ShardBlockNode) Timestamp() int64
func (*ShardBlockNode) Version ¶
func (node *ShardBlockNode) Version() int32
func (*ShardBlockNode) VoteK ¶
func (node *ShardBlockNode) VoteK() uint32
func (*ShardBlockNode) WorkSum ¶
func (node *ShardBlockNode) WorkSum() *big.Int