Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
PeerManager Class Referenceabstract

#include <net_processing.h>

Inheritance diagram for PeerManager:
[legend]
Collaboration diagram for PeerManager:
[legend]

Classes

struct  Options
 

Public Member Functions

virtual ~PeerManager ()
 
virtual std::optional< std::string > FetchBlock (const Config &config, NodeId peer_id, const CBlockIndex &block_index)=0
 Attempt to manually fetch block from a given peer.
 
virtual void StartScheduledTasks (CScheduler &scheduler)=0
 Begin running background tasks, should only be called once.
 
virtual bool GetNodeStateStats (NodeId nodeid, CNodeStateStats &stats) const =0
 Get statistics from node state.
 
virtual bool IgnoresIncomingTxs ()=0
 Whether this node ignores txs received over p2p.
 
virtual void RelayTransaction (const TxId &txid)=0
 Relay transaction to all peers.
 
virtual void RelayProof (const avalanche::ProofId &proofid)=0
 Relay proof to all peers.
 
virtual void SendPings ()=0
 Send ping message to all peers.
 
virtual void SetBestHeight (int height)=0
 Set the best height.
 
virtual void UnitTestMisbehaving (const NodeId peer_id, const int howmuch)=0
 Public for unit testing.
 
virtual void CheckForStaleTipAndEvictPeers ()=0
 Evict extra outbound peers.
 
virtual void ProcessMessage (const Config &config, CNode &pfrom, const std::string &msg_type, CDataStream &vRecv, const std::chrono::microseconds time_received, const std::atomic< bool > &interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex)=0
 Process a single message from a peer.
 
virtual void UpdateLastBlockAnnounceTime (NodeId node, int64_t time_in_seconds)=0
 This function is used for testing the stale tip eviction logic, see denialofservice_tests.cpp.
 
- Public Member Functions inherited from NetEventsInterface
virtual void InitializeNode (const Config &config, CNode &node, ServiceFlags our_services)=0
 Initialize a peer (setup state, queue any initial messages)
 
virtual void FinalizeNode (const Config &config, const CNode &node)=0
 Handle removal of a peer (clear state)
 
virtual bool ProcessMessages (const Config &config, CNode *pnode, std::atomic< bool > &interrupt) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex)=0
 Process protocol messages received from a given node.
 
virtual bool SendMessages (const Config &config, CNode *pnode) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex)=0
 Send queued protocol messages to a given node.
 

Static Public Member Functions

static std::unique_ptr< PeerManagermake (CConnman &connman, AddrMan &addrman, BanMan *banman, ChainstateManager &chainman, CTxMemPool &pool, avalanche::Processor *const avalanche, Options opts)
 

Additional Inherited Members

- Static Public Attributes inherited from NetEventsInterface
static Mutex g_msgproc_mutex
 Mutex for anything that is only accessed via the msg processing thread.
 
- Protected Member Functions inherited from CValidationInterface
 ~CValidationInterface ()=default
 Protected destructor so that instances can only be deleted by derived classes.
 
virtual void UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
 Notifies listeners when the block chain tip advances.
 
virtual void TransactionAddedToMempool (const CTransactionRef &tx, std::shared_ptr< const std::vector< Coin > > spent_coins, uint64_t mempool_sequence)
 Notifies listeners of a transaction having been added to mempool.
 
virtual void TransactionRemovedFromMempool (const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence)
 Notifies listeners of a transaction leaving mempool.
 
virtual void BlockConnected (const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
 Notifies listeners of a block being connected.
 
virtual void BlockDisconnected (const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
 Notifies listeners of a block being disconnected.
 
virtual void ChainStateFlushed (const CBlockLocator &locator)
 Notifies listeners of the new active block chain on-disk.
 
virtual void BlockChecked (const CBlock &, const BlockValidationState &)
 Notifies listeners of a block validation result.
 
virtual void NewPoWValidBlock (const CBlockIndex *pindex, const std::shared_ptr< const CBlock > &block)
 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.
 
virtual void BlockFinalized (const CBlockIndex *pindex)
 
virtual void BlockInvalidated (const CBlockIndex *pindex, const std::shared_ptr< const CBlock > &block)
 
- Protected Member Functions inherited from NetEventsInterface
 ~NetEventsInterface ()=default
 Protected destructor so that instances can only be deleted by derived classes.
 

Detailed Description

Definition at line 69 of file net_processing.h.

Constructor & Destructor Documentation

◆ ~PeerManager()

virtual PeerManager::~PeerManager ( )
inlinevirtual

Definition at line 110 of file net_processing.h.

Member Function Documentation

◆ CheckForStaleTipAndEvictPeers()

virtual void PeerManager::CheckForStaleTipAndEvictPeers ( )
pure virtual

Evict extra outbound peers.

If we think our tip may be stale, connect to an extra outbound.

◆ FetchBlock()

virtual std::optional< std::string > PeerManager::FetchBlock ( const Config config,
NodeId  peer_id,
const CBlockIndex block_index 
)
pure virtual

Attempt to manually fetch block from a given peer.

We must already have the header.

Parameters
[in]configThe global config
[in]peer_idThe peer id
[in]block_indexThe block index
Returns
std::nullopt if a request was successfully made, otherwise an error message
Here is the caller graph for this function:

◆ GetNodeStateStats()

virtual bool PeerManager::GetNodeStateStats ( NodeId  nodeid,
CNodeStateStats stats 
) const
pure virtual

Get statistics from node state.

Here is the caller graph for this function:

◆ IgnoresIncomingTxs()

virtual bool PeerManager::IgnoresIncomingTxs ( )
pure virtual

Whether this node ignores txs received over p2p.

◆ make()

std::unique_ptr< PeerManager > PeerManager::make ( CConnman connman,
AddrMan addrman,
BanMan banman,
ChainstateManager chainman,
CTxMemPool pool,
avalanche::Processor *const  avalanche,
Options  opts 
)
static

Definition at line 2754 of file net_processing.cpp.

Here is the caller graph for this function:

◆ ProcessMessage()

virtual void PeerManager::ProcessMessage ( const Config config,
CNode pfrom,
const std::string &  msg_type,
CDataStream vRecv,
const std::chrono::microseconds  time_received,
const std::atomic< bool > &  interruptMsgProc 
)
pure virtual

Process a single message from a peer.

Public for fuzz testing

◆ RelayProof()

virtual void PeerManager::RelayProof ( const avalanche::ProofId proofid)
pure virtual

Relay proof to all peers.

◆ RelayTransaction()

virtual void PeerManager::RelayTransaction ( const TxId txid)
pure virtual

Relay transaction to all peers.

◆ SendPings()

virtual void PeerManager::SendPings ( )
pure virtual

Send ping message to all peers.

Here is the caller graph for this function:

◆ SetBestHeight()

virtual void PeerManager::SetBestHeight ( int  height)
pure virtual

Set the best height.

◆ StartScheduledTasks()

virtual void PeerManager::StartScheduledTasks ( CScheduler scheduler)
pure virtual

Begin running background tasks, should only be called once.

◆ UnitTestMisbehaving()

virtual void PeerManager::UnitTestMisbehaving ( const NodeId  peer_id,
const int  howmuch 
)
pure virtual

Public for unit testing.

◆ UpdateLastBlockAnnounceTime()

virtual void PeerManager::UpdateLastBlockAnnounceTime ( NodeId  node,
int64_t  time_in_seconds 
)
pure virtual

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


The documentation for this class was generated from the following files: