Documentation ¶
Index ¶
- Constants
- type FlowContext
- func (f *FlowContext) AddBlock(block *externalapi.DomainBlock) error
- func (f *FlowContext) AddOrphan(orphanBlock *externalapi.DomainBlock)
- func (f *FlowContext) AddToPeers(peer *peerpkg.Peer) error
- func (f *FlowContext) AddTransaction(tx *externalapi.DomainTransaction, allowOrphan bool) error
- func (f *FlowContext) AddressManager() *addressmanager.AddressManager
- func (f *FlowContext) Broadcast(message appmessage.Message) error
- func (f *FlowContext) Close()
- func (f *FlowContext) Config() *config.Config
- func (f *FlowContext) ConnectionManager() *connmanager.ConnectionManager
- func (f *FlowContext) Domain() domain.Domain
- func (f *FlowContext) EnqueueTransactionIDsForPropagation(transactionIDs []*externalapi.DomainTransactionID) error
- func (f *FlowContext) GetOrphanRoots(orphan *externalapi.DomainHash) ([]*externalapi.DomainHash, bool, error)
- func (*FlowContext) HandleError(err error, flowName string, isStopping *uint32, errChan chan<- error)
- func (f *FlowContext) IBDPeer() *peerpkg.Peer
- func (f *FlowContext) IsIBDRunning() bool
- func (f *FlowContext) IsOrphan(blockHash *externalapi.DomainHash) bool
- func (*FlowContext) IsRecoverableError(err error) bool
- func (f *FlowContext) NetAdapter() *netadapter.NetAdapter
- func (f *FlowContext) OnNewBlock(block *externalapi.DomainBlock, ...) error
- func (f *FlowContext) OnPruningPointUTXOSetOverride() error
- func (f *FlowContext) OnTransactionAddedToMempool()
- func (f *FlowContext) Peers() []*peerpkg.Peer
- func (f *FlowContext) RemoveFromPeers(peer *peerpkg.Peer)
- func (f *FlowContext) SetOnBlockAddedToDAGHandler(onBlockAddedToDAGHandler OnBlockAddedToDAGHandler)
- func (f *FlowContext) SetOnPruningPointUTXOSetOverrideHandler(onPruningPointUTXOSetOverrideHandler OnPruningPointUTXOSetOverrideHandler)
- func (f *FlowContext) SetOnTransactionAddedToMempoolHandler(onTransactionAddedToMempoolHandler OnTransactionAddedToMempoolHandler)
- func (f *FlowContext) SharedRequestedBlocks() *blockrelay.SharedRequestedBlocks
- func (f *FlowContext) SharedRequestedTransactions() *transactionrelay.SharedRequestedTransactions
- func (f *FlowContext) ShouldMine() (bool, error)
- func (f *FlowContext) ShutdownChan() <-chan struct{}
- func (f *FlowContext) TrySetIBDRunning(ibdPeer *peerpkg.Peer) bool
- func (f *FlowContext) UnorphanBlocks(rootBlock *externalapi.DomainBlock) ([]*UnorphaningResult, error)
- func (f *FlowContext) UnsetIBDRunning()
- type OnBlockAddedToDAGHandler
- type OnPruningPointUTXOSetOverrideHandler
- type OnTransactionAddedToMempoolHandler
- type UnorphaningResult
Constants ¶
const TransactionIDPropagationInterval = 500 * time.Millisecond
TransactionIDPropagationInterval is the interval between transaction IDs propagations
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FlowContext ¶
type FlowContext struct {
// contains filtered or unexported fields
}
FlowContext holds state that is relevant to more than one flow or one peer, and allows communication between different flows that can be associated to different peers.
func New ¶
func New(cfg *config.Config, domain domain.Domain, addressManager *addressmanager.AddressManager, netAdapter *netadapter.NetAdapter, connectionManager *connmanager.ConnectionManager) *FlowContext
New returns a new instance of FlowContext.
func (*FlowContext) AddBlock ¶
func (f *FlowContext) AddBlock(block *externalapi.DomainBlock) error
AddBlock adds the given block to the DAG and propagates it.
func (*FlowContext) AddOrphan ¶
func (f *FlowContext) AddOrphan(orphanBlock *externalapi.DomainBlock)
AddOrphan adds the block to the orphan set
func (*FlowContext) AddToPeers ¶
func (f *FlowContext) AddToPeers(peer *peerpkg.Peer) error
AddToPeers marks this peer as ready and adds it to the ready peers list.
func (*FlowContext) AddTransaction ¶
func (f *FlowContext) AddTransaction(tx *externalapi.DomainTransaction, allowOrphan bool) error
AddTransaction adds transaction to the mempool and propagates it.
func (*FlowContext) AddressManager ¶
func (f *FlowContext) AddressManager() *addressmanager.AddressManager
AddressManager returns the address manager associated to the flow context.
func (*FlowContext) Broadcast ¶
func (f *FlowContext) Broadcast(message appmessage.Message) error
Broadcast broadcast the given message to all the ready peers.
func (*FlowContext) Close ¶ added in v0.10.0
func (f *FlowContext) Close()
Close signals to all flows the the protocol manager is closed.
func (*FlowContext) Config ¶
func (f *FlowContext) Config() *config.Config
Config returns an instance of *config.Config associated to the flow context.
func (*FlowContext) ConnectionManager ¶
func (f *FlowContext) ConnectionManager() *connmanager.ConnectionManager
ConnectionManager returns the connection manager that is associated to the flow context.
func (*FlowContext) Domain ¶
func (f *FlowContext) Domain() domain.Domain
Domain returns the Domain object associated to the flow context.
func (*FlowContext) EnqueueTransactionIDsForPropagation ¶ added in v0.11.0
func (f *FlowContext) EnqueueTransactionIDsForPropagation(transactionIDs []*externalapi.DomainTransactionID) error
EnqueueTransactionIDsForPropagation add the given transactions IDs to a set of IDs to propagate. The IDs will be broadcast to all peers within a single transaction Inv message. The broadcast itself may happen only during a subsequent call to this method
func (*FlowContext) GetOrphanRoots ¶
func (f *FlowContext) GetOrphanRoots(orphan *externalapi.DomainHash) ([]*externalapi.DomainHash, bool, error)
GetOrphanRoots returns the roots of the missing ancestors DAG of the given orphan
func (*FlowContext) HandleError ¶
func (*FlowContext) HandleError(err error, flowName string, isStopping *uint32, errChan chan<- error)
HandleError handles an error from a flow, It sends the error to errChan if isStopping == 0 and increments isStopping
If this is ErrRouteClosed - forward it to errChan If this is ProtocolError - logs the error, and forward it to errChan Otherwise - panics
func (*FlowContext) IBDPeer ¶
func (f *FlowContext) IBDPeer() *peerpkg.Peer
IBDPeer returns the current IBD peer or null if the node is not in IBD
func (*FlowContext) IsIBDRunning ¶
func (f *FlowContext) IsIBDRunning() bool
IsIBDRunning returns true if IBD is currently marked as running
func (*FlowContext) IsOrphan ¶
func (f *FlowContext) IsOrphan(blockHash *externalapi.DomainHash) bool
IsOrphan returns whether the given blockHash belongs to an orphan block
func (*FlowContext) IsRecoverableError ¶ added in v0.11.0
func (*FlowContext) IsRecoverableError(err error) bool
IsRecoverableError returns whether the error is recoverable
func (*FlowContext) NetAdapter ¶
func (f *FlowContext) NetAdapter() *netadapter.NetAdapter
NetAdapter returns the net adapter that is associated to the flow context.
func (*FlowContext) OnNewBlock ¶
func (f *FlowContext) OnNewBlock(block *externalapi.DomainBlock, blockInsertionResult *externalapi.BlockInsertionResult) error
OnNewBlock updates the mempool after a new block arrival, and relays newly unorphaned transactions and possibly rebroadcast manually added transactions when not in IBD.
func (*FlowContext) OnPruningPointUTXOSetOverride ¶ added in v0.8.10
func (f *FlowContext) OnPruningPointUTXOSetOverride() error
OnPruningPointUTXOSetOverride calls the handler function whenever the UTXO set resets due to pruning point change via IBD.
func (*FlowContext) OnTransactionAddedToMempool ¶
func (f *FlowContext) OnTransactionAddedToMempool()
OnTransactionAddedToMempool notifies the handler function that a transaction has been added to the mempool
func (*FlowContext) Peers ¶
func (f *FlowContext) Peers() []*peerpkg.Peer
Peers returns the currently active peers
func (*FlowContext) RemoveFromPeers ¶
func (f *FlowContext) RemoveFromPeers(peer *peerpkg.Peer)
RemoveFromPeers remove this peer from the peers list.
func (*FlowContext) SetOnBlockAddedToDAGHandler ¶
func (f *FlowContext) SetOnBlockAddedToDAGHandler(onBlockAddedToDAGHandler OnBlockAddedToDAGHandler)
SetOnBlockAddedToDAGHandler sets the onBlockAddedToDAG handler
func (*FlowContext) SetOnPruningPointUTXOSetOverrideHandler ¶ added in v0.8.10
func (f *FlowContext) SetOnPruningPointUTXOSetOverrideHandler(onPruningPointUTXOSetOverrideHandler OnPruningPointUTXOSetOverrideHandler)
SetOnPruningPointUTXOSetOverrideHandler sets the onPruningPointUTXOSetOverrideHandler handler
func (*FlowContext) SetOnTransactionAddedToMempoolHandler ¶
func (f *FlowContext) SetOnTransactionAddedToMempoolHandler(onTransactionAddedToMempoolHandler OnTransactionAddedToMempoolHandler)
SetOnTransactionAddedToMempoolHandler sets the onTransactionAddedToMempool handler
func (*FlowContext) SharedRequestedBlocks ¶
func (f *FlowContext) SharedRequestedBlocks() *blockrelay.SharedRequestedBlocks
SharedRequestedBlocks returns a *blockrelay.SharedRequestedBlocks for sharing data about requested blocks between different peers.
func (*FlowContext) SharedRequestedTransactions ¶
func (f *FlowContext) SharedRequestedTransactions() *transactionrelay.SharedRequestedTransactions
SharedRequestedTransactions returns a *transactionrelay.SharedRequestedTransactions for sharing data about requested transactions between different peers.
func (*FlowContext) ShouldMine ¶
func (f *FlowContext) ShouldMine() (bool, error)
ShouldMine returns whether it's ok to use block template from this node for mining purposes.
func (*FlowContext) ShutdownChan ¶ added in v0.10.0
func (f *FlowContext) ShutdownChan() <-chan struct{}
ShutdownChan is a chan where flows can subscribe to shutdown event.
func (*FlowContext) TrySetIBDRunning ¶
func (f *FlowContext) TrySetIBDRunning(ibdPeer *peerpkg.Peer) bool
TrySetIBDRunning attempts to set `isInIBD`. Returns false if it is already set
func (*FlowContext) UnorphanBlocks ¶
func (f *FlowContext) UnorphanBlocks(rootBlock *externalapi.DomainBlock) ([]*UnorphaningResult, error)
UnorphanBlocks removes the block from the orphan set, and remove all of the blocks that are not orphans anymore.
func (*FlowContext) UnsetIBDRunning ¶
func (f *FlowContext) UnsetIBDRunning()
UnsetIBDRunning unsets isInIBD
type OnBlockAddedToDAGHandler ¶
type OnBlockAddedToDAGHandler func(block *externalapi.DomainBlock, blockInsertionResult *externalapi.BlockInsertionResult) error
OnBlockAddedToDAGHandler is a handler function that's triggered when a block is added to the DAG
type OnPruningPointUTXOSetOverrideHandler ¶ added in v0.8.10
type OnPruningPointUTXOSetOverrideHandler func() error
OnPruningPointUTXOSetOverrideHandler is a handle function that's triggered whenever the UTXO set resets due to pruning point change via IBD.
type OnTransactionAddedToMempoolHandler ¶
type OnTransactionAddedToMempoolHandler func()
OnTransactionAddedToMempoolHandler is a handler function that's triggered when a transaction is added to the mempool
type UnorphaningResult ¶
type UnorphaningResult struct {
// contains filtered or unexported fields
}
UnorphaningResult is the result of unorphaning a block