Documentation ¶
Index ¶
- Constants
- Variables
- 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) HasPeers() bool
- func (f *FlowContext) IBDPeer() *peerpkg.Peer
- func (f *FlowContext) IsIBDRunning() bool
- func (f *FlowContext) IsNearlySynced() (bool, error)
- 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) OnNewBlockTemplate() 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) SetOnNewBlockTemplateHandler(onNewBlockTemplateHandler OnNewBlockTemplateHandler)
- func (f *FlowContext) SetOnPruningPointUTXOSetOverrideHandler(onPruningPointUTXOSetOverrideHandler OnPruningPointUTXOSetOverrideHandler)
- func (f *FlowContext) SetOnTransactionAddedToMempoolHandler(onTransactionAddedToMempoolHandler OnTransactionAddedToMempoolHandler)
- func (f *FlowContext) SharedRequestedBlocks() *SharedRequestedBlocks
- func (f *FlowContext) SharedRequestedTransactions() *SharedRequestedTransactions
- func (f *FlowContext) ShutdownChan() <-chan struct{}
- func (f *FlowContext) TrySetIBDRunning(ibdPeer *peerpkg.Peer) bool
- func (f *FlowContext) UnorphanBlocks(rootBlock *externalapi.DomainBlock) ([]*externalapi.DomainBlock, error)
- func (f *FlowContext) UnsetIBDRunning()
- type OnNewBlockTemplateHandler
- type OnPruningPointUTXOSetOverrideHandler
- type OnTransactionAddedToMempoolHandler
- type SharedRequestedBlocks
- type SharedRequestedTransactions
Constants ¶
const TransactionIDPropagationInterval = 500 * time.Millisecond
TransactionIDPropagationInterval is the interval between transaction IDs propagations
Variables ¶
var ( // ErrPingTimeout signifies that a ping operation timed out. ErrPingTimeout = protocolerrors.New(false, "timeout expired on ping") )
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) HasPeers ¶ added in v0.12.1
func (f *FlowContext) HasPeers() bool
HasPeers returns whether there are currently active peers
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) IsNearlySynced ¶ added in v0.11.15
func (f *FlowContext) IsNearlySynced() (bool, error)
IsNearlySynced returns whether current consensus is considered synced or close to being synced.
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) 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) OnNewBlockTemplate ¶ added in v0.11.15
func (f *FlowContext) OnNewBlockTemplate() error
OnNewBlockTemplate calls the handler function whenever a new block template is available for miners.
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) SetOnNewBlockTemplateHandler ¶ added in v0.11.15
func (f *FlowContext) SetOnNewBlockTemplateHandler(onNewBlockTemplateHandler OnNewBlockTemplateHandler)
SetOnNewBlockTemplateHandler sets the onNewBlockTemplateHandler 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() *SharedRequestedBlocks
SharedRequestedBlocks returns a *blockrelay.SharedRequestedBlocks for sharing data about requested blocks between different peers.
func (*FlowContext) SharedRequestedTransactions ¶
func (f *FlowContext) SharedRequestedTransactions() *SharedRequestedTransactions
SharedRequestedTransactions returns a *transactionrelay.SharedRequestedTransactions for sharing data about requested transactions between different peers.
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) ([]*externalapi.DomainBlock, 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 OnNewBlockTemplateHandler ¶ added in v0.11.15
type OnNewBlockTemplateHandler func() error
OnNewBlockTemplateHandler is a handler function that's triggered when a new block template is available
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 SharedRequestedBlocks ¶ added in v0.11.10
type SharedRequestedBlocks struct { // contains filtered or unexported fields }
SharedRequestedBlocks is a data structure that is shared between peers that holds the hashes of all the requested blocks to prevent redundant requests.
func NewSharedRequestedBlocks ¶ added in v0.11.10
func NewSharedRequestedBlocks() *SharedRequestedBlocks
NewSharedRequestedBlocks returns a new instance of SharedRequestedBlocks.
func (*SharedRequestedBlocks) AddIfNotExists ¶ added in v0.11.10
func (s *SharedRequestedBlocks) AddIfNotExists(hash *externalapi.DomainHash) (exists bool)
AddIfNotExists adds a block to the set if it doesn't exist yet.
func (*SharedRequestedBlocks) Remove ¶ added in v0.11.10
func (s *SharedRequestedBlocks) Remove(hash *externalapi.DomainHash)
Remove removes a block from the set.
func (*SharedRequestedBlocks) RemoveSet ¶ added in v0.11.10
func (s *SharedRequestedBlocks) RemoveSet(blockHashes map[externalapi.DomainHash]struct{})
RemoveSet removes a set of blocks from the set.
type SharedRequestedTransactions ¶ added in v0.11.10
type SharedRequestedTransactions struct { // contains filtered or unexported fields }
SharedRequestedTransactions is a data structure that is shared between peers that holds the IDs of all the requested transactions to prevent redundant requests.
func NewSharedRequestedTransactions ¶ added in v0.11.10
func NewSharedRequestedTransactions() *SharedRequestedTransactions
NewSharedRequestedTransactions returns a new instance of SharedRequestedTransactions.
func (*SharedRequestedTransactions) AddIfNotExists ¶ added in v0.11.10
func (s *SharedRequestedTransactions) AddIfNotExists(txID *externalapi.DomainTransactionID) (exists bool)
AddIfNotExists adds a transaction to the set if it doesn't exist yet.
func (*SharedRequestedTransactions) Remove ¶ added in v0.11.10
func (s *SharedRequestedTransactions) Remove(txID *externalapi.DomainTransactionID)
Remove removes a transaction from the set.
func (*SharedRequestedTransactions) RemoveMany ¶ added in v0.11.10
func (s *SharedRequestedTransactions) RemoveMany(txIDs []*externalapi.DomainTransactionID)
RemoveMany removes a set of transactions from the set.