Documentation ¶
Index ¶
- type FlowContext
- func (f *FlowContext) AddBlock(block *util.Block, flags blockdag.BehaviorFlags) error
- func (f *FlowContext) AddToPeers(peer *peerpkg.Peer) error
- func (f *FlowContext) AddTransaction(tx *util.Tx) error
- func (f *FlowContext) AddressManager() *addressmanager.AddressManager
- func (f *FlowContext) Broadcast(message appmessage.Message) error
- func (f *FlowContext) Config() *config.Config
- func (f *FlowContext) ConnectionManager() *connmanager.ConnectionManager
- func (f *FlowContext) DAG() *blockdag.BlockDAG
- func (f *FlowContext) FinishIBD()
- func (*FlowContext) HandleError(err error, flowName string, isStopping *uint32, errChan chan<- error)
- func (f *FlowContext) IBDPeer() *peerpkg.Peer
- func (f *FlowContext) IsInIBD() bool
- func (f *FlowContext) NetAdapter() *netadapter.NetAdapter
- func (f *FlowContext) OnNewBlock(block *util.Block) error
- func (f *FlowContext) Peers() []*peerpkg.Peer
- func (f *FlowContext) RemoveFromPeers(peer *peerpkg.Peer)
- func (f *FlowContext) SharedRequestedBlocks() *blockrelay.SharedRequestedBlocks
- func (f *FlowContext) SharedRequestedTransactions() *relaytransactions.SharedRequestedTransactions
- func (f *FlowContext) StartIBDIfRequired()
- func (f *FlowContext) TxPool() *mempool.TxPool
Constants ¶
This section is empty.
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, dag *blockdag.BlockDAG, addressManager *addressmanager.AddressManager, txPool *mempool.TxPool, netAdapter *netadapter.NetAdapter, connectionManager *connmanager.ConnectionManager) *FlowContext
New returns a new instance of FlowContext.
func (*FlowContext) AddBlock ¶
func (f *FlowContext) AddBlock(block *util.Block, flags blockdag.BehaviorFlags) error
AddBlock adds the given block to the DAG and propagates it.
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 *util.Tx) 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) 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) DAG ¶
func (f *FlowContext) DAG() *blockdag.BlockDAG
DAG returns the DAG associated to the flow context.
func (*FlowContext) FinishIBD ¶
func (f *FlowContext) FinishIBD()
FinishIBD finishes the current IBD flow and starts a new one if required.
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 currently active IBD peer. Returns nil if we aren't currently in IBD
func (*FlowContext) IsInIBD ¶
func (f *FlowContext) IsInIBD() bool
IsInIBD is true if IBD is currently running
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 *util.Block) 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) 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) 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() *relaytransactions.SharedRequestedTransactions
SharedRequestedTransactions returns a *relaytransactions.SharedRequestedTransactions for sharing data about requested transactions between different peers.
func (*FlowContext) StartIBDIfRequired ¶
func (f *FlowContext) StartIBDIfRequired()
StartIBDIfRequired selects a peer and starts IBD against it if required
func (*FlowContext) TxPool ¶
func (f *FlowContext) TxPool() *mempool.TxPool
TxPool returns the transaction pool associated to the manager.