Documentation ¶
Index ¶
- Variables
- func InitGlobalChain()
- type BehaviorFlags
- type BlockLocator
- type Chain
- func (c *Chain) AddToBranch(bis *blockindex.BlockIndex) error
- func (c *Chain) AddToIndexMap(bi *blockindex.BlockIndex) error
- func (c *Chain) AddToOrphan(bi *blockindex.BlockIndex) error
- func (c *Chain) BuildForwardTree() (forward map[*blockindex.BlockIndex][]*blockindex.BlockIndex)
- func (c *Chain) ChainOrphanLen() int32
- func (c *Chain) ClearActive()
- func (c *Chain) Contains(index *blockindex.BlockIndex) bool
- func (c *Chain) Equal(dst *Chain) bool
- func (c *Chain) FindBlockIndex(hash util.Hash) *blockindex.BlockIndex
- func (c *Chain) FindFork(blIndex *blockindex.BlockIndex) *blockindex.BlockIndex
- func (c *Chain) FindHashInActive(hash util.Hash) *blockindex.BlockIndex
- func (c *Chain) FindMostWorkChain() *blockindex.BlockIndex
- func (c *Chain) Genesis() *blockindex.BlockIndex
- func (c *Chain) GetAncestor(height int32) *blockindex.BlockIndex
- func (c *Chain) GetBlockScriptFlags(pindex *blockindex.BlockIndex) uint32
- func (c *Chain) GetChainTips() *set.Set
- func (c *Chain) GetIndex(height int32) *blockindex.BlockIndex
- func (c *Chain) GetLocator(index *blockindex.BlockIndex) *BlockLocator
- func (c *Chain) GetParams() *model.BitcoinParams
- func (c *Chain) GetReceivedID() uint64
- func (c *Chain) GetSpendHeight(hash *util.Hash) int32
- func (c *Chain) Height() int32
- func (c *Chain) InBranch(pindex *blockindex.BlockIndex) bool
- func (c *Chain) IndexMapSize() int
- func (c *Chain) InitLoad(indexMap map[util.Hash]*blockindex.BlockIndex, branch []*blockindex.BlockIndex)
- func (c *Chain) IsCurrent() bool
- func (c *Chain) Next(index *blockindex.BlockIndex) *blockindex.BlockIndex
- func (c *Chain) ParentInBranch(pindex *blockindex.BlockIndex) bool
- func (c *Chain) RemoveFromBranch(bis *blockindex.BlockIndex) error
- func (c *Chain) ResetBlockFailureFlags(targetBI *blockindex.BlockIndex)
- func (c *Chain) SendNotification(typ NotificationType, data interface{})
- func (c *Chain) SetTip(index *blockindex.BlockIndex)
- func (c *Chain) Subscribe(callback NotificationCallback)
- func (c *Chain) Tip() *blockindex.BlockIndex
- func (c *Chain) TipHeight() int32
- type Notification
- type NotificationCallback
- type NotificationType
- type SyncingState
- type TipUpdatedEvent
Constants ¶
This section is empty.
Variables ¶
var HashAssumeValid util.Hash
Functions ¶
func InitGlobalChain ¶
func InitGlobalChain()
Types ¶
type BehaviorFlags ¶
type BehaviorFlags uint32
BehaviorFlags is a bitmask defining tweaks to the normal behavior when performing chain processing and consensus rules checks.
const ( // BFFastAdd may be set to indicate that several checks can be avoided // for the block since it is already known to fit into the chain due to // already proving it correct links into the chain up to a known // checkpoint. This is primarily used for headers-first mode. BFFastAdd BehaviorFlags = 1 << iota // BFNoPoWCheck may be set to indicate the proof of work check which // ensures a block hashes to a value less than the required target will // not be performed. BFNoPoWCheck // BFNone is a convenience value to specifically indicate no flags. BFNone BehaviorFlags = 0 )
type BlockLocator ¶
type BlockLocator struct {
// contains filtered or unexported fields
}
func NewBlockLocator ¶
func NewBlockLocator(vHaveIn []util.Hash) *BlockLocator
func (*BlockLocator) GetBlockHashList ¶
func (blt *BlockLocator) GetBlockHashList() []util.Hash
func (*BlockLocator) IsNull ¶
func (blt *BlockLocator) IsNull() bool
func (*BlockLocator) SetNull ¶
func (blt *BlockLocator) SetNull()
type Chain ¶
type Chain struct { *SyncingState // contains filtered or unexported fields }
Chain An in-memory blIndexed chain of blocks.
func GetInstance ¶
func GetInstance() *Chain
func (*Chain) AddToBranch ¶
func (c *Chain) AddToBranch(bis *blockindex.BlockIndex) error
func (*Chain) AddToIndexMap ¶
func (c *Chain) AddToIndexMap(bi *blockindex.BlockIndex) error
func (*Chain) AddToOrphan ¶
func (c *Chain) AddToOrphan(bi *blockindex.BlockIndex) error
func (*Chain) BuildForwardTree ¶ added in v0.0.3
func (c *Chain) BuildForwardTree() (forward map[*blockindex.BlockIndex][]*blockindex.BlockIndex)
BuildForwardTree Build forward-pointing map of the entire block tree.
func (*Chain) ChainOrphanLen ¶
func (*Chain) ClearActive ¶ added in v0.0.3
func (c *Chain) ClearActive()
func (*Chain) Contains ¶
func (c *Chain) Contains(index *blockindex.BlockIndex) bool
Contains /** Efficiently check whether a block is present in this chain
func (*Chain) FindBlockIndex ¶
func (c *Chain) FindBlockIndex(hash util.Hash) *blockindex.BlockIndex
FindBlockIndex finds blockindex from blockIndexMap
func (*Chain) FindFork ¶
func (c *Chain) FindFork(blIndex *blockindex.BlockIndex) *blockindex.BlockIndex
FindFork Find the last common block between this chain and a block blIndex entry.
func (*Chain) FindHashInActive ¶
func (c *Chain) FindHashInActive(hash util.Hash) *blockindex.BlockIndex
FindHashInActive finds blockindex from active
func (*Chain) FindMostWorkChain ¶
func (c *Chain) FindMostWorkChain() *blockindex.BlockIndex
func (*Chain) Genesis ¶
func (c *Chain) Genesis() *blockindex.BlockIndex
Genesis Returns the blIndex entry for the genesis block of this chain, or nullptr if none.
func (*Chain) GetAncestor ¶
func (c *Chain) GetAncestor(height int32) *blockindex.BlockIndex
GetAncestor gets ancestor from active chain.
func (*Chain) GetBlockScriptFlags ¶
func (c *Chain) GetBlockScriptFlags(pindex *blockindex.BlockIndex) uint32
func (*Chain) GetChainTips ¶ added in v0.0.3
func (c *Chain) GetChainTips() *set.Set
GetChainTips Returns fork tip, no activate chain tip
func (*Chain) GetIndex ¶
func (c *Chain) GetIndex(height int32) *blockindex.BlockIndex
GetIndex Returns the blIndex entry at a particular height in this chain, or nullptr if no such height exists.
func (*Chain) GetLocator ¶
func (c *Chain) GetLocator(index *blockindex.BlockIndex) *BlockLocator
GetLocator get a series blockHash, which slice contain blocks sort by height from Highest to lowest.
func (*Chain) GetParams ¶
func (c *Chain) GetParams() *model.BitcoinParams
func (*Chain) GetReceivedID ¶
func (*Chain) Height ¶
Height Return the maximal height in the chain. Is equal to chain.Tip() ? chain.Tip()->nHeight : -1.
func (*Chain) InBranch ¶
func (c *Chain) InBranch(pindex *blockindex.BlockIndex) bool
InBranch finds blockindex in branch
func (*Chain) IndexMapSize ¶ added in v0.0.3
func (*Chain) InitLoad ¶
func (c *Chain) InitLoad(indexMap map[util.Hash]*blockindex.BlockIndex, branch []*blockindex.BlockIndex)
InitLoad load the maps of the chain
func (*Chain) IsCurrent ¶
IsCurrent returns whether or not the chain believes it is current. Several factors are used to guess, but the key factors that allow the chain to believe it is current are:
- Latest block height is after the latest checkpoint (if enabled)
- Latest block has a timestamp newer than 24 hours ago
func (*Chain) Next ¶
func (c *Chain) Next(index *blockindex.BlockIndex) *blockindex.BlockIndex
Next Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip.
func (*Chain) ParentInBranch ¶
func (c *Chain) ParentInBranch(pindex *blockindex.BlockIndex) bool
ParentInBranch finds blockindex'parent in branch
func (*Chain) RemoveFromBranch ¶
func (c *Chain) RemoveFromBranch(bis *blockindex.BlockIndex) error
func (*Chain) ResetBlockFailureFlags ¶ added in v0.0.3
func (c *Chain) ResetBlockFailureFlags(targetBI *blockindex.BlockIndex)
func (*Chain) SendNotification ¶
func (c *Chain) SendNotification(typ NotificationType, data interface{})
SendNotification sends a notification with the passed type and data if the caller requested notifications by providing a callback function in the call to New.
func (*Chain) SetTip ¶
func (c *Chain) SetTip(index *blockindex.BlockIndex)
SetTip Set/initialize a chain with a given tip.
func (*Chain) Subscribe ¶
func (c *Chain) Subscribe(callback NotificationCallback)
Subscribe to block chain notifications. Registers a callback to be executed when various events take place. See the documentation on Notification and NotificationType for details on the types and contents of notifications.
func (*Chain) Tip ¶
func (c *Chain) Tip() *blockindex.BlockIndex
Tip Returns the blIndex entry for the tip of this chain, or nullptr if none.
type Notification ¶
type Notification struct { Type NotificationType Data interface{} }
Notification defines notification that is sent to the caller via the callback function provided during the call to New and consists of a notification type as well as associated data that depends on the type as follows:
- NTBlockAccepted: *btcutil.Block
- NTBlockConnected: *btcutil.Block
- NTBlockDisconnected: *btcutil.Block
type NotificationCallback ¶
type NotificationCallback func(*Notification)
NotificationCallback is used for a caller to provide a callback for notifications about various chain events.
type NotificationType ¶
type NotificationType int
NotificationType represents the type of a notification message.
const ( // NTBlockAccepted indicates the associated block was accepted into // the block chain. Note that this does not necessarily mean it was // added to the main chain. For that, use NTBlockConnected. NTBlockAccepted NotificationType = iota // NTBlockConnected indicates the associated block was connected to the // main chain. NTBlockConnected // NTBlockDisconnected indicates the associated block was disconnected // from the main chain. NTBlockDisconnected // NTChainTipUpdated indicates the associated blocks leads to the new main chain. NTChainTipUpdated )
Constants for the type of a notification message.
func (NotificationType) String ¶
func (n NotificationType) String() string
String returns the NotificationType in human-readable form.
type SyncingState ¶
type SyncingState struct {
// contains filtered or unexported fields
}
func (*SyncingState) IsAlmostSynced ¶
func (ds *SyncingState) IsAlmostSynced() bool
func (*SyncingState) UpdateSyncingState ¶
func (ds *SyncingState) UpdateSyncingState()
type TipUpdatedEvent ¶
type TipUpdatedEvent struct { TipIndex *blockindex.BlockIndex ForkIndex *blockindex.BlockIndex IsInitialDownload bool }