Bitcoin ABC  0.26.3
P2P Digital Currency
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
avalanche::Processor Class Referencefinal

#include <processor.h>

Inheritance diagram for avalanche::Processor:
[legend]
Collaboration diagram for avalanche::Processor:
[legend]

Classes

class  NotificationsHandler
 
struct  PeerData
 
struct  Query
 

Public Member Functions

 ~Processor ()
 
bool addBlockToReconcile (const CBlockIndex *pindex)
 
bool addProofToReconcile (const ProofRef &proof)
 
bool isAccepted (const CBlockIndex *pindex) const
 
bool isAccepted (const ProofRef &proof) const
 
int getConfidence (const CBlockIndex *pindex) const
 
int getConfidence (const ProofRef &proof) const
 
void sendResponse (CNode *pfrom, Response response) const
 
bool registerVotes (NodeId nodeid, const Response &response, std::vector< BlockUpdate > &blockUpdates, std::vector< ProofUpdate > &proofUpdates, int &banscore, std::string &error)
 
template<typename Callable >
auto withPeerManager (Callable &&func) const
 
CPubKey getSessionPubKey () const
 
bool sendHello (CNode *pfrom) const
 
ProofRef getLocalProof () const
 
bool isAvalancheServiceAvailable ()
 
bool startEventLoop (CScheduler &scheduler)
 
bool stopEventLoop ()
 
void avaproofsSent (NodeId nodeid) LOCKS_EXCLUDED(cs_main)
 
int64_t getAvaproofsNodeCounter () const
 
bool isQuorumEstablished () LOCKS_EXCLUDED(cs_main)
 
void InitializeNode (const ::Config &config, CNode *pnode) override
 
bool ProcessMessages (const ::Config &config, CNode *pnode, std::atomic< bool > &interrupt) override
 
bool SendMessages (const ::Config &config, CNode *pnode) override
 
void FinalizeNode (const ::Config &config, const CNode &node) override LOCKS_EXCLUDED(cs_main)
 Handle removal of a node. More...
 
- Public Member Functions inherited from NetEventsInterface
virtual void InitializeNode (const Config &config, CNode *pnode)=0
 Initialize a peer (setup state, queue any initial messages) More...
 
virtual void FinalizeNode (const Config &config, const CNode &node)=0
 Handle removal of a peer (clear state) More...
 
virtual bool ProcessMessages (const Config &config, CNode *pnode, std::atomic< bool > &interrupt)=0
 Process protocol messages received from a given node. More...
 
virtual bool SendMessages (const Config &config, CNode *pnode) EXCLUSIVE_LOCKS_REQUIRED(pnode -> cs_sendProcessing)=0
 Send queued protocol messages to a given node. More...
 

Static Public Member Functions

static std::unique_ptr< ProcessorMakeProcessor (const ArgsManager &argsman, interfaces::Chain &chain, CConnman *connman, ChainstateManager &chainman, CScheduler &scheduler, bilingual_str &error)
 

Private Types

using QuerySet = boost::multi_index_container< Query, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< boost::multi_index::composite_key< Query, boost::multi_index::member< Query, NodeId, &Query::nodeid >, boost::multi_index::member< Query, uint64_t, &Query::round > >>, boost::multi_index::ordered_non_unique< boost::multi_index::tag< query_timeout >, boost::multi_index::member< Query, TimePoint, &Query::timeout > >> >
 

Private Member Functions

std::unique_ptr< PeerManager > peerManager GUARDED_BY (cs_peerManager)
 
CBlockIndex *finalizationTip GUARDED_BY (cs_finalizationTip)
 
 Processor (Config avaconfig, interfaces::Chain &chain, CConnman *connmanIn, ChainstateManager &chainman, CScheduler &scheduler, std::unique_ptr< PeerData > peerDataIn, CKey sessionKeyIn, uint32_t minQuorumTotalScoreIn, double minQuorumConnectedScoreRatioIn, int64_t minAvaproofsNodeCountIn, uint32_t staleVoteThresholdIn, uint32_t staleVoteFactorIn, Amount stakeUtxoDustThresholdIn)
 
