state

package
v1.0.5-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2018 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockIndex

type BlockIndex struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

BlockIndex is the struct for help chain trace block chain as tree

func NewBlockIndex

func NewBlockIndex() *BlockIndex

NewBlockIndex will create a empty BlockIndex

func (*BlockIndex) AddNode

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

AddNode will add node to the index map

func (*BlockIndex) BestNode

func (bi *BlockIndex) BestNode() *BlockNode

func (*BlockIndex) BlockExist

func (bi *BlockIndex) BlockExist(hash *bc.Hash) bool

BlockExist check does the block existed in blockIndex

func (*BlockIndex) GetNode

func (bi *BlockIndex) GetNode(hash *bc.Hash) *BlockNode

GetNode will search node from the index map

func (*BlockIndex) InMainchain

func (bi *BlockIndex) InMainchain(hash bc.Hash) bool

TODO: THIS FUNCTION MIGHT BE DELETED

func (*BlockIndex) NodeByHeight

func (bi *BlockIndex) NodeByHeight(height uint64) *BlockNode

NodeByHeight returns the block node at the specified height.

func (*BlockIndex) SetMainChain

func (bi *BlockIndex) SetMainChain(node *BlockNode)

SetMainChain will set the the mainChain array

type BlockNode

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

func NewBlockNode(bh *types.BlockHeader, parent *BlockNode) (*BlockNode, error)

func (*BlockNode) BlockHeader

func (node *BlockNode) BlockHeader() *types.BlockHeader

blockHeader convert a node to the header struct

func (*BlockNode) CalcNextBits

func (node *BlockNode) CalcNextBits() uint64

CalcNextBits calculate the bits for next block

func (*BlockNode) CalcNextSeed

func (node *BlockNode) CalcNextSeed() *bc.Hash

CalcNextSeed calculate the seed for next block

func (*BlockNode) CalcPastMedianTime

func (node *BlockNode) CalcPastMedianTime() uint64

Jump to

Keyboard shortcuts

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