blkmgr

package
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: ISC Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
const (
	LatestBlockOrder = int64(-1)
)

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(logger l.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type BlockManager

type BlockManager struct {
	service.Service

	sync.Mutex
	// contains filtered or unexported fields
}

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) DAGSync

func (b *BlockManager) DAGSync() *meerdag.DAGSync

DAGSync

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

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

type ProcessBlockResponse struct {
	IsOrphan      bool
	Err           error
	IsTipsExpired bool
}

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) GetBlock

func (api *PublicBlockAPI) GetBlock(h hash.Hash, verbose *bool, inclTx *bool, fullTx *bool) (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 (api *PublicBlockAPI) GetBlockByOrder(order int64, verbose *bool, inclTx *bool, fullTx *bool) (interface{}, error)

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 (api *PublicBlockAPI) GetBlockV2(h hash.Hash, verbose *bool, inclTx *bool, fullTx *bool) (interface{}, error)

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.

type TxManager

type TxManager interface {
	MemPool() consensus.TxPool
	FeeEstimator() consensus.FeeEstimator
	InitDefaultFeeEstimator()
}

Jump to

Keyboard shortcuts

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