Bitcoin ABC 0.33.1
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 <unordered_map>
40#include <variant>
41#include <vector>
42
43class ArgsManager;
44class CConnman;
45class CNode;
46class CScheduler;
47class Config;
48class PeerManager;
49struct bilingual_str;
50
55static constexpr size_t DEFAULT_AVALANCHE_MAX_ELEMENT_POLL = 1024;
56
63static constexpr size_t AVALANCHE_MAX_ELEMENT_POLL_LEGACY = 16;
64
69static constexpr size_t AVALANCHE_CONTENDER_MAX_POLLABLE = 12;
70
74static constexpr std::chrono::milliseconds AVALANCHE_DEFAULT_QUERY_TIMEOUT{
75 10000};
76
87
88namespace avalanche {
89
90class Delegation;
91class PeerManager;
92class ProofRegistrationState;
93struct VoteRecord;
94
95enum struct VoteStatus : uint8_t {
96 Invalid,
100 Stale,
101};
102
103using AnyVoteItem = std::variant<const ProofRef, const CBlockIndex *,
104 const StakeContenderId, const CTransactionRef>;
105
109
110public:
112 : item(std::move(itemIn)), status(statusIn) {}
113
114 const VoteStatus &getStatus() const { return status; }
115 const AnyVoteItem &getVoteItem() const { return item; }
116};
117
119 bool operator()(const AnyVoteItem &lhs, const AnyVoteItem &rhs) const {
120 // If the variants are of different types, sort them by variant index
121 if (lhs.index() != rhs.index()) {
122 return lhs.index() < rhs.index();
123 }
124
125 return std::visit(
127 [](const ProofRef &lhs, const ProofRef &rhs) {
128 return ProofComparatorByScore()(lhs, rhs);
129 },
130 [](const CBlockIndex *lhs, const CBlockIndex *rhs) {
131 // Reverse ordering so we get the highest work first
132 return CBlockIndexWorkComparator()(rhs, lhs);
133 },
134 [](const StakeContenderId &lhs, const StakeContenderId &rhs) {
135 return lhs < rhs;
136 },
137 [](const CTransactionRef &lhs, const CTransactionRef &rhs) {
138 return lhs->GetId() < rhs->GetId();
139 },
140 [](const auto &lhs, const auto &rhs) {
141 // This serves 2 purposes:
142 // - This makes sure that we don't forget to implement a
143 // comparison case when adding a new variant type.
144 // - This avoids having to write all the cross type cases
145 // which are already handled by the index sort above.
146 // Because the compiler has no way to determine that, we
147 // cannot use static assertions here without having to
148 // define the whole type matrix also.
149 assert(false);
150 // Return any bool, it's only there to make the compiler
151 // happy.
152 return false;
153 },
154 },
155 lhs, rhs);
156 }
157};
158using VoteMap = std::map<AnyVoteItem, VoteRecord, VoteMapComparator>;
159
161
162namespace {
163 struct AvalancheTest;
164}
165
166// FIXME Implement a proper notification handler for node disconnection instead
167// of implementing the whole NetEventsInterface for a single interesting event.
168class Processor final : public NetEventsInterface {
173
178
182 std::atomic<uint64_t> round;
183
188 std::unique_ptr<PeerManager> peerManager GUARDED_BY(cs_peerManager);
189
190 struct Query {
192 uint64_t round;
194
201 mutable std::vector<CInv> invs;
202 };
203
204 using QuerySet = boost::multi_index_container<
205 Query,
206 boost::multi_index::indexed_by<
207 // index by nodeid/round
208 boost::multi_index::hashed_unique<boost::multi_index::composite_key<
209 Query,
210 boost::multi_index::member<Query, NodeId, &Query::nodeid>,
211 boost::multi_index::member<Query, uint64_t, &Query::round>>>,
212 // sorted by timeout
213 boost::multi_index::ordered_non_unique<
214 boost::multi_index::tag<query_timeout>,
215 boost::multi_index::member<Query, SteadyMilliseconds,
216 &Query::timeout>>>>;
217
219
221 struct PeerData;
222 std::unique_ptr<PeerData> peerData;
224
227
233 std::atomic<bool> quorumIsEstablished{false};
234 std::atomic<bool> m_canShareLocalProof{false};
236 std::atomic<int64_t> avaproofsNodeCounter{0};
237
239 const uint32_t staleVoteThreshold;
240 const uint32_t staleVoteFactor;
241
244 std::unique_ptr<interfaces::Handler> chainNotificationsHandler;
245
247 const CBlockIndex *finalizationTip GUARDED_BY(cs_finalizationTip){nullptr};
248
254 std::unordered_set<NodeId>
255 delayedAvahelloNodeIds GUARDED_BY(cs_delayedAvahelloNodeIds);
256
259 // Ordered list of acceptable winners, only the first is used for mining
260 std::vector<std::pair<ProofId, CScript>> winners;
261 };
262
264 std::unordered_map<BlockHash, StakingReward, SaltedUint256Hasher>
266
269 CScheduler &scheduler, std::unique_ptr<PeerData> peerDataIn,
270 CKey sessionKeyIn, uint32_t minQuorumTotalScoreIn,
271 double minQuorumConnectedScoreRatioIn,
272 int64_t minAvaproofsNodeCountIn, uint32_t staleVoteThresholdIn,
273 uint32_t staleVoteFactorIn, Amount stakeUtxoDustThresholdIn,
274 bool preConsensus, bool stakingPreConsensus,
275 size_t maxElementPoll);
276
277 const bool m_preConsensus{false};
278 // Not const for testing purpose
279 std::atomic_bool m_stakingPreConsensus{false};
280
282
283public:
284 ~Processor();
285
286 static std::unique_ptr<Processor>
287 MakeProcessor(const ArgsManager &argsman, interfaces::Chain &chain,
289 CTxMemPool *mempoolIn, CScheduler &scheduler,
290 bilingual_str &error);
291
292 bool addToReconcile(const AnyVoteItem &item)
299 bool reconcileOrFinalize(const ProofRef &proof)
301 bool isAccepted(const AnyVoteItem &item) const;
302 int getConfidence(const AnyVoteItem &item) const;
303 bool isPolled(const AnyVoteItem &item) const;
304
305 bool isRecentlyFinalized(const uint256 &itemId) const
307 void setRecentlyFinalized(const uint256 &itemId)
310
311 // TODO: Refactor the API to remove the dependency on avalanche/protocol.h
312 void sendResponse(CNode *pfrom, Response response) const;
313 bool registerVotes(NodeId nodeid, const Response &response,
314 std::vector<VoteItemUpdate> &updates, bool &disconnect,
315 std::string &error)
318
319 template <typename Callable>
320 auto withPeerManager(Callable &&func) const
323 return func(*peerManager);
324 }
325
333 bool sendHello(CNode *pfrom)
337
338 ProofRef getLocalProof() const;
341
342 /*
343 * Return whether the avalanche service flag should be set.
344 */
346
350 return finalizationTip != nullptr;
351 }
352
353 bool startEventLoop(CScheduler &scheduler);
354 bool stopEventLoop();
355
358 int64_t getAvaproofsNodeCounter() const {
359 return avaproofsNodeCounter.load();
360 }
364 bool canShareLocalProof();
365
366 bool computeStakingReward(const CBlockIndex *pindex)
369 bool eraseStakingRewardWinner(const BlockHash &prevBlockHash)
371 void cleanupStakingRewards(const int minHeight)
374 const BlockHash &prevBlockHash,
375 std::vector<std::pair<ProofId, CScript>> &winners) const
377 bool getStakingRewardWinners(const BlockHash &prevBlockHash,
378 std::vector<CScript> &payouts) const
380 bool setStakingRewardWinners(const CBlockIndex *pprev,
381 const std::vector<CScript> &payouts)
384 const CBlockIndex *pprev,
385 const std::vector<std::pair<ProofId, CScript>> &winners)
387
388 // Implement NetEventInterface. Only FinalizeNode is of interest.
389 void InitializeNode(const ::Config &config, CNode &pnode,
390 ServiceFlags our_services) override {}
391 bool ProcessMessages(const ::Config &config, CNode *pnode,
392 std::atomic<bool> &interrupt) override {
393 return false;
394 }
395 bool SendMessages(const ::Config &config, CNode *pnode) override {
396 return false;
397 }
398
400 void FinalizeNode(const ::Config &config,
401 const CNode &node) override LOCKS_EXCLUDED(cs_main)
403
405 int getStakeContenderStatus(const StakeContenderId &contenderId) const
407 void acceptStakeContender(const StakeContenderId &contenderId)
409 void finalizeStakeContender(const StakeContenderId &contenderId)
411 void rejectStakeContender(const StakeContenderId &contenderId)
413
418
419 bool isPreconsensusActivated(const CBlockIndex *pprev) const;
420 bool isStakingPreconsensusActivated(const CBlockIndex *pprev) const;
421
422 size_t getMaxElementPoll() const { return m_maxElementPoll; }
423
424private:
425 void updatedBlockTip()
430 void runEventLoop()
436 std::vector<CInv>
437 getInvsForNextPoll(RWCollection<VoteMap>::ReadView &voteRecordsReadView,
438 size_t max_elements, bool forPoll = true) const;
439 bool sendHelloInternal(CNode *pfrom)
441 AnyVoteItem getVoteItemFromInv(const CInv &inv) const
443
450 const CBlockIndex *pindex,
451 std::vector<StakeContenderId> &pollableContenders)
453
462 100, 0.0000001};
463
476
479
480 IsWorthPolling(const Processor &_processor) : processor(_processor){};
481
482 bool operator()(const CBlockIndex *pindex) const
484 bool operator()(const ProofRef &proof) const
486 bool operator()(const StakeContenderId &contenderId) const
488 bool operator()(const CTransactionRef &tx) const;
489 };
490 bool isWorthPolling(const AnyVoteItem &item) const
492
495
496 GetLocalAcceptance(const Processor &_processor)
497 : processor(_processor){};
498
499 bool operator()(const CBlockIndex *pindex) const
501 bool operator()(const ProofRef &proof) const
503 bool operator()(const StakeContenderId &contenderId) const;
504 bool operator()(const CTransactionRef &tx) const;
505 };
506 bool getLocalAcceptance(const AnyVoteItem &item) const {
507 return std::visit(GetLocalAcceptance(*this), item);
508 }
509
510 friend struct ::avalanche::AvalancheTest;
511};
512
513} // namespace avalanche
514
515#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:830
Inv(ventory) message data.
Definition: protocol.h:590
An encapsulated secp256k1 private key.
Definition: key.h:28
Information about a peer.
Definition: net.h:389
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:41
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:221
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:1185
Definition: config.h:19
Interface for message handling.
Definition: net.h:779
void sendResponse(CNode *pfrom, Response response) const
Definition: processor.cpp:559
const uint32_t staleVoteThreshold
Voting parameters.
Definition: processor.h:239
std::atomic< bool > quorumIsEstablished
Definition: processor.h:233
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:216
AnyVoteItem getVoteItemFromInv(const CInv &inv) const EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.cpp:1406
Mutex cs_finalizedItems
Rolling bloom filter to track recently finalized inventory items of any type.
Definition: processor.h:473
bool sendHelloInternal(CNode *pfrom) EXCLUSIVE_LOCKS_REQUIRED(cs_delayedAvahelloNodeIds)
Definition: processor.cpp:716
int getConfidence(const AnyVoteItem &item) const
Definition: processor.cpp:493
bool addToReconcile(const AnyVoteItem &item) EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:442
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:146
bool isStakingPreconsensusActivated(const CBlockIndex *pprev) const
Definition: processor.cpp:1544
int64_t getAvaproofsNodeCounter() const
Definition: processor.h:358
RWCollection< QuerySet > queries
Definition: processor.h:218
bool hasFinalizedTip() const EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizationTip)
Whether there is a finalized tip.
Definition: processor.h:348
bool ProcessMessages(const ::Config &config, CNode *pnode, std::atomic< bool > &interrupt) override
Definition: processor.h:391
ProofRegistrationState getLocalProofRegistrationState() const EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.cpp:777
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:1157
void transactionAddedToMempool(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:1223
const CBlockIndex *finalizationTip GUARDED_BY(cs_finalizationTip)
Definition: processor.h:247
bool sendHello(CNode *pfrom) EXCLUSIVE_LOCKS_REQUIRED(!cs_delayedAvahelloNodeIds)
Send a avahello message.
Definition: processor.cpp:751
bool isRecentlyFinalized(const uint256 &itemId) const EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:517
void setRecentlyFinalized(const uint256 &itemId) EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:521
size_t getMaxElementPoll() const
Definition: processor.h:422
bool startEventLoop(CScheduler &scheduler)
Definition: processor.cpp:808
bool isQuorumEstablished() LOCKS_EXCLUDED(cs_main) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:838
std::atomic< uint64_t > round
Keep track of peers and queries sent.
Definition: processor.h:182
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:225
EventLoop eventLoop
Event loop machinery.
Definition: processor.h:226
CTxMemPool * mempool
Definition: processor.h:172
int64_t minAvaproofsNodeCount
Definition: processor.h:235
const bool m_preConsensus
Definition: processor.h:277
bool isPolled(const AnyVoteItem &item) const
Definition: processor.cpp:507
Mutex cs_delayedAvahelloNodeIds
Definition: processor.h:249
bool setStakingRewardWinners(const CBlockIndex *pprev, const std::vector< CScript > &payouts) EXCLUSIVE_LOCKS_REQUIRED(!cs_stakingRewards
Definition: processor.cpp:1034
void runEventLoop() EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:1230
bool isAvalancheServiceAvailable()
Definition: processor.h:345
Mutex cs_invalidatedBlocks
We don't need many blocks but a low false positive rate.
Definition: processor.h:460
void updatedBlockTip() EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:1169
RWCollection< VoteMap > voteRecords
Items to run avalanche on.
Definition: processor.h:177
std::unique_ptr< interfaces::Handler > chainNotificationsHandler
Definition: processor.h:244
uint32_t minQuorumScore
Quorum management.
Definition: processor.h:231
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:1070
bool getStakingRewardWinners(const BlockHash &prevBlockHash, std::vector< std::pair< ProofId, CScript > > &winners) const EXCLUSIVE_LOCKS_REQUIRED(!cs_stakingRewards)
Definition: processor.cpp:1005
std::atomic< bool > m_canShareLocalProof
Definition: processor.h:234
void cleanupStakingRewards(const int minHeight) EXCLUSIVE_LOCKS_REQUIRED(!cs_stakingRewards
Definition: processor.cpp:983
bool isAccepted(const AnyVoteItem &item) const
Definition: processor.cpp:479
ProofRef getLocalProof() const
Definition: processor.cpp:773
void acceptStakeContender(const StakeContenderId &contenderId) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.cpp:1101
void InitializeNode(const ::Config &config, CNode &pnode, ServiceFlags our_services) override
Definition: processor.h:389
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:460
int getStakeContenderStatus(const StakeContenderId &contenderId) const EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Track votes on stake contenders.
Definition: processor.cpp:1078
const uint32_t staleVoteFactor
Definition: processor.h:240
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:1133
void sendDelayedAvahello() EXCLUSIVE_LOCKS_REQUIRED(!cs_delayedAvahelloNodeIds)
Definition: processor.cpp:756
void finalizeStakeContender(const StakeContenderId &contenderId) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:1106
std::unique_ptr< PeerData > peerData
Definition: processor.h:222
const size_t m_maxElementPoll
Definition: processor.h:281
bool eraseStakingRewardWinner(const BlockHash &prevBlockHash) EXCLUSIVE_LOCKS_REQUIRED(!cs_stakingRewards)
Definition: processor.cpp:978
bool isPreconsensusActivated(const CBlockIndex *pprev) const
Definition: processor.cpp:1540
CConnman * connman
Definition: processor.h:170
std::vector< CInv > getInvsForNextPoll(RWCollection< VoteMap >::ReadView &voteRecordsReadView, size_t max_elements, bool forPoll=true) const
Definition: processor.cpp:1368
bool isWorthPolling(const AnyVoteItem &item) const EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:1499
CPubKey getSessionPubKey() const
Definition: processor.cpp:712
auto withPeerManager(Callable &&func) const EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.h:320
std::unique_ptr< PeerManager > peerManager GUARDED_BY(cs_peerManager)
ChainstateManager & chainman
Definition: processor.h:171
std::atomic< int64_t > avaproofsNodeCounter
Definition: processor.h:236
bool SendMessages(const ::Config &config, CNode *pnode) override
Definition: processor.h:395
std::atomic_bool m_stakingPreConsensus
Definition: processor.h:279
bool computeStakingReward(const CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:938
bool registerVotes(NodeId nodeid, const Response &response, std::vector< VoteItemUpdate > &updates, bool &disconnect, std::string &error) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:565
CRollingBloomFilter finalizedItems GUARDED_BY(cs_finalizedItems)
Definition: processor.h:474
void clearTimedoutRequests() EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.cpp:1329
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:187
bool getLocalAcceptance(const AnyVoteItem &item) const
Definition: processor.h:506
void rejectStakeContender(const StakeContenderId &contenderId) EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager)
Definition: processor.cpp:1128
void clearInvsNotWorthPolling() EXCLUSIVE_LOCKS_REQUIRED(!cs_peerManager
Definition: processor.cpp:1318
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:817
double minQuorumConnectedScoreRatio
Definition: processor.h:232
void clearFinalizedItems() EXCLUSIVE_LOCKS_REQUIRED(!cs_finalizedItems)
Definition: processor.cpp:525
const AnyVoteItem & getVoteItem() const
Definition: processor.h:115
VoteItemUpdate(AnyVoteItem itemIn, VoteStatus statusIn)
Definition: processor.h:111
const VoteStatus & getStatus() const
Definition: processor.h:114
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:129
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:104
std::map< AnyVoteItem, VoteRecord, VoteMapComparator > VoteMap
Definition: processor.h:158
RCUPtr< const Proof > ProofRef
Definition: proof.h:186
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:536
static constexpr size_t DEFAULT_AVALANCHE_MAX_ELEMENT_POLL
Maximum item that can be polled at once.
Definition: processor.h:55
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:69
static constexpr std::chrono::milliseconds AVALANCHE_DEFAULT_QUERY_TIMEOUT
How long before we consider that a query timed out.
Definition: processor.h:74
static constexpr size_t AVALANCHE_MAX_ELEMENT_POLL_LEGACY
Legacy maximum element poll.
Definition: processor.h:63
static constexpr uint32_t AVALANCHE_FINALIZED_ITEMS_FILTER_NUM_ELEMENTS
The size of the finalized items filter.
Definition: processor.h:85
ServiceFlags
nServices flags.
Definition: protocol.h:336
Definition: amount.h:21
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:1504
GetLocalAcceptance(const Processor &_processor)
Definition: processor.h:496
IsWorthPolling(const Processor &_processor)
Definition: processor.h:480
bool operator()(const CBlockIndex *pindex) const LOCKS_EXCLUDED(cs_main)
Definition: processor.cpp:1437
SteadyMilliseconds timeout
Definition: processor.h:193
std::vector< CInv > invs
We declare this as mutable so it can be modified in the multi_index.
Definition: processor.h:201
std::vector< std::pair< ProofId, CScript > > winners
Definition: processor.h:260
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:119
Bilingual messages:
Definition: translation.h:17
#define LOCK(cs)
Definition: sync.h:306
#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:40