flowcontext

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: ISC Imports: 25 Imported by: 5

Documentation

Index

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, 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) 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) Domain

func (f *FlowContext) Domain() domain.Domain

Domain returns the Domain object associated to the flow context.

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

Jump to

Keyboard shortcuts

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