Documentation ¶
Index ¶
- Constants
- Variables
- func CalcWork(bits uint32) *big.Int
- func CompactToBig(compact uint32) *big.Int
- func DisableLog()
- func HashToBig(hash *common.Uint256) *big.Int
- func UseLogger(logger elalog.Logger)
- type BlockChain
- func (b *BlockChain) BestHeight() uint32
- func (b *BlockChain) Clear() error
- func (b *BlockChain) Close() error
- func (b *BlockChain) CommitBlock(block *util.Block) (newTip, reorg bool, newHeight, fps uint32, err error)
- func (b *BlockChain) HaveBlock(hash *common.Uint256) bool
- func (b *BlockChain) LatestBlockLocator() []*common.Uint256
Constants ¶
const (
MaxBlockLocatorHashes = 100
)
Variables ¶
var OrphanBlockError = errors.New("block does not extend any known blocks")
Functions ¶
func CompactToBig ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
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) CommitBlock ¶
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