Bitcoin ABC 0.34.3
P2P Digital Currency
processor.h
Go to the documentation of this file.
1// Copyright (c) 2018-2019 The Bitcoin developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_AVALANCHE_PROCESSOR_H
6#define BITCOIN_AVALANCHE_PROCESSOR_H
7
8#include <avalanche/config.h>
9#include <avalanche/node.h>
10#include <avalanche/proof.h>
12#include <avalanche/protocol.h>
14#include <avalanche/voterecord.h> // For AVALANCHE_MAX_INFLIGHT_POLL
15#include <blockindex.h>
17#include <common/bloom.h>
18#include <eventloop.h>
19#include <interfaces/chain.h>
20#include <interfaces/handler.h>
21#include <key.h>
22#include <net.h>
24#include <rwcollection.h>
25#include <txmempool.h>
26#include <util/variant.h>
27#include <validationinterface.h>
28
29#include <boost/multi_index/composite_key.hpp>
30#include <boost/multi_index/hashed_index.hpp>
31#include <boost/multi_index/member.hpp>
32#include <boost/multi_index/ordered_index.hpp>
33#include <boost/multi_index_container.hpp>
34
35#include <atomic>
36#include <chrono>
37#include <cstdint>
38#include <memory>
39#include <optional>
40#include <unordered_map>
41#include <variant>
42#include <vector>
43
44class ArgsManager;
45class CConnman;
46class CNode;
47class CScheduler;
48class Config;
49class PeerManager;
50struct bilingual_str;
51
56static constexpr size_t DEFAULT_AVALANCHE_MAX_ELEMENT_POLL = 1024;
57
64static constexpr size_t AVALANCHE_MAX_ELEMENT_POLL_LEGACY = 16;
65
70static constexpr size_t AVALANCHE_CONTENDER_MAX_POLLABLE = 12;
71
75static constexpr std::chrono::milliseconds AVALANCHE_DEFAULT_QUERY_TIMEOUT{
76 10000};
77
88
89namespace avalanche {
90
91class Delegation;
92class PeerManager;
93class ProofRegistrationState;
94struct VoteRecord;
95
96enum struct VoteStatus : uint8_t {
97 Invalid,
100 Finalized,
101 Stale,
102};
103
104using AnyVoteItem = std::variant<const ProofRef, const CBlockIndex *,
105 const StakeContenderId, const CTransactionRef>;
106
110
111public:
113 : item(std::move(itemIn)), status(statusIn) {}
114
115 const VoteStatus &getStatus() const { return status; }
116 const AnyVoteItem &getVoteItem() const { return item; }
117};
118
120 bool operator()(const AnyVoteItem &lhs, const AnyVoteItem &rhs) const {
121 // If the variants are of different types, sort them by variant index
122 if (lhs.index() != rhs.index()) {
123 return lhs.index() < rhs.index();
124 }
125
126 return std::visit(
128 [](const ProofRef &lhs, const ProofRef &rhs) {
129 return ProofComparatorByScore()(lhs, rhs);
130 },
131 [](const CBlockIndex *lhs, const CBlockIndex *rhs) {
132 // Reverse ordering so we get the highest work first
133 return CBlockIndexWorkComparator()(rhs, lhs);
134 },
135 [](const StakeContenderId &lhs, const StakeContenderId &rhs) {
136 return lhs < rhs;
137 },
138 [](const CTransactionRef &lhs, const CTransactionRef &rhs) {
139 return lhs->GetId() < rhs->GetId();
140 },
141 [](const auto &lhs, const auto &rhs) {
142 // This serves 2 purposes:
143 // - This makes sure that we don't forget to implement a
144 // comparison case when adding a new variant type.
145 // - This avoids having to write all the cross type cases
146 // which are already handled by the index sort above.
147 // Because the compiler has no way to determine that, we
148 // cannot use static assertions here without having to
149 // define the whole type matrix also.
150 assert(false);
151 // Return any bool, it's only there to make the compiler
152 // happy.
153 return false;
154 },
155 },
156 lhs, rhs);
157 }
158};
159using VoteMap = std::map<AnyVoteItem, VoteRecord, VoteMapComparator>;
160
162
163namespace {
164 struct AvalancheTest;
165}
166
167// FIXME Implement a proper notification handler for node disconnection instead
168// of implementing the whole NetEventsInterface for a single interesting event.
169class Processor final : public NetEventsInterface {
174
179
183 std::atomic<uint64_t> round;
184
189 std::unique_ptr<PeerManager> peerManager GUARDED_BY(cs_peerManager);
190
191 struct Query {
193 uint64_t round;
195
202 mutable std::vector<CInv> invs;
203 };
204
205 using QuerySet = boost::multi_index_container<
206 Query,
207 boost::multi_index::indexed_by<
208 // index by nodeid/round
209 boost::multi_index::hashed_unique<boost::multi_index::composite_key<
210 Query,
211 boost::multi_index::member<Query, NodeId, &Query::nodeid>,
212 boost::multi_index::member<Query, uint64_t, &Query::round>>>,
213 // sorted by timeout
214 boost::multi_index::ordered_non_unique<
215 boost::multi_index::tag<query_timeout>,
216 boost::multi_index::member<Query, SteadyMilliseconds,
217 &Query::timeout>>>>;
218
220
222 struct PeerData;
223 std::unique_ptr<PeerData> peerData;
225
228
234 std::atomic<bool> quorumIsEstablished{false};
235 std::atomic<bool> m_canShareLocalProof{false};
237 std::atomic<int64_t> avaproofsNodeCounter{0};
238
240 const uint32_t staleVoteThreshold;
241 const uint32_t staleVoteFactor;
242
245 std::unique_ptr<interfaces::Handler> chainNotificationsHandler;
246
248 const CBlockIndex *finalizationTip GUARDED_BY(cs_finalizationTip){nullptr};
249
255 std::unordered_set<NodeId>
256 delayedAvahelloNodeIds GUARDED_BY(cs_delayedAvahelloNodeIds);
257
260 // Ordered list of acceptable winners, only the first is used for mining
261 std::vector<std::pair<ProofId, CScript>> winners;
262 };
263
265 std::unordered_map<BlockHash, StakingReward, SaltedUint256Hasher>
267
270 CScheduler &scheduler, std::unique_ptr<PeerData> peerDataIn,
271 CKey sessionKeyIn, uint32_t minQuorumTotalScoreIn,
272 double minQuorumConnectedScoreRatioIn,
273 int64_t minAvaproofsNodeCountIn, uint32_t staleVoteThresholdIn,
274 uint32_t staleVoteFactorIn, Amount stakeUtxoDustThresholdIn,
275 bool preConsensus, bool stakingPreConsensus,
276 size_t maxElementPoll);
277
278 const bool m_preConsensus{false};
279 // Not const for testing purpose
280 std::atomic_bool m_stakingPreConsensus{false};
281 // When set, VoteRecords use this seed instead of a random one (tests only).
282 std::optional<uint32_t> m_voteRecordSeed;
283
285
286public:
287 ~Processor();
288
289 static std::unique_ptr<Processor>
290 MakeProcessor(const ArgsManager &argsman, interfaces::Chain &chain,
292 CTxMemPool *mempoolIn, CScheduler &scheduler,
293 bilingual_str &error);
294
295 bool addToReconcile(const AnyVoteItem &item)
302 bool reconcileOrFinalize(const ProofRef &proof)
304 bool isAccepted(const AnyVoteItem &item) const;
305 int getConfidence(const AnyVoteItem &item) const;
306 bool isPolled(const AnyVoteItem &item) const;
307
308 bool isRecentlyFinalized(const uint256 &itemId) const
310 void setRecentlyFinalized(const uint256 &itemId)
313
314 // TODO: Refactor the API to remove the dependency on avalanche/protocol.h
315 void sendResponse(CNode *pfrom, Response response) const;
316 bool registerVotes(NodeId nodeid, const Response &response,
317 std::vector<VoteItemUpdate> &updates, bool &disconnect,
318 std::string &error)
321
322 template <typename Callable>
323 auto withPeerManager(Callable &&func) const
326 return func(*peerManager);
327 }
328
336 bool sendHello(CNode *pfrom)
340
341 ProofRef getLocalProof() const;
344
345 /*
346 * Return whether the avalanche service flag should be set.
347 */
349
353 return finalizationTip != nullptr;
354 }
355
356 bool startEventLoop(CScheduler &scheduler);
357 bool stopEventLoop();
358
361 int64_t getAvaproofsNodeCounter() const {
362 return avaproofsNodeCounter.load();
363 }
367 bool canShareLocalProof();
368
369 bool computeStakingReward(const CBlockIndex *pindex)
372 bool eraseStakingRewardWinner(const BlockHash &prevBlockHash)
374 void cleanupStakingRewards(const int minHeight)
377 const BlockHash &prevBlockHash,
378 std::vector<std::pair<ProofId, CScript>> &winners) const
380 bool getStakingRewardWinners(const BlockHash &prevBlockHash,
381 std::vector<CScript> &payouts) const
383 bool setStakingRewardWinners(const CBlockIndex *pprev,
384 const std::vector<CScript> &payouts)
387 const CBlockIndex *pprev,
388 const std::vector<std::pair<ProofId, CScript>> &winners)
390
391 // Implement NetEventInterface. Only FinalizeNode is of interest.
392 void InitializeNode(const ::Config &config, CNode &pnode,
393 ServiceFlags our_services) override {}
394 bool ProcessMessages(const ::Config &config, CNode *pnode,
395 std::atomic<bool> &interrupt) override {
396 return false;
397 }
398 bool SendMessages(const ::Config &config, CNode *pnode) override {
399 return false;
400 }
401
403 void FinalizeNode(const ::Config &config,
404 const CNode &node) override LOCKS_EXCLUDED(cs_main)
406
408 int getStakeContenderStatus(const StakeContenderId &contenderId) const
410 void acceptStakeContender(const StakeContenderId &contenderId)
412 void finalizeStakeContender(const StakeContenderId &contenderId)
414 void rejectStakeContender(const StakeContenderId &contenderId)
416
421
422 bool isPreconsensusActivated(const CBlockIndex *pprev) const
424 bool isStakingPreconsensusActivated(const CBlockIndex *pprev) const;
425
426 size_t getMaxElementPoll() const { return m_maxElementPoll; }
427
428private:
429 void updatedBlockTip()
434 void runEventLoop()
444 void clearInflightRequests(const std::vector<CInv> &invs)
449 void clearInflightRequests(const std::map<CInv, uint8_t> &inflightRequests)
451 std::vector<CInv>
452 getInvsForNextPoll(RWCollection<VoteMap>::ReadView &voteRecordsReadView,
453 size_t max_elements, bool forPoll = true) const;
454 bool sendHelloInternal(CNode *pfrom)
456 AnyVoteItem getVoteItemFromInv(const CInv &inv) const
458
465 const CBlockIndex *pindex,
466 std::vector<StakeContenderId> &pollableContenders)
468
477 100, 0.0000001};
478
491
494
495 IsWorthPolling(const Processor &_processor) : processor(_processor) {};
496
497 bool operator()(const CBlockIndex *pindex) const
499 bool operator()(const ProofRef &proof) const
501 bool operator()(const StakeContenderId &contenderId) const
503 bool operator()(const CTransactionRef &tx) const;
504 };
505 bool isWorthPolling(const AnyVoteItem &item) const
507
510
511 GetLocalAcceptance(const Processor &_processor)
512 : processor(_processor) {};
513
514 bool operator()(const CBlockIndex *pindex) const
516 bool operator()(const ProofRef &proof) const
518 bool operator()(const StakeContenderId &contenderId) const;
519 bool operator()(const CTransactionRef &tx) const;
520 };
521 bool getLocalAcceptance(const AnyVoteItem &item) const {
522 return std::visit(GetLocalAcceptance(*this), item);
523 }
524
525 friend struct ::avalanche::AvalancheTest;
526};
527
528} // namespace avalanche
529
530#endif // BITCOIN_AVALANCHE_PROCESSOR_H
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:25
Definition: net.h:838
Inv(ventory) message data.
Definition: protocol.h:588
An encapsulated secp256k1 private key.
Definition: key.h:28
Information about a peer.
Definition: net.h:395
An encapsulated public key.
Definition: pubkey.h:31
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set.
Definition: bloom.h:115
Simple class for background tasks that should be run periodically or once "after a while".
Definition: scheduler.h:42
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:222
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:1176
Definition: config.h:19
Interface for message handling.
Definition: net.h:787
void sendResponse(CNode *pfrom, Response response) const
Definition: processor.cpp:562
const uint32_t staleVoteThreshold
Voting parameters.
Definition: processor.h:240
std::atomic< bool > quorumIsEstablished
Definition: processor.h:234
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, SteadyMilliseconds, &Query::timeout > > > > QuerySet
Definition: processor.h:217
AnyVoteItem getVoteItemFromInv(const CInv &inv) const EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.cpp:1500
Mutex cs_finalizedItems
Rolling bloom filter to track recently finalized inventory items of any type.
Definition: processor.h:488
bool sendHelloInternal(CNode *pfrom) EXCLUSIVE_LOCKS_REQUIRED(cs_delayedAvahelloNodeIds)
Definition: processor.cpp:721
int getConfidence(const AnyVoteItem &item) const
Definition: processor.cpp:496
bool addToReconcile(const AnyVoteItem &item) EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:443
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, bool preConsensus, bool stakingPreConsensus, size_t maxElementPoll)
Definition: processor.cpp:147
bool isStakingPreconsensusActivated(const CBlockIndex *pprev) const
Definition: processor.cpp:1640
int64_t getAvaproofsNodeCounter() const
Definition: processor.h:361
RWCollection< QuerySet > queries
Definition: processor.h:219
bool hasFinalizedTip() const EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizationTip)
Whether there is a finalized tip.
Definition: processor.h:351
bool isPreconsensusActivated(const CBlockIndex *pprev) const EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizationTip)
Definition: processor.cpp:1634
bool ProcessMessages(const ::Config &config, CNode *pnode, std::atomic< bool > &interrupt) override
Definition: processor.h:394
ProofRegistrationState getLocalProofRegistrationState() const EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.cpp:782
bool setContenderStatusForLocalWinners(const CBlockIndex *pindex, std::vector< StakeContenderId > &pollableContenders) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Helper to set the vote status for local winners in the contender cache.
Definition: processor.cpp:1230
const CBlockIndex *finalizationTip GUARDED_BY(cs_finalizationTip)
Definition: processor.h:248
bool sendHello(CNode *pfrom) EXCLUSIVE_LOCKS_REQUIRED(!cs_delayedAvahelloNodeIds)
Send a avahello message.
Definition: processor.cpp:756
bool isRecentlyFinalized(const uint256 &itemId) const EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:520
void setRecentlyFinalized(const uint256 &itemId) EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:524
size_t getMaxElementPoll() const
Definition: processor.h:426
bool startEventLoop(CScheduler &scheduler)
Definition: processor.cpp:813
bool isQuorumEstablished() LOCKS_EXCLUDED(cs_main) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:843
std::atomic< uint64_t > round
Keep track of peers and queries sent.
Definition: processor.h:183
static std::unique_ptr< Processor > MakeProcessor(const ArgsManager &argsman, interfaces::Chain &chain, CConnman *connman, ChainstateManager &chainman, CTxMemPool *mempoolIn, CScheduler &scheduler, bilingual_str &error)
Definition: processor.cpp:226
EventLoop eventLoop
Event loop machinery.
Definition: processor.h:227
CTxMemPool * mempool
Definition: processor.h:173
int64_t minAvaproofsNodeCount
Definition: processor.h:236
const bool m_preConsensus
Definition: processor.h:278
bool isPolled(const AnyVoteItem &item) const
Definition: processor.cpp:510
Mutex cs_delayedAvahelloNodeIds
Definition: processor.h:250
bool setStakingRewardWinners(const CBlockIndex *pprev, const std::vector< CScript > &payouts) EXCLUSIVE_LOCKS_REQUIRED(!cs_stakingRewards
Definition: processor.cpp:1039
void runEventLoop() EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:1303
bool isAvalancheServiceAvailable()
Definition: processor.h:348
Mutex cs_invalidatedBlocks
We don't need many blocks but a low false positive rate.
Definition: processor.h:475
void updatedBlockTip() EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:1242
RWCollection< VoteMap > voteRecords
Items to run avalanche on.
Definition: processor.h:178
std::unique_ptr< interfaces::Handler > chainNotificationsHandler
Definition: processor.h:245
uint32_t minQuorumScore
Quorum management.
Definition: processor.h:232
void FinalizeNode(const ::Config &config, const CNode &node) override LOCKS_EXCLUDED(cs_main) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Handle removal of a node.
Definition: processor.cpp:1075
bool getStakingRewardWinners(const BlockHash &prevBlockHash, std::vector< std::pair< ProofId, CScript > > &winners) const EXCLUSIVE_LOCKS_REQUIRED(!cs_stakingRewards)
Definition: processor.cpp:1010
std::atomic< bool > m_canShareLocalProof
Definition: processor.h:235
void cleanupStakingRewards(const int minHeight) EXCLUSIVE_LOCKS_REQUIRED(!cs_stakingRewards
Definition: processor.cpp:988
bool isAccepted(const AnyVoteItem &item) const
Definition: processor.cpp:482
ProofRef getLocalProof() const
Definition: processor.cpp:778
void acceptStakeContender(const StakeContenderId &contenderId) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.cpp:1106
void InitializeNode(const ::Config &config, CNode &pnode, ServiceFlags our_services) override
Definition: processor.h:392
bool reconcileOrFinalize(const ProofRef &proof) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Wrapper around the addToReconcile for proofs that adds back the finalization flag to the peer if it i...
Definition: processor.cpp:463
int getStakeContenderStatus(const StakeContenderId &contenderId) const EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Track votes on stake contenders.
Definition: processor.cpp:1083
const uint32_t staleVoteFactor
Definition: processor.h:241
void promoteAndPollStakeContenders(const CBlockIndex *pprev) EXCLUSIVE_LOCKS_REQUIRED(!cs_stakingRewards
Promote stake contender cache entries to a given block and then poll.
Definition: processor.cpp:1206
void sendDelayedAvahello() EXCLUSIVE_LOCKS_REQUIRED(!cs_delayedAvahelloNodeIds)
Definition: processor.cpp:761
void finalizeStakeContender(const StakeContenderId &contenderId) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:1111
std::unique_ptr< PeerData > peerData
Definition: processor.h:223
const size_t m_maxElementPoll
Definition: processor.h:284
bool eraseStakingRewardWinner(const BlockHash &prevBlockHash) EXCLUSIVE_LOCKS_REQUIRED(!cs_stakingRewards)
Definition: processor.cpp:983
CConnman * connman
Definition: processor.h:171
std::vector< CInv > getInvsForNextPoll(RWCollection< VoteMap >::ReadView &voteRecordsReadView, size_t max_elements, bool forPoll=true) const
Definition: processor.cpp:1462
bool isWorthPolling(const AnyVoteItem &item) const EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:1593
CPubKey getSessionPubKey() const
Definition: processor.cpp:717
void clearInflightRequests(const std::vector< CInv > &invs) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Decrement VoteRecord::inflight for each inventory.
Definition: processor.cpp:1431
auto withPeerManager(Callable &&func) const EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.h:323
std::unique_ptr< PeerManager > peerManager GUARDED_BY(cs_peerManager)
ChainstateManager & chainman
Definition: processor.h:172
std::atomic< int64_t > avaproofsNodeCounter
Definition: processor.h:237
std::optional< uint32_t > m_voteRecordSeed
Definition: processor.h:282
bool SendMessages(const ::Config &config, CNode *pnode) override
Definition: processor.h:398
std::atomic_bool m_stakingPreConsensus
Definition: processor.h:280
bool computeStakingReward(const CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:943
bool registerVotes(NodeId nodeid, const Response &response, std::vector< VoteItemUpdate > &updates, bool &disconnect, std::string &error) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:568
CRollingBloomFilter finalizedItems GUARDED_BY(cs_finalizedItems)
Definition: processor.h:489
void clearTimedoutRequests() EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.cpp:1411
void transactionAddedToMempool(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems
Definition: processor.cpp:1296
std::unordered_map< BlockHash, StakingReward, SaltedUint256Hasher > stakingRewards GUARDED_BY(cs_stakingRewards)
Mutex cs_peerManager
Keep track of the peers and associated infos.
Definition: processor.h:188
bool getLocalAcceptance(const AnyVoteItem &item) const
Definition: processor.h:521
void clearInvsNotWorthPolling() EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:1400
void rejectStakeContender(const StakeContenderId &contenderId) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:1133
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 c...
void avaproofsSent(NodeId nodeid) LOCKS_EXCLUDED(cs_main) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.cpp:822
double minQuorumConnectedScoreRatio
Definition: processor.h:233
void clearFinalizedItems() EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:528
const AnyVoteItem & getVoteItem() const
Definition: processor.h:116
VoteItemUpdate(AnyVoteItem itemIn, VoteStatus statusIn)
Definition: processor.h:112
const VoteStatus & getStatus() const
Definition: processor.h:115
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:136
256-bit opaque blob.
Definition: uint256.h:199
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: cs_main.cpp:7
int64_t NodeId
Definition: eviction.h:16
std::variant< const ProofRef, const CBlockIndex *, const StakeContenderId, const CTransactionRef > AnyVoteItem
Definition: processor.h:105
std::map< AnyVoteItem, VoteRecord, VoteMapComparator > VoteMap
Definition: processor.h:159
RCUPtr< const Proof > ProofRef
Definition: proof.h:183
Definition: messages.h:12
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition: rcu.h:259
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:315
Response response
Definition: processor.cpp:539
static constexpr size_t DEFAULT_AVALANCHE_MAX_ELEMENT_POLL
Maximum item that can be polled at once.
Definition: processor.h:56
static constexpr size_t AVALANCHE_CONTENDER_MAX_POLLABLE
Maximum number of stake contenders to poll for, leaving room for polling blocks and proofs in the sam...
Definition: processor.h:70
static constexpr std::chrono::milliseconds AVALANCHE_DEFAULT_QUERY_TIMEOUT
How long before we consider that a query timed out.
Definition: processor.h:75
static constexpr size_t AVALANCHE_MAX_ELEMENT_POLL_LEGACY
Legacy maximum element poll.
Definition: processor.h:64
static constexpr uint32_t AVALANCHE_FINALIZED_ITEMS_FILTER_NUM_ELEMENTS
The size of the finalized items filter.
Definition: processor.h:86
ServiceFlags
nServices flags.
Definition: protocol.h:335
Definition: amount.h:23
A BlockHash is a unqiue identifier for a block.
Definition: blockhash.h:13
bool operator()(const CBlockIndex *pindex) const LOCKS_EXCLUDED(cs_main)
Definition: processor.cpp:1598
GetLocalAcceptance(const Processor &_processor)
Definition: processor.h:511
IsWorthPolling(const Processor &_processor)
Definition: processor.h:495
bool operator()(const CBlockIndex *pindex) const LOCKS_EXCLUDED(cs_main)
Definition: processor.cpp:1531
SteadyMilliseconds timeout
Definition: processor.h:194
std::vector< CInv > invs
We declare this as mutable so it can be modified in the multi_index.
Definition: processor.h:202
std::vector< std::pair< ProofId, CScript > > winners
Definition: processor.h:261
Compare proofs by score, then by id in case of equality.
StakeContenderIds are unique for each block to ensure that the peer polling for their acceptance has ...
bool operator()(const AnyVoteItem &lhs, const AnyVoteItem &rhs) const
Definition: processor.h:120
Bilingual messages:
Definition: translation.h:17
#define LOCK(cs)
Definition: sync.h:295
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:56
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:55
std::chrono::time_point< std::chrono::steady_clock, std::chrono::milliseconds > SteadyMilliseconds
Definition: time.h:33
assert(!tx.IsCoinBase())
static constexpr int AVALANCHE_MAX_INFLIGHT_POLL
How many inflight requests can exist for one item.
Definition: voterecord.h:41