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, virtualChangeSet *externalapi.VirtualChangeSet) error
- func (f *FlowContext) OnPruningPointUTXOSetOverride() error
- func (f *FlowContext) OnTransactionAddedToMempool()
- func (f *FlowContext) OnVirtualChange(virtualChangeSet *externalapi.VirtualChangeSet) error
- 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) SetOnVirtualChangeHandler(onVirtualChangeHandler OnVirtualChangeHandler)
- func (f *FlowContext) SharedRequestedBlocks() *SharedRequestedBlocks
- func (f *FlowContext) SharedRequestedTransactions() *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 OnVirtualChangeHandler
- type SharedRequestedBlocks
- type SharedRequestedTransactions
- 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, virtualChangeSet *externalapi.VirtualChangeSet) 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) OnVirtualChange ¶ added in v0.11.7
func (f *FlowContext) OnVirtualChange(virtualChangeSet *externalapi.VirtualChangeSet) error
OnVirtualChange calls the handler function whenever the virtual block changes.
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) SetOnVirtualChangeHandler ¶ added in v0.11.7
func (f *FlowContext) SetOnVirtualChangeHandler(onVirtualChangeHandler OnVirtualChangeHandler)
SetOnVirtualChangeHandler sets the onVirtualChangeHandler 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) 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, virtualChangeSet *externalapi.VirtualChangeSet) 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 OnVirtualChangeHandler ¶ added in v0.11.7
type OnVirtualChangeHandler func(virtualChangeSet *externalapi.VirtualChangeSet) error
OnVirtualChangeHandler is a handler function that's triggered when the virtual changes
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.
type UnorphaningResult ¶
type UnorphaningResult struct {
// contains filtered or unexported fields
}
UnorphaningResult is the result of unorphaning a block