Documentation ¶
Index ¶
- Constants
- func UseLogger(logger l.Logger)
- type BlockManager
- func (b *BlockManager) APIs() []api.API
- func (b *BlockManager) ChainParams() *params.Params
- func (b *BlockManager) Current() bool
- func (b *BlockManager) DAGSync() *meerdag.DAGSync
- func (b *BlockManager) GetChain() *blockchain.BlockChain
- func (b *BlockManager) GetCurrentTemplate() *types.BlockTemplate
- func (b *BlockManager) GetParentTemplate() *types.BlockTemplate
- func (b *BlockManager) GetTxManager() TxManager
- func (b *BlockManager) IsCurrent() bool
- func (b *BlockManager) ProcessBlock(block *types.SerializedBlock, flags blockchain.BehaviorFlags) ProcessBlockResponse
- func (b *BlockManager) ProcessTransaction(tx *types.Tx, allowOrphans bool, rateLimit bool, allowHighFees bool) ([]*types.TxDesc, error)
- func (b *BlockManager) SetCurrentTemplate(bt *types.BlockTemplate)
- func (b *BlockManager) SetParentTemplate(bt *types.BlockTemplate)
- func (b *BlockManager) SetTxManager(txManager TxManager)
- func (b *BlockManager) Start() error
- func (b *BlockManager) Stop() error
- func (b *BlockManager) TipGeneration() ([]hash.Hash, error)
- func (b *BlockManager) WaitForStop()
- type P2PService
- type ProcessBlockResponse
- type PublicBlockAPI
- func (api *PublicBlockAPI) GetBestBlockHash() (interface{}, error)
- func (api *PublicBlockAPI) GetBlock(h hash.Hash, verbose *bool, inclTx *bool, fullTx *bool) (interface{}, error)
- func (api *PublicBlockAPI) GetBlockByID(id uint64, verbose *bool, inclTx *bool, fullTx *bool) (interface{}, error)
- func (api *PublicBlockAPI) GetBlockByNum(num uint64, verbose *bool, inclTx *bool, fullTx *bool) (interface{}, error)
- func (api *PublicBlockAPI) GetBlockByOrder(order int64, verbose *bool, inclTx *bool, fullTx *bool) (interface{}, error)
- func (api *PublicBlockAPI) GetBlockCount() (interface{}, error)
- func (api *PublicBlockAPI) GetBlockHeader(hash hash.Hash, verbose bool) (interface{}, error)
- func (api *PublicBlockAPI) GetBlockTotal() (interface{}, error)
- func (api *PublicBlockAPI) GetBlockV2(h hash.Hash, verbose *bool, inclTx *bool, fullTx *bool) (interface{}, error)
- func (api *PublicBlockAPI) GetBlockWeight(h hash.Hash) (interface{}, error)
- func (api *PublicBlockAPI) GetBlockhash(order int64) (string, error)
- func (api *PublicBlockAPI) GetBlockhashByRange(start int64, end int64) ([]string, error)
- func (api *PublicBlockAPI) GetCoinbase(h hash.Hash, verbose *bool) (interface{}, error)
- func (api *PublicBlockAPI) GetFees(h hash.Hash) (interface{}, error)
- func (api *PublicBlockAPI) GetMainChainHeight() (interface{}, error)
- func (api *PublicBlockAPI) GetOrphansTotal() (interface{}, error)
- func (api *PublicBlockAPI) GetTokenInfo() (interface{}, error)
- func (api *PublicBlockAPI) IsBlue(h hash.Hash) (interface{}, error)
- func (api *PublicBlockAPI) IsCurrent() (interface{}, error)
- func (api *PublicBlockAPI) IsOnMainChain(h hash.Hash) (interface{}, error)
- func (api *PublicBlockAPI) Tips() (interface{}, error)
- type TxManager
Constants ¶
const ( // maxStallDuration is the time after which we will disconnect our // current sync peer if we haven't made progress. MaxStallDuration = 3 * time.Minute // stallSampleInterval the interval at which we will check to see if our // sync has stalled. StallSampleInterval = 3 * time.Second // maxStallDuration is the time after which we will disconnect our // current sync peer if we haven't made progress. MaxBlockStallDuration = 3 * time.Second )
const (
LatestBlockOrder = int64(-1)
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockManager ¶
BlockManager provides a concurrency safe block manager for handling all incoming blocks.
func NewBlockManager ¶
func NewBlockManager(ntmgr consensus.Notify, indexManager blockchain.IndexManager, db database.DB, timeSource blockchain.MedianTimeSource, sigCache *txscript.SigCache, cfg *config.Config, par *params.Params, interrupt <-chan struct{}, events *event.Feed, peerServer P2PService) (*BlockManager, error)
NewBlockManager returns a new block manager. Use Start to begin processing asynchronous block and inv updates.
func (*BlockManager) APIs ¶
func (b *BlockManager) APIs() []api.API
func (*BlockManager) ChainParams ¶
func (b *BlockManager) ChainParams() *params.Params
Return chain params
func (*BlockManager) Current ¶
func (b *BlockManager) Current() bool
IsCurrent returns whether or not the block manager believes it is synced with the connected peers.
func (*BlockManager) GetChain ¶
func (b *BlockManager) GetChain() *blockchain.BlockChain
func (*BlockManager) GetCurrentTemplate ¶
func (b *BlockManager) GetCurrentTemplate() *types.BlockTemplate
GetCurrentTemplate gets the current block template for mining.
func (*BlockManager) GetParentTemplate ¶
func (b *BlockManager) GetParentTemplate() *types.BlockTemplate
GetParentTemplate gets the current parent block template for mining.
func (*BlockManager) GetTxManager ¶
func (b *BlockManager) GetTxManager() TxManager
func (*BlockManager) IsCurrent ¶
func (b *BlockManager) IsCurrent() bool
func (*BlockManager) ProcessBlock ¶
func (b *BlockManager) ProcessBlock(block *types.SerializedBlock, flags blockchain.BehaviorFlags) ProcessBlockResponse
ProcessBlock makes use of ProcessBlock on an internal instance of a block chain. It is funneled through the block manager since blockchain is not safe for concurrent access.
func (*BlockManager) ProcessTransaction ¶
func (b *BlockManager) ProcessTransaction(tx *types.Tx, allowOrphans bool, rateLimit bool, allowHighFees bool) ([]*types.TxDesc, error)
ProcessTransaction makes use of ProcessTransaction on an internal instance of a block chain. It is funneled through the block manager since blockchain is not safe for concurrent access.
func (*BlockManager) SetCurrentTemplate ¶
func (b *BlockManager) SetCurrentTemplate(bt *types.BlockTemplate)
SetCurrentTemplate sets the current block template for mining.
func (*BlockManager) SetParentTemplate ¶
func (b *BlockManager) SetParentTemplate(bt *types.BlockTemplate)
SetParentTemplate sets the current parent block template for mining.
func (*BlockManager) SetTxManager ¶
func (b *BlockManager) SetTxManager(txManager TxManager)
func (*BlockManager) Start ¶
func (b *BlockManager) Start() error
Start begins the core block handler which processes block and inv messages.
func (*BlockManager) Stop ¶
func (b *BlockManager) Stop() error
func (*BlockManager) TipGeneration ¶
func (b *BlockManager) TipGeneration() ([]hash.Hash, error)
TipGeneration returns the hashes of all the children of the current best chain tip. It is funneled through the block manager since blockchain is not safe for concurrent access.
func (*BlockManager) WaitForStop ¶
func (b *BlockManager) WaitForStop()
type P2PService ¶
type P2PService interface {
IsCurrent() bool
}
type ProcessBlockResponse ¶
processBlockResponse is a response sent to the reply channel of a processBlockMsg.
type PublicBlockAPI ¶
type PublicBlockAPI struct {
// contains filtered or unexported fields
}
func NewPublicBlockAPI ¶
func NewPublicBlockAPI(bm *BlockManager) *PublicBlockAPI
func (*PublicBlockAPI) GetBestBlockHash ¶
func (api *PublicBlockAPI) GetBestBlockHash() (interface{}, error)
func (*PublicBlockAPI) GetBlockByID ¶
func (api *PublicBlockAPI) GetBlockByID(id uint64, verbose *bool, inclTx *bool, fullTx *bool) (interface{}, error)
Obsoleted GetBlockByID Method, since the confused naming, replaced by GetBlockByNum method
func (*PublicBlockAPI) GetBlockByNum ¶
func (api *PublicBlockAPI) GetBlockByNum(num uint64, verbose *bool, inclTx *bool, fullTx *bool) (interface{}, error)
GetBlockByNum works like GetBlockByOrder, the different is the GetBlockByNum is return the order result from the current node's DAG directly instead of according to the consensus of BlockDAG algorithm.
func (*PublicBlockAPI) GetBlockByOrder ¶
func (*PublicBlockAPI) GetBlockCount ¶
func (api *PublicBlockAPI) GetBlockCount() (interface{}, error)
The total ordered Block count
func (*PublicBlockAPI) GetBlockHeader ¶
func (api *PublicBlockAPI) GetBlockHeader(hash hash.Hash, verbose bool) (interface{}, error)
GetBlockHeader implements the getblockheader command.
func (*PublicBlockAPI) GetBlockTotal ¶
func (api *PublicBlockAPI) GetBlockTotal() (interface{}, error)
The total Block count, included possible blocks have not ordered by BlockDAG consensus yet at the moments.
func (*PublicBlockAPI) GetBlockV2 ¶
func (*PublicBlockAPI) GetBlockWeight ¶
func (api *PublicBlockAPI) GetBlockWeight(h hash.Hash) (interface{}, error)
Return the weight of block
func (*PublicBlockAPI) GetBlockhash ¶
func (api *PublicBlockAPI) GetBlockhash(order int64) (string, error)
TODO, refactor BlkMgr API
func (*PublicBlockAPI) GetBlockhashByRange ¶
func (api *PublicBlockAPI) GetBlockhashByRange(start int64, end int64) ([]string, error)
Return the hash range of block from 'start' to 'end'(exclude self) if 'end' is equal to zero, 'start' is the number that from the last block to the Gen if 'start' is greater than or equal to 'end', it will just return the hash of 'start'
func (*PublicBlockAPI) GetCoinbase ¶
func (api *PublicBlockAPI) GetCoinbase(h hash.Hash, verbose *bool) (interface{}, error)
GetCoinbase
func (*PublicBlockAPI) GetFees ¶
func (api *PublicBlockAPI) GetFees(h hash.Hash) (interface{}, error)
GetCoinbase
func (*PublicBlockAPI) GetMainChainHeight ¶
func (api *PublicBlockAPI) GetMainChainHeight() (interface{}, error)
Return the current height of DAG main chain
func (*PublicBlockAPI) GetOrphansTotal ¶
func (api *PublicBlockAPI) GetOrphansTotal() (interface{}, error)
Return the total number of orphan blocks, orphan block are the blocks have not been included into the DAG at this moment.
func (*PublicBlockAPI) GetTokenInfo ¶
func (api *PublicBlockAPI) GetTokenInfo() (interface{}, error)
func (*PublicBlockAPI) IsBlue ¶
func (api *PublicBlockAPI) IsBlue(h hash.Hash) (interface{}, error)
IsBlue:0:not blue; 1:blue 2:Cannot confirm
func (*PublicBlockAPI) IsCurrent ¶
func (api *PublicBlockAPI) IsCurrent() (interface{}, error)
Return IsCurrent
func (*PublicBlockAPI) IsOnMainChain ¶
func (api *PublicBlockAPI) IsOnMainChain(h hash.Hash) (interface{}, error)
Query whether a given block is on the main chain. Note that some DAG protocols may not support this feature.
func (*PublicBlockAPI) Tips ¶
func (api *PublicBlockAPI) Tips() (interface{}, error)
Return a list hash of the tip blocks of the DAG at this moment.