blockchain

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 7 Imported by: 20

Documentation

Index

Constants

View Source
const (
	MaxBlockLocatorHashes = 100
)

Variables

View Source
var OrphanBlockError = errors.New("block does not extend any known blocks")
View Source
var PowLimit = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 255), big.NewInt(1))

Functions

func CalcWork

func CalcWork(bits uint32) *big.Int

func CompactToBig

func CompactToBig(compact uint32) *big.Int

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func HashToBig

func HashToBig(hash *common.Uint256) *big.Int

func UseLogger

func UseLogger(logger elalog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using elalog.

Types

type BlockChain

type BlockChain struct {
	// contains filtered or unexported fields
}

BlockChain is the database of blocks, also when a new transaction or block commit, BlockChain will verify them with stored blocks.

func New

func New(genesisHeader util.BlockHeader, db database.ChainStore) (*BlockChain, error)

NewBlockChain returns a new BlockChain instance.

func (*BlockChain) BestHeight

func (b *BlockChain) BestHeight() uint32

BestHeight return current best chain height.

func (*BlockChain) Clear

func (b *BlockChain) Clear() error

Close the blockchain

func (*BlockChain) Close

func (b *BlockChain) Close() error

Close the blockchain

func (*BlockChain) CommitBlock

func (b *BlockChain) CommitBlock(block *util.Block) (newTip, reorg bool, newHeight, fps uint32, err error)

func (*BlockChain) HaveBlock

func (b *BlockChain) HaveBlock(hash *common.Uint256) bool

HaveBlock returns whether or not the chain instance has the block represented by the passed hash. This includes checking the various places a block can be like part of the main chain, on a side chain, or in the orphan pool.

This function is safe for concurrent access.

func (*BlockChain) LatestBlockLocator

func (b *BlockChain) LatestBlockLocator() []*common.Uint256

LatestBlockLocator returns a block locator for current last block, which is a array of block hashes stored in blockchain

Jump to

Keyboard shortcuts

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