Bitcoin ABC  0.24.7
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 Reference

#include <processor.h>

Collaboration diagram for avalanche::Processor:
[legend]

Classes

class  NotificationsHandler
 
struct  PeerData
 
struct  Query
 

Public Member Functions

 ~Processor ()
 
void setQueryTimeoutDuration (std::chrono::milliseconds d)
 
bool addBlockToReconcile (const CBlockIndex *pindex)
 
void 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 ()
 

Static Public Member Functions

static std::unique_ptr< ProcessorMakeProcessor (const ArgsManager &argsman, interfaces::Chain &chain, CConnman *connman, 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)
 
 Processor (interfaces::Chain &chain, CConnman *connmanIn, std::unique_ptr< PeerData > peerDataIn, CKey sessionKeyIn)
 
void runEventLoop ()
 
void clearTimedoutRequests ()
 
std::vector< CInvgetInvsForNextPoll (bool forPoll=true)
 
NodeId getSuitableNodeToQuery ()
 
uint256 buildLocalSighash (CNode *pfrom) const
 Build and return the challenge whose signature is included in the AVAHELLO message that we send to a peer. More...
 

Private Attributes

CConnmanconnman
 
std::chrono::milliseconds queryTimeoutDuration
 
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...
 
std::unique_ptr< interfaces::HandlerchainNotificationsHandler
 

Friends

struct ::avalanche::AvalancheTest
 

Detailed Description

Definition at line 91 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 142 of file processor.h.

Constructor & Destructor Documentation

◆ Processor()

avalanche::Processor::Processor ( interfaces::Chain chain,
CConnman connmanIn,
std::unique_ptr< PeerData peerDataIn,
CKey  sessionKeyIn 
)
private

Definition at line 132 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 142 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 246 of file processor.cpp.

Here is the call graph for this function:

◆ addProofToReconcile()

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

Definition at line 264 of file processor.cpp.

Here is the call graph for this function:

◆ buildLocalSighash()

uint256 avalanche::Processor::buildLocalSighash ( CNode pfrom) const
private

Build and return the challenge whose signature is included in the AVAHELLO message that we send to a peer.

Definition at line 488 of file processor.cpp.

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

◆ clearTimedoutRequests()

void avalanche::Processor::clearTimedoutRequests ( )
private

Definition at line 597 of file processor.cpp.

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

◆ getConfidence() [1/2]

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

Definition at line 295 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 305 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 537 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 524 of file processor.cpp.

◆ getSessionPubKey()

CPubKey avalanche::Processor::getSessionPubKey ( ) const

Definition at line 484 of file processor.cpp.

Here is the call graph for this function:

◆ getSuitableNodeToQuery()

NodeId avalanche::Processor::getSuitableNodeToQuery ( )
private

Definition at line 592 of file processor.cpp.

Here is the caller graph for this function:

◆ GUARDED_BY()

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

◆ isAccepted() [1/2]

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

Definition at line 275 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 285 of file processor.cpp.

Here is the call graph for this function:

◆ isAvalancheServiceAvailable()

bool avalanche::Processor::isAvalancheServiceAvailable ( )
inline

Definition at line 200 of file processor.h.

◆ MakeProcessor()

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

Definition at line 147 of file processor.cpp.

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

◆ 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 351 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 659 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 498 of file processor.cpp.

Here is the call graph for this function:

◆ sendResponse()

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

Definition at line 344 of file processor.cpp.

Here is the call graph for this function:

◆ setQueryTimeoutDuration()

void avalanche::Processor::setQueryTimeoutDuration ( std::chrono::milliseconds  d)
inline

Definition at line 169 of file processor.h.

◆ startEventLoop()

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

Definition at line 528 of file processor.cpp.

Here is the call graph for this function:

◆ stopEventLoop()

bool avalanche::Processor::stopEventLoop ( )

Definition at line 533 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 187 of file processor.h.

Friends And Related Function Documentation

◆ ::avalanche::AvalancheTest

friend struct ::avalanche::AvalancheTest
friend

Definition at line 217 of file processor.h.

Member Data Documentation

◆ blockVoteRecords

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

Blocks to run avalanche on.

Definition at line 98 of file processor.h.

◆ chainNotificationsHandler

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

Definition at line 155 of file processor.h.

◆ connman

CConnman* avalanche::Processor::connman
private

Definition at line 92 of file processor.h.

◆ cs_peerManager

Mutex avalanche::Processor::cs_peerManager
mutableprivate

Keep track of the peers and associated infos.

Definition at line 113 of file processor.h.

◆ eventLoop

EventLoop avalanche::Processor::eventLoop
private

Event loop machinery.

Definition at line 152 of file processor.h.

◆ peerData

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

Definition at line 147 of file processor.h.

◆ proofVoteRecords

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

Proofs to run avalanche on.

Definition at line 103 of file processor.h.

◆ queries

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

Definition at line 144 of file processor.h.

◆ queryTimeoutDuration

std::chrono::milliseconds avalanche::Processor::queryTimeoutDuration
private

Definition at line 93 of file processor.h.

◆ round

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

Keep track of peers and queries sent.

Definition at line 108 of file processor.h.

◆ sessionKey

CKey avalanche::Processor::sessionKey
private

Definition at line 149 of file processor.h.


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