![]() |
Bitcoin ABC
0.26.3
P2P Digital Currency
|
#include <processor.h>
Classes | |
struct | GetLocalAcceptance |
struct | IsWorthPolling |
class | NotificationsHandler |
struct | PeerData |
struct | Query |
struct | StakingReward |
Public Member Functions | |
~Processor () | |
bool | addToReconcile (const AnyVoteItem &item) |
bool | isAccepted (const AnyVoteItem &item) const |
int | getConfidence (const AnyVoteItem &item) const |
bool | isRecentlyFinalized (const AnyVoteItem &item) const |
void | sendResponse (CNode *pfrom, Response response) const |
bool | registerVotes (NodeId nodeid, const Response &response, std::vector< VoteItemUpdate > &updates, int &banscore, std::string &error) |
template<typename Callable > | |
auto | withPeerManager (Callable &&func) const |
CPubKey | getSessionPubKey () const |
bool | sendHello (CNode *pfrom) |
Send a avahello message. More... | |
void | sendDelayedAvahello () |
ProofRef | getLocalProof () const |
ProofRegistrationState | getLocalProofRegistrationState () 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) |
bool | canShareLocalProof () |
bool | computeStakingReward (const CBlockIndex *pindex) |
void | cleanupStakingRewards (const int minHeight) |
bool | getStakingRewardWinner (const BlockHash &prevBlockHash, CScript &winner) const |
bool | getStakingRewardAcceptableWinners (const BlockHash &prevBlockHash, std::vector< CScript > &acceptableWinners) const |
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... | |
![]() | |
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< Processor > | MakeProcessor (const ArgsManager &argsman, interfaces::Chain &chain, CConnman *connman, ChainstateManager &chainman, CTxMemPool *mempoolIn, 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) |
const CBlockIndex *finalizationTip | GUARDED_BY (cs_finalizationTip) |
std::unordered_set< NodeId > delayedAvahelloNodeIds | GUARDED_BY (cs_delayedAvahelloNodeIds) |
A list of the nodes that did not get our proof announced via avahello yet because we had no inbound connection. More... | |
std::unordered_map< BlockHash, StakingReward, SaltedUint256Hasher > stakingRewards | GUARDED_BY (cs_stakingRewards) |
Processor (Config avaconfig, interfaces::Chain &chain, CConnman *connmanIn, ChainstateManager &chainman, CTxMemPool *mempoolIn, 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< CInv > | getInvsForNextPoll (bool forPoll=true) |
bool | sendHelloInternal (CNode *pfrom) EXCLUSIVE_LOCKS_REQUIRED(cs_delayedAvahelloNodeIds) |
AnyVoteItem | getVoteItemFromInv (const CInv &inv) const |
CRollingBloomFilter invalidatedBlocks | GUARDED_BY (cs_invalidatedBlocks) |
CRollingBloomFilter finalizedItems | GUARDED_BY (cs_finalizedItems) |
bool | isWorthPolling (const AnyVoteItem &item) const |
bool | getLocalAcceptance (const AnyVoteItem &item) const |
Private Attributes | |
Config | avaconfig |
CConnman * | connman |
ChainstateManager & | chainman |
CTxMemPool * | mempool |
RWCollection< VoteMap > | voteRecords |
Items 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< QuerySet > | queries |
std::unique_ptr< PeerData > | peerData |
CKey | sessionKey |
EventLoop | eventLoop |
Event loop machinery. More... | |
uint32_t | minQuorumScore |
Quorum management. More... | |
double | minQuorumConnectedScoreRatio |
std::atomic< bool > | quorumIsEstablished {false} |
std::atomic< bool > | m_canShareLocalProof {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::Handler > | chainNotificationsHandler |
Mutex | cs_finalizationTip |
Mutex | cs_delayedAvahelloNodeIds |
Mutex | cs_stakingRewards |
Mutex | cs_invalidatedBlocks |
We don't need many blocks but a low false positive rate. More... | |
Mutex | cs_finalizedItems |
Rolling bloom filter to track recently finalized inventory items of any type. More... | |
Friends | |
struct | ::avalanche::AvalancheTest |
Additional Inherited Members | |
![]() | |
~NetEventsInterface ()=default | |
Protected destructor so that instances can only be deleted by derived classes. More... | |
Definition at line 181 of file processor.h.
|
private |
Definition at line 217 of file processor.h.
|
private |
Definition at line 162 of file processor.cpp.
avalanche::Processor::~Processor | ( | ) |
bool avalanche::Processor::addToReconcile | ( | const AnyVoteItem & | item | ) |
Definition at line 389 of file processor.cpp.
void avalanche::Processor::avaproofsSent | ( | NodeId | nodeid | ) |
bool avalanche::Processor::canShareLocalProof | ( | ) |
Definition at line 807 of file processor.cpp.
void avalanche::Processor::cleanupStakingRewards | ( | const int | minHeight | ) |
Definition at line 853 of file processor.cpp.
|
private |
Definition at line 953 of file processor.cpp.
bool avalanche::Processor::computeStakingReward | ( | const CBlockIndex * | pindex | ) |
Handle removal of a node.
Definition at line 877 of file processor.cpp.
|
inline |
Definition at line 335 of file processor.h.
int avalanche::Processor::getConfidence | ( | const AnyVoteItem & | item | ) | const |
|
private |
Definition at line 992 of file processor.cpp.
|
inlineprivate |
ProofRef avalanche::Processor::getLocalProof | ( | ) | const |
ProofRegistrationState avalanche::Processor::getLocalProofRegistrationState | ( | ) | const |
Definition at line 700 of file processor.cpp.
CPubKey avalanche::Processor::getSessionPubKey | ( | ) | const |
bool avalanche::Processor::getStakingRewardAcceptableWinners | ( | const BlockHash & | prevBlockHash, |
std::vector< CScript > & | acceptableWinners | ||
) | const |
bool avalanche::Processor::getStakingRewardWinner | ( | const BlockHash & | prevBlockHash, |
CScript & | winner | ||
) | const |
Definition at line 865 of file processor.cpp.
|
private |
Definition at line 1038 of file processor.cpp.
|
private |
A list of the nodes that did not get our proof announced via avahello yet because we had no inbound connection.
|
inlineprivate |
Definition at line 260 of file processor.h.
|
inlineprivate |
Definition at line 391 of file processor.h.
|
inlineprivate |
Definition at line 378 of file processor.h.
|
private |
|
private |
Definition at line 350 of file processor.h.
bool avalanche::Processor::isAccepted | ( | const AnyVoteItem & | item | ) | const |
|
inline |
Definition at line 329 of file processor.h.
bool avalanche::Processor::isQuorumEstablished | ( | ) |
Definition at line 736 of file processor.cpp.
bool avalanche::Processor::isRecentlyFinalized | ( | const AnyVoteItem & | item | ) | const |
Definition at line 435 of file processor.cpp.
|
private |
Definition at line 1109 of file processor.cpp.
|
static |
Definition at line 201 of file processor.cpp.
|
inlineoverride |
Definition at line 351 of file processor.h.
bool avalanche::Processor::registerVotes | ( | NodeId | nodeid, |
const Response & | response, | ||
std::vector< VoteItemUpdate > & | updates, | ||
int & | banscore, | ||
std::string & | error | ||
) |
|
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 885 of file processor.cpp.
void avalanche::Processor::sendDelayedAvahello | ( | ) |
bool avalanche::Processor::sendHello | ( | CNode * | pfrom | ) |
Send a avahello message.
pfrom | The node to send the message to |
Definition at line 674 of file processor.cpp.
|
private |
Definition at line 638 of file processor.cpp.
Definition at line 355 of file processor.h.
bool avalanche::Processor::startEventLoop | ( | CScheduler & | scheduler | ) |
bool avalanche::Processor::stopEventLoop | ( | ) |
Definition at line 711 of file processor.cpp.
|
inline |
Definition at line 308 of file processor.h.
|
friend |
Definition at line 423 of file processor.h.
|
private |
Definition at line 182 of file processor.h.
|
private |
Definition at line 249 of file processor.h.
|
private |
Definition at line 184 of file processor.h.
|
private |
Definition at line 257 of file processor.h.
|
private |
Definition at line 183 of file processor.h.
|
mutableprivate |
Definition at line 262 of file processor.h.
|
mutableprivate |
Definition at line 259 of file processor.h.
|
mutableprivate |
Rolling bloom filter to track recently finalized inventory items of any type.
Once placed in this filter, those items will not be polled again unless they roll out. Note that this one filter tracks all types so blocks may be rolled out by transaction activity for example.
We want a low false positive rate to prevent accidentally not polling for an item when it is first seen.
Definition at line 390 of file processor.h.
|
mutableprivate |
We don't need many blocks but a low false positive rate.
In the event of a false positive the node might skip polling this block. Such a block will not get marked as finalized until it is reconsidered for polling (if the filter changed its state) or another block is found.
Definition at line 377 of file processor.h.
|
mutableprivate |
Keep track of the peers and associated infos.
Definition at line 200 of file processor.h.
|
mutableprivate |
Definition at line 276 of file processor.h.
|
private |
Event loop machinery.
Definition at line 239 of file processor.h.
|
private |
Definition at line 247 of file processor.h.
|
private |
Definition at line 185 of file processor.h.
|
private |
Definition at line 248 of file processor.h.
|
private |
Definition at line 245 of file processor.h.
|
private |
Quorum management.
Definition at line 244 of file processor.h.
|
private |
Definition at line 235 of file processor.h.
|
private |
Definition at line 231 of file processor.h.
|
private |
Definition at line 246 of file processor.h.
|
private |
Keep track of peers and queries sent.
Definition at line 195 of file processor.h.
|
private |
Definition at line 236 of file processor.h.
|
private |
Definition at line 253 of file processor.h.
|
private |
Voting parameters.
Definition at line 252 of file processor.h.
|
private |
Items to run avalanche on.
Definition at line 190 of file processor.h.