Bitcoin ABC 0.33.3
P2P Digital Currency
peermanager.h
Go to the documentation of this file.
1// Copyright (c) 2020 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_PEERMANAGER_H
6#define BITCOIN_AVALANCHE_PEERMANAGER_H
7
8#include <avalanche/node.h>
9#include <avalanche/proof.h>
10#include <avalanche/proofpool.h>
12#include <avalanche/protocol.h>
14#include <coins.h>
15#include <common/bloom.h>
17#include <radix.h>
18#include <util/fs.h>
19#include <util/hasher.h>
20#include <util/time.h>
21
22#include <boost/multi_index/composite_key.hpp>
23#include <boost/multi_index/hashed_index.hpp>
24#include <boost/multi_index/mem_fun.hpp>
25#include <boost/multi_index/member.hpp>
26#include <boost/multi_index/ordered_index.hpp>
27#include <boost/multi_index_container.hpp>
28
29#include <atomic>
30#include <chrono>
31#include <cstdint>
32#include <memory>
33#include <vector>
34
36class CScheduler;
37
38namespace avalanche {
39
46static constexpr uint32_t AVALANCHE_MAX_IMMATURE_PROOFS = 4000;
47
48class Delegation;
49
50namespace {
51 struct TestPeerManager;
52}
53
54struct Slot {
55private:
56 uint64_t start;
57 uint32_t score;
59
60public:
61 Slot(uint64_t startIn, uint32_t scoreIn, PeerId peeridIn)
62 : start(startIn), score(scoreIn), peerid(peeridIn) {}
63
64 Slot withStart(uint64_t startIn) const {
65 return Slot(startIn, score, peerid);
66 }
67 Slot withScore(uint64_t scoreIn) const {
68 return Slot(start, scoreIn, peerid);
69 }
70 Slot withPeerId(PeerId peeridIn) const {
71 return Slot(start, score, peeridIn);
72 }
73
74 uint64_t getStart() const { return start; }
75 uint64_t getStop() const { return start + score; }
76 uint32_t getScore() const { return score; }
77 PeerId getPeerId() const { return peerid; }
78
79 bool contains(uint64_t slot) const {
80 return getStart() <= slot && slot < getStop();
81 }
82 bool precedes(uint64_t slot) const { return slot >= getStop(); }
83 bool follows(uint64_t slot) const { return getStart() > slot; }
84};
85
86struct Peer {
88 uint32_t index = -1;
89 uint32_t node_count = 0;
90
92 bool hasFinalized = false;
93
94 // The network stack uses timestamp in seconds, so we oblige.
95 std::chrono::seconds registration_time;
96 std::chrono::seconds nextPossibleConflictTime;
97
102 static constexpr auto DANGLING_TIMEOUT = 15min;
103
104 Peer(PeerId peerid_, ProofRef proof_,
105 std::chrono::seconds nextPossibleConflictTime_)
106 : peerid(peerid_), proof(std::move(proof_)),
107 registration_time(GetTime<std::chrono::seconds>()),
108 nextPossibleConflictTime(std::move(nextPossibleConflictTime_)) {}
109
110 const ProofId &getProofId() const { return proof->getId(); }
111 uint32_t getScore() const { return proof->getScore(); }
112};
113
116 result_type operator()(const Peer &p) const { return p.proof->getId(); }
117};
118
120 using result_type = uint32_t;
121 result_type operator()(const Peer &p) const { return p.getScore(); }
122};
123
125
130
131 PendingNode(ProofId proofid_, NodeId nodeid_, size_t max_elements_)
132 : proofid(proofid_), nodeid(nodeid_), max_elements(max_elements_){};
133};
134
135struct by_proofid;
136struct by_nodeid;
137struct by_score;
138
142 std::chrono::seconds lastUpdate;
144};
145
147 NONE = 0,
149 IMMATURE,
150 INVALID,
152 REJECTED,
154 DANGLING,
156};
157
158class ProofRegistrationState : public ValidationState<ProofRegistrationResult> {
159};
160
161namespace bmi = boost::multi_index;
162
164 std::vector<Slot> slots;
165 uint64_t slotCount = 0;
166 uint64_t fragmentation = 0;
167
172 using PeerSet = boost::multi_index_container<
173 Peer, bmi::indexed_by<
174 // index by peerid
175 bmi::hashed_unique<bmi::member<Peer, PeerId, &Peer::peerid>>,
176 // index by proof
177 bmi::hashed_unique<bmi::tag<by_proofid>, proof_index,
179 // ordered by score, decreasing order
180 bmi::ordered_non_unique<bmi::tag<by_score>, score_index,
181 std::greater<uint32_t>>>>;
182
185
190
193
194 using NodeSet = boost::multi_index_container<
195 Node, bmi::indexed_by<
196 // index by nodeid
197 bmi::hashed_unique<bmi::member<Node, NodeId, &Node::nodeid>>,
198 // sorted by peerid/nextRequestTime
199 bmi::ordered_non_unique<
200 bmi::tag<next_request_time>,
201 bmi::composite_key<
202 Node, bmi::member<Node, PeerId, &Node::peerid>,
203 bmi::member<Node, SteadyMilliseconds,
205
207
212 std::atomic<bool> needMoreNodes{false};
213
214 using PendingNodeSet = boost::multi_index_container<
216 bmi::indexed_by<
217 // index by proofid
218 bmi::hashed_non_unique<
219 bmi::tag<by_proofid>,
220 bmi::member<PendingNode, ProofId, &PendingNode::proofid>,
222 // index by nodeid
223 bmi::hashed_unique<
224 bmi::tag<by_nodeid>,
225 bmi::member<PendingNode, NodeId, &PendingNode::nodeid>>>>;
227
228 static constexpr int SELECT_PEER_MAX_RETRY = 3;
229 static constexpr int SELECT_NODE_MAX_RETRY = 3;
230
235
239 uint32_t totalPeersScore = 0;
241
243
245
246 const bool m_stakingPreConsensus{false};
247
249
250 struct by_lastUpdate;
251
252 using RemoteProofSet = boost::multi_index_container<
254 bmi::indexed_by<
255 // index by proofid/nodeid pair
256 bmi::hashed_unique<
257 bmi::composite_key<
259 bmi::member<RemoteProof, ProofId, &RemoteProof::proofid>,
260 bmi::member<RemoteProof, NodeId, &RemoteProof::nodeid>>,
261 bmi::composite_key_hash<SaltedProofIdHasher,
262 boost::hash<NodeId>>>,
263 // index by proofid
264 bmi::hashed_non_unique<
265 bmi::tag<by_proofid>,
266 bmi::member<RemoteProof, ProofId, &RemoteProof::proofid>,
268 // index by nodeid
269 bmi::hashed_non_unique<
270 bmi::tag<by_nodeid>,
271 bmi::member<RemoteProof, NodeId, &RemoteProof::nodeid>>,
272 bmi::ordered_non_unique<
273 bmi::tag<by_lastUpdate>,
274 bmi::composite_key<
276 bmi::member<RemoteProof, NodeId, &RemoteProof::nodeid>,
277 bmi::member<RemoteProof, std::chrono::seconds,
279
285
299
300 std::unordered_set<ProofId, SaltedProofIdHasher> manualFlakyProofids;
301
303
304public:
305 static constexpr size_t MAX_REMOTE_PROOFS{100};
306
307 PeerManager(const Amount &stakeUtxoDustThresholdIn,
308 ChainstateManager &chainmanIn, bool stakingPreConsensus = false,
309 const ProofRef &localProofIn = ProofRef())
310 : stakeUtxoDustThreshold(stakeUtxoDustThresholdIn),
311 chainman(chainmanIn), m_stakingPreConsensus(stakingPreConsensus),
312 localProof(localProofIn){};
313
317 bool addNode(NodeId nodeid, const ProofId &proofid, size_t max_elements);
318 bool removeNode(NodeId nodeid);
319 size_t getNodeCount() const { return nodes.size(); }
320 size_t getPendingNodeCount() const { return pendingNodes.size(); }
321
322 // Update when a node is to be polled next.
324 uint64_t round);
326 const Response &response);
332 bool latchAvaproofsSent(NodeId nodeid);
333
334 // Randomly select a node to poll.
336
340 bool shouldRequestMoreNodes() { return needMoreNodes.exchange(false); }
341
342 template <typename Callable>
343 bool forNode(NodeId nodeid, Callable &&func) const {
344 auto it = nodes.find(nodeid);
345 return it != nodes.end() && func(*it);
346 }
347
348 template <typename Callable>
349 void forEachNode(const Peer &peer, Callable &&func) const {
350 auto &nview = nodes.get<next_request_time>();
351 auto range = nview.equal_range(peer.peerid);
352 for (auto it = range.first; it != range.second; ++it) {
353 func(*it);
354 }
355 }
356
366 const std::chrono::seconds &nextTime);
367
371 bool setFinalized(PeerId peerid);
372
380 enum class RegistrationMode {
381 DEFAULT,
382 FORCE_ACCEPT,
383 };
384
385 bool registerProof(const ProofRef &proof,
386 ProofRegistrationState &registrationState,
388 bool registerProof(const ProofRef &proof,
391 return registerProof(proof, dummy, mode);
392 }
393
403 enum class RejectionMode {
404 DEFAULT,
405 INVALIDATE,
406 };
407
408 bool rejectProof(const ProofId &proofid,
410
415 bool exists(const ProofId &proofid) const {
416 return getProof(proofid) != nullptr;
417 }
418
420 std::unordered_set<ProofRef, SaltedProofHasher> &registeredProofs);
421
422 template <typename Callable>
423 bool forPeer(const ProofId &proofid, Callable &&func) const {
424 auto &pview = peers.get<by_proofid>();
425 auto it = pview.find(proofid);
426 return it != pview.end() && func(*it);
427 }
428
429 template <typename Callable> void forEachPeer(Callable &&func) const {
430 for (const auto &p : peers) {
431 func(p);
432 }
433 }
434
438 std::unordered_set<ProofRef, SaltedProofHasher> updatedBlockTip();
439
443 void addUnbroadcastProof(const ProofId &proofid);
444 void removeUnbroadcastProof(const ProofId &proofid);
446
447 /*
448 * Quorum management
449 */
450 uint32_t getTotalPeersScore() const { return totalPeersScore; }
451 uint32_t getConnectedPeersScore() const { return connectedPeersScore; }
452
453 bool saveRemoteProof(const ProofId &proofid, const NodeId nodeid,
454 const bool present);
455 std::vector<RemoteProof> getRemoteProofs(const NodeId nodeid) const;
456 bool hasRemoteProofStatus(const ProofId &proofid) const;
457 bool isRemotelyPresentProof(const ProofId &proofid) const;
458
459 bool setFlaky(const ProofId &proofid);
460 bool unsetFlaky(const ProofId &proofid);
461 template <typename Callable> void forEachFlakyProof(Callable &&func) const {
462 for (const auto &p : manualFlakyProofids) {
463 func(p);
464 }
465 }
466
468 void cleanupStakeContenders(const int requestedMinHeight);
469 void addStakeContender(const ProofRef &proof);
470 int getStakeContenderStatus(const StakeContenderId &contenderId,
471 BlockHash &prevblockhashout) const;
472 void acceptStakeContender(const StakeContenderId &contenderId);
474 const StakeContenderId &contenderId, BlockHash &prevblockhash,
475 std::vector<std::pair<ProofId, CScript>> &newWinners);
476 void rejectStakeContender(const StakeContenderId &contenderId);
477 void promoteStakeContendersToBlock(const CBlockIndex *pindex);
479 const CBlockIndex *prevblock,
480 const std::vector<std::pair<ProofId, CScript>> winners,
481 size_t maxPollable, std::vector<StakeContenderId> &pollableContenders);
482 bool setStakeContenderWinners(const CBlockIndex *pindex,
483 const std::vector<CScript> &payoutScripts);
484
485 /****************************************************
486 * Functions which are public for testing purposes. *
487 ****************************************************/
488
492 bool removePeer(const PeerId peerid);
493
497 PeerId selectPeer() const;
498
503 uint64_t compact();
504
508 bool verify() const;
509
510 // Accessors.
511 uint64_t getSlotCount() const { return slotCount; }
512 uint64_t getFragmentation() const { return fragmentation; }
513
514 const ProofPool &getValidProofPool() const { return validProofPool; }
517 }
519
520 ProofRef getProof(const ProofId &proofid) const;
521 bool isBoundToPeer(const ProofId &proofid) const;
522 bool isImmature(const ProofId &proofid) const;
523 bool isInConflictingPool(const ProofId &proofid) const;
524 bool isDangling(const ProofId &proofid) const;
525
526 void setInvalid(const ProofId &proofid);
527 bool isInvalid(const ProofId &proofid) const;
528 void clearAllInvalid();
529
531 return shareableProofs;
532 }
533
536 }
537
543 const CBlockIndex *pprev,
544 std::vector<std::pair<ProofId, CScript>> &winners);
545
546 bool dumpPeersToFile(const fs::path &dumpPath) const;
548 const fs::path &dumpPath,
549 std::unordered_set<ProofRef, SaltedProofHasher> &registeredProofs);
550
551private:
552 template <typename ProofContainer>
553 void moveToConflictingPool(const ProofContainer &proofs);
554
555 bool addOrUpdateNode(const PeerSet::iterator &it, NodeId nodeid,
556 size_t max_elements);
557 bool addNodeToPeer(const PeerSet::iterator &it);
558 bool removeNodeFromPeer(const PeerSet::iterator &it, uint32_t count = 1);
559
567 std::optional<bool> getRemotePresenceStatus(const ProofId &proofid) const;
568
569 bool isFlaky(const ProofId &proofid) const;
570
573 }
574
575 friend struct ::avalanche::TestPeerManager;
576};
577
581PeerId selectPeerImpl(const std::vector<Slot> &slots, const uint64_t slot,
582 const uint64_t max);
583
584} // namespace avalanche
585
586#endif // BITCOIN_AVALANCHE_PEERMANAGER_H
uint32_t PeerId
Definition: node.h:15
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:25
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
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:1185
Template for capturing information about block/transaction validation.
Definition: validation.h:89
bool selectStakingRewardWinner(const CBlockIndex *pprev, std::vector< std::pair< ProofId, CScript > > &winners)
Deterministically select a list of payout scripts based on the proof set and the previous block hash.
uint32_t connectedPeersScore
Definition: peermanager.h:240
boost::multi_index_container< PendingNode, bmi::indexed_by< bmi::hashed_non_unique< bmi::tag< by_proofid >, bmi::member< PendingNode, ProofId, &PendingNode::proofid >, SaltedProofIdHasher >, bmi::hashed_unique< bmi::tag< by_nodeid >, bmi::member< PendingNode, NodeId, &PendingNode::nodeid > > > > PendingNodeSet
Definition: peermanager.h:225
std::vector< RemoteProof > getRemoteProofs(const NodeId nodeid) const
bool removeNode(NodeId nodeid)
bool setFinalized(PeerId peerid)
Latch on that this peer has a finalized proof.
bool dumpPeersToFile(const fs::path &dumpPath) const
RemoteProofSet remoteProofs
Remember which node sent which proof so we have an image of the proof set of our peers.
Definition: peermanager.h:284
uint64_t getFragmentation() const
Definition: peermanager.h:512
uint32_t getConnectedPeersScore() const
Definition: peermanager.h:451
bool updateNextRequestTimeForResponse(NodeId nodeid, const Response &response)
bool isDangling(const ProofId &proofid) const
bool addNode(NodeId nodeid, const ProofId &proofid, size_t max_elements)
Node API.
Definition: peermanager.cpp:33
bool unsetFlaky(const ProofId &proofid)
std::optional< bool > getRemotePresenceStatus(const ProofId &proofid) const
Get the presence remote status of a proof.
bool addNodeToPeer(const PeerSet::iterator &it)
Definition: peermanager.cpp:91
bool shouldRequestMoreNodes()
Returns true if we encountered a lack of node since the last call.
Definition: peermanager.h:340
bool exists(const ProofId &proofid) const
Return true if the (valid) proof exists, but only for non-dangling proofs.
Definition: peermanager.h:415
size_t getNodeCount() const
Definition: peermanager.h:319
PendingNodeSet pendingNodes
Definition: peermanager.h:226
const ProofPool & getValidProofPool() const
Definition: peermanager.h:514
bool verify() const
Perform consistency check on internal data structures.
bool forNode(NodeId nodeid, Callable &&func) const
Definition: peermanager.h:343
bool hasRemoteProofStatus(const ProofId &proofid) const
bool forPeer(const ProofId &proofid, Callable &&func) const
Definition: peermanager.h:423
boost::multi_index_container< Node, bmi::indexed_by< bmi::hashed_unique< bmi::member< Node, NodeId, &Node::nodeid > >, bmi::ordered_non_unique< bmi::tag< next_request_time >, bmi::composite_key< Node, bmi::member< Node, PeerId, &Node::peerid >, bmi::member< Node, SteadyMilliseconds, &Node::nextRequestTime > > > > > NodeSet
Definition: peermanager.h:204
uint32_t getTotalPeersScore() const
Definition: peermanager.h:450
void finalizeStakeContender(const StakeContenderId &contenderId, BlockHash &prevblockhash, std::vector< std::pair< ProofId, CScript > > &newWinners)
bool latchAvaproofsSent(NodeId nodeid)
Flag that a node did send its compact proofs.
bool registerProof(const ProofRef &proof, RegistrationMode mode=RegistrationMode::DEFAULT)
Definition: peermanager.h:388
void cleanupStakeContenders(const int requestedMinHeight)
Make some of the contender cache API available.
bool updateNextRequestTimeForPoll(NodeId nodeid, SteadyMilliseconds timeout, uint64_t round)
uint64_t getSlotCount() const
Definition: peermanager.h:511
static constexpr int SELECT_PEER_MAX_RETRY
Definition: peermanager.h:228
ProofIdSet m_unbroadcast_proofids
Track proof ids to broadcast.
Definition: peermanager.h:234
bool loadPeersFromFile(const fs::path &dumpPath, std::unordered_set< ProofRef, SaltedProofHasher > &registeredProofs)
RejectionMode
Rejection mode.
Definition: peermanager.h:403
void addUnbroadcastProof(const ProofId &proofid)
Proof broadcast API.
std::unordered_set< ProofRef, SaltedProofHasher > updatedBlockTip()
Update the peer set when a new block is connected.
void removeUnbroadcastProof(const ProofId &proofid)
PeerManager(const Amount &stakeUtxoDustThresholdIn, ChainstateManager &chainmanIn, bool stakingPreConsensus=false, const ProofRef &localProofIn=ProofRef())
Definition: peermanager.h:307
void promoteStakeContendersToBlock(const CBlockIndex *pindex)
const ProofRadixTree & getShareableProofsSnapshot() const
Definition: peermanager.h:530
bool isBoundToPeer(const ProofId &proofid) const
bool setContenderStatusForLocalWinners(const CBlockIndex *prevblock, const std::vector< std::pair< ProofId, CScript > > winners, size_t maxPollable, std::vector< StakeContenderId > &pollableContenders)
boost::multi_index_container< RemoteProof, bmi::indexed_by< bmi::hashed_unique< bmi::composite_key< RemoteProof, bmi::member< RemoteProof, ProofId, &RemoteProof::proofid >, bmi::member< RemoteProof, NodeId, &RemoteProof::nodeid > >, bmi::composite_key_hash< SaltedProofIdHasher, boost::hash< NodeId > > >, bmi::hashed_non_unique< bmi::tag< by_proofid >, bmi::member< RemoteProof, ProofId, &RemoteProof::proofid >, SaltedProofIdHasher >, bmi::hashed_non_unique< bmi::tag< by_nodeid >, bmi::member< RemoteProof, NodeId, &RemoteProof::nodeid > >, bmi::ordered_non_unique< bmi::tag< by_lastUpdate >, bmi::composite_key< RemoteProof, bmi::member< RemoteProof, NodeId, &RemoteProof::nodeid >, bmi::member< RemoteProof, std::chrono::seconds, &RemoteProof::lastUpdate > > > > > RemoteProofSet
Definition: peermanager.h:278
size_t getPendingNodeCount() const
Definition: peermanager.h:320
const ProofPool & getImmatureProofPool() const
Definition: peermanager.h:518
ProofRadixTree shareableProofs
Definition: peermanager.h:192
bool saveRemoteProof(const ProofId &proofid, const NodeId nodeid, const bool present)
CRollingBloomFilter invalidProofs
Filter for proofs that are consensus-invalid or were recently invalidated by avalanche (finalized rej...
Definition: peermanager.h:298
bool addOrUpdateNode(const PeerSet::iterator &it, NodeId nodeid, size_t max_elements)
Definition: peermanager.cpp:49
uint64_t compact()
Trigger maintenance of internal data structures.
std::vector< Slot > slots
Definition: peermanager.h:164
uint32_t totalPeersScore
Quorum management.
Definition: peermanager.h:239
ProofPool danglingProofPool
Definition: peermanager.h:189
void forEachPeer(Callable &&func) const
Definition: peermanager.h:429
StakeContenderCache stakeContenderCache
Definition: peermanager.h:302
void setInvalid(const ProofId &proofid)
void forEachNode(const Peer &peer, Callable &&func) const
Definition: peermanager.h:349
int getStakeContenderStatus(const StakeContenderId &contenderId, BlockHash &prevblockhashout) const
const Amount & getStakeUtxoDustThreshold() const
Definition: peermanager.h:534
void forEachFlakyProof(Callable &&func) const
Definition: peermanager.h:461
bool isFlaky(const ProofId &proofid) const
ChainstateManager & chainman
Definition: peermanager.h:244
bool isInvalid(const ProofId &proofid) const
std::unordered_set< ProofId, SaltedProofIdHasher > manualFlakyProofids
Definition: peermanager.h:300
bool removePeer(const PeerId peerid)
Remove an existing peer.
const bool m_stakingPreConsensus
Definition: peermanager.h:246
bool isImmature(const ProofId &proofid) const
bool rejectProof(const ProofId &proofid, RejectionMode mode=RejectionMode::DEFAULT)
ProofPool immatureProofPool
Definition: peermanager.h:188
RegistrationMode
Registration mode.
Definition: peermanager.h:380
ProofPool conflictingProofPool
Definition: peermanager.h:187
const ProofPool & getConflictingProofPool() const
Definition: peermanager.h:515
bool isStakingPreconsensusActivated() const
Definition: peermanager.h:571
static constexpr size_t MAX_REMOTE_PROOFS
Definition: peermanager.h:305
bool setFlaky(const ProofId &proofid)
void addStakeContender(const ProofRef &proof)
std::atomic< bool > needMoreNodes
Flag indicating that we failed to select a node and need to expand our node set.
Definition: peermanager.h:212
PeerId selectPeer() const
Randomly select a peer to poll.
boost::multi_index_container< Peer, bmi::indexed_by< bmi::hashed_unique< bmi::member< Peer, PeerId, &Peer::peerid > >, bmi::hashed_unique< bmi::tag< by_proofid >, proof_index, SaltedProofIdHasher >, bmi::ordered_non_unique< bmi::tag< by_score >, score_index, std::greater< uint32_t > > > > PeerSet
Several nodes can make an avalanche peer.
Definition: peermanager.h:181
auto getUnbroadcastProofs() const
Definition: peermanager.h:445
bool isInConflictingPool(const ProofId &proofid) const
bool isRemotelyPresentProof(const ProofId &proofid) const
static constexpr int SELECT_NODE_MAX_RETRY
Definition: peermanager.h:229
void cleanupDanglingProofs(std::unordered_set< ProofRef, SaltedProofHasher > &registeredProofs)
void acceptStakeContender(const StakeContenderId &contenderId)
ProofRef getProof(const ProofId &proofid) const
bool registerProof(const ProofRef &proof, ProofRegistrationState &registrationState, RegistrationMode mode=RegistrationMode::DEFAULT)
void rejectStakeContender(const StakeContenderId &contenderId)
bool removeNodeFromPeer(const PeerSet::iterator &it, uint32_t count=1)
bool updateNextPossibleConflictTime(PeerId peerid, const std::chrono::seconds &nextTime)
Proof and Peer related API.
void moveToConflictingPool(const ProofContainer &proofs)
bool setStakeContenderWinners(const CBlockIndex *pindex, const std::vector< CScript > &payoutScripts)
Map a proof to each utxo.
Definition: proofpool.h:57
Cache to track stake contenders for recent blocks.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:30
int64_t NodeId
Definition: eviction.h:16
ProofRegistrationResult
Definition: peermanager.h:146
static constexpr uint32_t AVALANCHE_MAX_IMMATURE_PROOFS
Maximum number of immature proofs the peer manager will accept from the network.
Definition: peermanager.h:46
std::unordered_set< ProofId, SaltedProofIdHasher > ProofIdSet
Definition: proofpool.h:52
PeerId selectPeerImpl(const std::vector< Slot > &slots, const uint64_t slot, const uint64_t max)
Internal methods that are exposed for testing purposes.
RCUPtr< const Proof > ProofRef
Definition: proof.h:186
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition: rcu.h:259
Response response
Definition: processor.cpp:536
Definition: amount.h:21
A BlockHash is a unqiue identifier for a block.
Definition: blockhash.h:13
SteadyMilliseconds nextRequestTime
Definition: node.h:23
std::chrono::seconds registration_time
Definition: peermanager.h:95
std::chrono::seconds nextPossibleConflictTime
Definition: peermanager.h:96
uint32_t node_count
Definition: peermanager.h:89
static constexpr auto DANGLING_TIMEOUT
Consider dropping the peer if no node is attached after this timeout expired.
Definition: peermanager.h:102
const ProofId & getProofId() const
Definition: peermanager.h:110
uint32_t index
Definition: peermanager.h:88
uint32_t getScore() const
Definition: peermanager.h:111
ProofRef proof
Definition: peermanager.h:91
Peer(PeerId peerid_, ProofRef proof_, std::chrono::seconds nextPossibleConflictTime_)
Definition: peermanager.h:104
PendingNode(ProofId proofid_, NodeId nodeid_, size_t max_elements_)
Definition: peermanager.h:131
std::chrono::seconds lastUpdate
Definition: peermanager.h:142
Slot(uint64_t startIn, uint32_t scoreIn, PeerId peeridIn)
Definition: peermanager.h:61
uint32_t score
Definition: peermanager.h:57
uint64_t start
Definition: peermanager.h:56
Slot withPeerId(PeerId peeridIn) const
Definition: peermanager.h:70
uint32_t getScore() const
Definition: peermanager.h:76
bool follows(uint64_t slot) const
Definition: peermanager.h:83
Slot withScore(uint64_t scoreIn) const
Definition: peermanager.h:67
Slot withStart(uint64_t startIn) const
Definition: peermanager.h:64
uint64_t getStop() const
Definition: peermanager.h:75
uint64_t getStart() const
Definition: peermanager.h:74
PeerId getPeerId() const
Definition: peermanager.h:77
bool precedes(uint64_t slot) const
Definition: peermanager.h:82
bool contains(uint64_t slot) const
Definition: peermanager.h:79
StakeContenderIds are unique for each block to ensure that the peer polling for their acceptance has ...
result_type operator()(const Peer &p) const
Definition: peermanager.h:116
result_type operator()(const Peer &p) const
Definition: peermanager.h:121
static int count
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
Definition: time.cpp:80
std::chrono::time_point< std::chrono::steady_clock, std::chrono::milliseconds > SteadyMilliseconds
Definition: time.h:33