blocknode

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: ISC Imports: 7 Imported by: 0

Documentation

Overview

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Index

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) *BeaconBlockNode

newBlockNode 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) 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) GetHash

func (node *BeaconBlockNode) GetHash() chainhash.Hash

func (*BeaconBlockNode) GetHeight

func (node *BeaconBlockNode) GetHeight() int32

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) NewHeader

func (node *BeaconBlockNode) NewHeader() wire.BlockHeader

func (*BeaconBlockNode) NewNode

func (node *BeaconBlockNode) NewNode() IBlockNode

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) SetBits

func (node *BeaconBlockNode) SetBits(value uint32)

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) 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 {
	NewNode() IBlockNode
	GetHash() chainhash.Hash
	GetHeight() int32
	Height() int32
	Version() int32
	Bits() uint32
	SetBits(uint32)
	Status() BlockStatus
	SetStatus(status BlockStatus)
	NewHeader() wire.BlockHeader

	Header() wire.BlockHeader
	Parent() IBlockNode
	Ancestor(height int32) IBlockNode
	CalcPastMedianTime() time.Time
	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) *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) 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) GetHash

func (node *ShardBlockNode) GetHash() chainhash.Hash

func (*ShardBlockNode) GetHeight

func (node *ShardBlockNode) GetHeight() int32

func (*ShardBlockNode) Header

func (node *ShardBlockNode) Header() wire.BlockHeader

ShardHeader 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) NewHeader

func (node *ShardBlockNode) NewHeader() wire.BlockHeader

func (*ShardBlockNode) NewNode

func (node *ShardBlockNode) NewNode() IBlockNode

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) SetBits

func (node *ShardBlockNode) SetBits(value uint32)

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) WorkSum

func (node *ShardBlockNode) WorkSum() *big.Int

Jump to

Keyboard shortcuts

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