void runEventLoop ()
 
void clearTimedoutRequests ()
 
std::vector< CInvgetInvsForNextPoll (bool forPoll=true)
 
bool isWorthPolling (const CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
bool isWorthPolling (const ProofRef &proof) const EXCLUSIVE_LOCKS_REQUIRED(cs_peerManager)
 

Private Attributes

Config avaconfig
 
CConnmanconnman
 
ChainstateManagerchainman
 
RWCollection< BlockVoteMapblockVoteRecords
 Blocks to run avalanche on. More...
 
RWCollection< ProofVoteMapproofVoteRecords
 Proofs to run avalanche on. More...
 
std::atomic< uint64_t > round
 Keep track of peers and queries sent. More...
 
Mutex cs_peerManager
 Keep track of the peers and associated infos. More...
 
RWCollection< QuerySetqueries
 
std::unique_ptr< PeerDatapeerData
 
CKey sessionKey
 
EventLoop eventLoop
 Event loop machinery. More...
 
uint32_t minQuorumScore
 Quorum management. More...
 
double minQuorumConnectedScoreRatio
 
std::atomic< bool > quorumIsEstablished {false}
 
int64_t minAvaproofsNodeCount
 
std::atomic< int64_t > avaproofsNodeCounter {0}
 
const uint32_t staleVoteThreshold
 Voting parameters. More...
 
const uint32_t staleVoteFactor
 
std::unique_ptr< interfaces::HandlerchainNotificationsHandler
 
Mutex cs_finalizationTip
 

Friends

struct ::avalanche::AvalancheTest
 

Additional Inherited Members

- Protected Member Functions inherited from NetEventsInterface
 ~NetEventsInterface ()=default
 Protected destructor so that instances can only be deleted by derived classes. More...
 

Detailed Description

Definition at line 97 of file processor.h.

Member Typedef Documentation

◆ QuerySet

using avalanche::Processor::QuerySet = boost::multi_index_container< Query, boost::multi_index::indexed_by< boost::multi_index::hashed_unique<boost::multi_index::composite_key< Query, boost::multi_index::member<Query, NodeId, &Query::nodeid>, boost::multi_index::member<Query, uint64_t, &Query::round> >>, boost::multi_index::ordered_non_unique< boost::multi_index::tag<query_timeout>, boost::multi_index::member<Query, TimePoint, &Query::timeout> >> >
private

Definition at line 137 of file processor.h.

Constructor & Destructor Documentation

◆ Processor()

avalanche::Processor::Processor ( Config  avaconfig,
interfaces::Chain chain,
CConnman connmanIn,
ChainstateManager chainman,
CScheduler scheduler,
std::unique_ptr< PeerData peerDataIn,
CKey  sessionKeyIn,
uint32_t  minQuorumTotalScoreIn,
double  minQuorumConnectedScoreRatioIn,
int64_t  minAvaproofsNodeCountIn,
uint32_t  staleVoteThresholdIn,
uint32_t  staleVoteFactorIn,
Amount  stakeUtxoDustThresholdIn 
)
private

Definition at line 134 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Processor()

avalanche::Processor::~Processor ( )

Definition at line 165 of file processor.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addBlockToReconcile()

bool avalanche::Processor::addBlockToReconcile ( const CBlockIndex pindex)

Definition at line 353 of file processor.cpp.

Here is the call graph for this function:

◆ addProofToReconcile()

bool avalanche::Processor::addProofToReconcile ( const ProofRef proof)

Definition at line 375 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ avaproofsSent()

void avalanche::Processor::avaproofsSent ( NodeId  nodeid)

Definition at line 689 of file processor.cpp.

Here is the call graph for this function:

◆ clearTimedoutRequests()

void avalanche::Processor::clearTimedoutRequests ( )
private

Definition at line 855 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FinalizeNode()

void avalanche::Processor::FinalizeNode ( const ::Config config,
const CNode node 
)
override

Handle removal of a node.

Definition at line 781 of file processor.cpp.

◆ getAvaproofsNodeCounter()

int64_t avalanche::Processor::getAvaproofsNodeCounter ( ) const
inline

Definition at line 230 of file processor.h.

◆ getConfidence() [1/2]

int avalanche::Processor::getConfidence ( const CBlockIndex pindex) const

Definition at line 421 of file processor.cpp.

Here is the call graph for this function:

◆ getConfidence() [2/2]

int avalanche::Processor::getConfidence ( const ProofRef proof) const

Definition at line 436 of file processor.cpp.

Here is the call graph for this function:

◆ getInvsForNextPoll()

std::vector< CInv > avalanche::Processor::getInvsForNextPoll ( bool  forPoll = true)
private

Definition at line 918 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLocalProof()

ProofRef avalanche::Processor::getLocalProof ( ) const

Definition at line 676 of file processor.cpp.

Here is the caller graph for this function:

◆ getSessionPubKey()

CPubKey avalanche::Processor::getSessionPubKey ( ) const

Definition at line 645 of file processor.cpp.

Here is the call graph for this function:

◆ GUARDED_BY() [1/2]

CBlockIndex* finalizationTip avalanche::Processor::GUARDED_BY ( cs_finalizationTip  )
inlineprivate

Definition at line 179 of file processor.h.

◆ GUARDED_BY() [2/2]

std::unique_ptr<PeerManager> peerManager avalanche::Processor::GUARDED_BY ( cs_peerManager  )
private

◆ InitializeNode()

void avalanche::Processor::InitializeNode ( const ::Config config,
CNode pnode 
)
inlineoverride

Definition at line 236 of file processor.h.

◆ isAccepted() [1/2]

bool avalanche::Processor::isAccepted ( const CBlockIndex pindex) const

Definition at line 396 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAccepted() [2/2]

bool avalanche::Processor::isAccepted ( const ProofRef proof) const

Definition at line 411 of file processor.cpp.

Here is the call graph for this function:

◆ isAvalancheServiceAvailable()

bool avalanche::Processor::isAvalancheServiceAvailable ( )
inline

Definition at line 224 of file processor.h.

◆ isQuorumEstablished()

bool avalanche::Processor::isQuorumEstablished ( )

Definition at line 710 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isWorthPolling() [1/2]

bool avalanche::Processor::isWorthPolling ( const CBlockIndex pindex)
private

Definition at line 979 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isWorthPolling() [2/2]

bool avalanche::Processor::isWorthPolling ( const ProofRef proof) const
private

Definition at line 1003 of file processor.cpp.

Here is the call graph for this function:

◆ MakeProcessor()

std::unique_ptr< Processor > avalanche::Processor::MakeProcessor ( const ArgsManager argsman,
interfaces::Chain chain,
CConnman connman,
ChainstateManager chainman,
CScheduler scheduler,
bilingual_str error 
)
static

Definition at line 171 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessMessages()

bool avalanche::Processor::ProcessMessages ( const ::Config config,
CNode pnode,
std::atomic< bool > &  interrupt 
)
inlineoverride

Definition at line 237 of file processor.h.

◆ registerVotes()

bool avalanche::Processor::registerVotes ( NodeId  nodeid,
const Response response,
std::vector< BlockUpdate > &  blockUpdates,
std::vector< ProofUpdate > &  proofUpdates,
int &  banscore,
std::string &  error 
)

Definition at line 482 of file processor.cpp.

Here is the call graph for this function:

◆ runEventLoop()

void avalanche::Processor::runEventLoop ( )
private

If we lost contact to that node, then we remove it from nodeids, but never add the request to queries, which ensures bad nodes get cleaned up over time.

Definition at line 787 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendHello()

bool avalanche::Processor::sendHello ( CNode pfrom) const

Definition at line 649 of file processor.cpp.

Here is the call graph for this function:

◆ SendMessages()

bool avalanche::Processor::SendMessages ( const ::Config config,
CNode pnode 
)
inlineoverride

Definition at line 241 of file processor.h.

◆ sendResponse()

void avalanche::Processor::sendResponse ( CNode pfrom,
Response  response 
) const

Definition at line 475 of file processor.cpp.

Here is the call graph for this function:

◆ startEventLoop()

bool avalanche::Processor::startEventLoop ( CScheduler scheduler)

Definition at line 680 of file processor.cpp.

Here is the call graph for this function:

◆ stopEventLoop()

bool avalanche::Processor::stopEventLoop ( )

Definition at line 685 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ withPeerManager()

template<typename Callable >
auto avalanche::Processor::withPeerManager ( Callable &&  func) const
inline

Definition at line 211 of file processor.h.

Friends And Related Function Documentation

◆ ::avalanche::AvalancheTest

friend struct ::avalanche::AvalancheTest
friend

Definition at line 259 of file processor.h.

Member Data Documentation

◆ avaconfig

Config avalanche::Processor::avaconfig
private

Definition at line 98 of file processor.h.

◆ avaproofsNodeCounter

std::atomic<int64_t> avalanche::Processor::avaproofsNodeCounter {0}
private

Definition at line 168 of file processor.h.

◆ blockVoteRecords

RWCollection<BlockVoteMap> avalanche::Processor::blockVoteRecords
private

Blocks to run avalanche on.

Definition at line 105 of file processor.h.

◆ chainman

ChainstateManager& avalanche::Processor::chainman
private

Definition at line 100 of file processor.h.

◆ chainNotificationsHandler

std::unique_ptr<interfaces::Handler> avalanche::Processor::chainNotificationsHandler
private

Definition at line 176 of file processor.h.

◆ connman

CConnman* avalanche::Processor::connman
private

Definition at line 99 of file processor.h.

◆ cs_finalizationTip

Mutex avalanche::Processor::cs_finalizationTip
private

Definition at line 178 of file processor.h.

◆ cs_peerManager

Mutex avalanche::Processor::cs_peerManager
mutableprivate

Keep track of the peers and associated infos.

Definition at line 120 of file processor.h.

◆ eventLoop

EventLoop avalanche::Processor::eventLoop
private

Event loop machinery.

Definition at line 159 of file processor.h.

◆ minAvaproofsNodeCount

int64_t avalanche::Processor::minAvaproofsNodeCount
private

Definition at line 167 of file processor.h.

◆ minQuorumConnectedScoreRatio

double avalanche::Processor::minQuorumConnectedScoreRatio
private

Definition at line 165 of file processor.h.

◆ minQuorumScore

uint32_t avalanche::Processor::minQuorumScore
private

Quorum management.

Definition at line 164 of file processor.h.

◆ peerData

std::unique_ptr<PeerData> avalanche::Processor::peerData
private

Definition at line 155 of file processor.h.

◆ proofVoteRecords

RWCollection<ProofVoteMap> avalanche::Processor::proofVoteRecords
private

Proofs to run avalanche on.

Definition at line 110 of file processor.h.

◆ queries

RWCollection<QuerySet> avalanche::Processor::queries
private

Definition at line 151 of file processor.h.

◆ quorumIsEstablished

std::atomic<bool> avalanche::Processor::quorumIsEstablished {false}
private

Definition at line 166 of file processor.h.

◆ round

std::atomic<uint64_t> avalanche::Processor::round
private

Keep track of peers and queries sent.

Definition at line 115 of file processor.h.

◆ sessionKey

CKey avalanche::Processor::sessionKey
private

Definition at line 156 of file processor.h.

◆ staleVoteFactor

const uint32_t avalanche::Processor::staleVoteFactor
private

Definition at line 172 of file processor.h.

◆ staleVoteThreshold

const uint32_t avalanche::Processor::staleVoteThreshold
private

Voting parameters.

Definition at line 171 of file processor.h.


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