Drives the peer‐to‐peer message processing and relay logic for a node.

Synopsis

Declared in <net_processing.h>

class PeerManager
    : public CValidationInterface
    , public NetEventsInterface

Base Classes

Name

Description

CValidationInterface

Implement this to subscribe to events generated in validation and mempool

NetEventsInterface

Interface for message handling

Types

Name

Description

Options

Tunable options controlling peer manager behavior.

Member Functions

Name

Description

~PeerManager [destructor] [virtual]

Destroy the peer manager.

AbortPrivateBroadcast [virtual]

Abort private broadcast attempts for transactions currently being privately broadcast.

CheckForStaleTipAndEvictPeers [virtual]

Evict extra outbound peers. If we think our tip may be stale, connect to an extra outbound. Public for unit testing.

FetchBlock [virtual]

Attempt to manually fetch block from a given peer. We must already have the header.

FinalizeNode [virtual]

Handle removal of a peer (clear state).

GetDesirableServiceFlags [virtual]

Gets the set of service flags which are "desirable" for a given peer.

GetInfo [virtual]

Get peer manager info.

GetNodeStateStats [virtual]

Get statistics from node state

GetOrphanTransactions [virtual]

Get information about transactions currently held in the orphan pool.

GetPrivateBroadcastInfo [virtual]

Get info about transactions currently being privately broadcast.

HasAllDesirableServiceFlags [virtual]

Callback to determine whether the given set of service flags are sufficient for a peer to be "relevant".

InitializeNode [virtual]

Initialize a peer (setup state).

InitiateTxBroadcastPrivate [virtual]

Initiate a private transaction broadcast. This is done asynchronously via short‐lived connections to peers on privacy networks.

InitiateTxBroadcastToAll [virtual]

Initiate a transaction broadcast to eligible peers. Queue the witness transaction id to the inbound and outbound inv backlogs. Later, depending on ‐txsendrate, the peer's next inventory send time and if the transaction is in the mempool, an INV about it may be sent to the peer.

ProcessMessages [virtual]

Process protocol messages received from a given node

SendMessages [virtual]

Send queued protocol messages to a given node.

SendPings [virtual]

Send ping message to all peers

SetBestBlock [virtual]

Set the height of the best block and its time (seconds since epoch).

StartScheduledTasks [virtual]

Begin running background tasks, should only be called once

UnitTestMisbehaving [virtual]

Apply misbehavior scoring to a peer directly. Public for unit testing.

UpdateLastBlockAnnounceTime [virtual]

This function is used for testing the stale tip eviction logic, see denialofservice_tests.cpp

Static Member Functions

Name

Description

make

Create a PeerManager instance wired to the node's networking and validation components.

Static Data Members

Name

Description

g_msgproc_mutex

Mutex for anything that is only accessed via the msg processing thread

Protected Member Functions

Name

Description

ActiveTipChange [virtual]

Notifies listeners any time the block chain tip changes, synchronously.

BlockChecked [virtual]

Notifies listeners of a block validation result. If the provided BlockValidationState IsValid, the provided block is guaranteed to be the current best block at the time the callback was generated (not necessarily now).

BlockConnected [virtual]

Notifies listeners of a block being connected.

BlockDisconnected [virtual]

Notifies listeners of a block being disconnected Provides the block that was disconnected.

ChainStateFlushed [virtual]

Notifies listeners of the new active block chain on‐disk.

MempoolTransactionsRemovedForBlock [virtual]

Notifies listeners of transactions removed from the mempool as as a result of new block being connected. MempoolTransactionsRemovedForBlock will be fired before BlockConnected.

NewPoWValidBlock [virtual]

Notifies listeners that a block which builds directly on our current tip has been received and connected to the headers tree, though not validated yet.

TransactionAddedToMempool [virtual]

Notifies listeners of a transaction having been added to mempool.

TransactionRemovedFromMempool [virtual]

Notifies listeners of a transaction leaving mempool.

UpdatedBlockTip [virtual]

Notifies listeners when the block chain tip advances.

Non-Member Functions

Name

Description

EnsurePeerman

Get the peer manager from a node context, asserting it is present.

Created with MrDocs