Bitcoin ABC  0.26.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 <coins.h>
13 #include <common/bloom.h>
14 #include <consensus/validation.h>
15 #include <pubkey.h>
16 #include <radix.h>
17 #include <util/hasher.h>
18 #include <util/time.h>
19 
20 #include <boost/multi_index/composite_key.hpp>
21 #include <boost/multi_index/hashed_index.hpp>
22 #include <boost/multi_index/mem_fun.hpp>
23 #include <boost/multi_index/member.hpp>
24 #include <boost/multi_index/ordered_index.hpp>
25 #include <boost/multi_index_container.hpp>
26 
27 #include <atomic>
28 #include <chrono>
29 #include <cstdint>
30 #include <memory>
31 #include <vector>
32 
33 class ChainstateManager;
34 class CScheduler;
35 
36 namespace avalanche {
37 
44 static constexpr uint32_t AVALANCHE_MAX_IMMATURE_PROOFS = 4000;
45 
46 class Delegation;
47 
48 namespace {
49  struct TestPeerManager;
50 }
51 
52 struct Slot {
53 private:
54  uint64_t start;
55  uint32_t score;
57 
58 public:
59  Slot(uint64_t startIn, uint32_t scoreIn, PeerId peeridIn)
60  : start(startIn), score(scoreIn), peerid(peeridIn) {}
61 
62  Slot withStart(uint64_t startIn) const {
63  return Slot(startIn, score, peerid);
64  }
65  Slot withScore(uint64_t scoreIn) const {
66  return Slot(start, scoreIn, peerid);
67  }
68  Slot withPeerId(PeerId peeridIn) const {
69  return Slot(start, score, peeridIn);
70  }
71 
72  uint64_t getStart() const { return start; }
73  uint64_t getStop() const { return start + score; }
74  uint32_t getScore() const { return score; }
75  PeerId getPeerId() const { return peerid; }
76 
77  bool contains(uint64_t slot) const {
78  return getStart() <= slot && slot < getStop();
79  }
80  bool precedes(uint64_t slot) const { return slot >= getStop(); }
81  bool follows(uint64_t slot) const { return getStart() > slot; }
82 };
83 
84 struct Peer {
86  uint32_t index = -1;
87  uint32_t node_count = 0;
88 
90  bool hasFinalized = false;
91 
92  // The network stack uses timestamp in seconds, so we oblige.
93  std::chrono::seconds registration_time;
94  std::chrono::seconds nextPossibleConflictTime;
95 
96  double availabilityScore = 0.0;
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 
114 struct proof_index {
116  result_type operator()(const Peer &p) const { return p.proof->getId(); }
117 };
118 
119 struct score_index {
120  using result_type = uint32_t;
121  result_type operator()(const Peer &p) const { return p.getScore(); }
122 };
123 
125 
126 struct PendingNode {
129 
130  PendingNode(ProofId proofid_, NodeId nodeid_)
131  : proofid(proofid_), nodeid(nodeid_){};
132 };
133 
134 struct by_proofid;
135 struct by_nodeid;
136 struct by_score;
137 
138 struct RemoteProof {
141  std::chrono::seconds lastUpdate;
142  bool present;
143 };
144 
146  NONE = 0,
148  IMMATURE,
149  INVALID,
150  CONFLICTING,
151  REJECTED,
153  DANGLING,
154  MISSING_UTXO,
155 };
156 
157 class ProofRegistrationState : public ValidationState<ProofRegistrationResult> {
158 };
159 
160 namespace bmi = boost::multi_index;
161 
162 class PeerManager {
163  std::vector<Slot> slots;
164  uint64_t slotCount = 0;
165  uint64_t fragmentation = 0;
166 
171  using PeerSet = boost::multi_index_container<
172  Peer, bmi::indexed_by<
173  // index by peerid
174  bmi::hashed_unique<bmi::member<Peer, PeerId, &Peer::peerid>>,
175  // index by proof
176  bmi::hashed_unique<bmi::tag<by_proofid>, proof_index,
178  // ordered by score, decreasing order
179  bmi::ordered_non_unique<bmi::tag<by_score>, score_index,
180  std::greater<uint32_t>>>>;
181 
184 
189 
192 
193  using NodeSet = boost::multi_index_container<
194  Node, bmi::indexed_by<
195  // index by nodeid
196  bmi::hashed_unique<bmi::member<Node, NodeId, &Node::nodeid>>,
197  // sorted by peerid/nextRequestTime
198  bmi::ordered_non_unique<
199  bmi::tag<next_request_time>,
200  bmi::composite_key<
201  Node, bmi::member<Node, PeerId, &Node::peerid>,
202  bmi::member<Node, SteadyMilliseconds,
203  &Node::nextRequestTime>>>>>;
204 
206 
211  std::atomic<bool> needMoreNodes{false};
212 
213  using PendingNodeSet = boost::multi_index_container<
214  PendingNode,
215  bmi::indexed_by<
216  // index by proofid
217  bmi::hashed_non_unique<
218  bmi::tag<by_proofid>,
219  bmi::member<PendingNode, ProofId, &PendingNode::proofid>,
221  // index by nodeid
222  bmi::hashed_unique<
223  bmi::tag<by_nodeid>,
224  bmi::member<PendingNode, NodeId, &PendingNode::nodeid>>>>;
226 
227  static constexpr int SELECT_PEER_MAX_RETRY = 3;
228  static constexpr int SELECT_NODE_MAX_RETRY = 3;
229 
234 
238  uint32_t totalPeersScore = 0;
239  uint32_t connectedPeersScore = 0;
240 
242 
244 
246 
247  struct by_lastUpdate;
248 
249  using RemoteProofSet = boost::multi_index_container<
250  RemoteProof,
251  bmi::indexed_by<
252  // index by proofid/nodeid pair
253  bmi::hashed_unique<
254  bmi::composite_key<
255  RemoteProof,
256  bmi::member<RemoteProof, ProofId, &RemoteProof::proofid>,
257  bmi::member<RemoteProof, NodeId, &RemoteProof::nodeid>>,
258  bmi::composite_key_hash<SaltedProofIdHasher,
259  boost::hash<NodeId>>>,
260  // index by proofid
261  bmi::hashed_non_unique<
262  bmi::tag<by_proofid>,
263  bmi::member<RemoteProof, ProofId, &RemoteProof::proofid>,
265  // index by nodeid
266  bmi::hashed_non_unique<
267  bmi::tag<by_nodeid>,
268  bmi::member<RemoteProof, NodeId, &RemoteProof::nodeid>>,
269  bmi::ordered_non_unique<
270  bmi::tag<by_lastUpdate>,
271  bmi::composite_key<
272  RemoteProof,
273  bmi::member<RemoteProof, NodeId, &RemoteProof::nodeid>,
274  bmi::member<RemoteProof, std::chrono::seconds,
276 
282 
296 
297 public:
298  static constexpr size_t MAX_REMOTE_PROOFS{100};
299 
300  PeerManager(const Amount &stakeUtxoDustThresholdIn,
301  ChainstateManager &chainmanIn,
302  const ProofRef &localProofIn = ProofRef())
303  : stakeUtxoDustThreshold(stakeUtxoDustThresholdIn),
304  chainman(chainmanIn), localProof(localProofIn){};
305 
309  bool addNode(NodeId nodeid, const ProofId &proofid);
310  bool removeNode(NodeId nodeid);
311  size_t getNodeCount() const { return nodes.size(); }
312  size_t getPendingNodeCount() const { return pendingNodes.size(); }
313 
314  // Update when a node is to be polled next.
315  bool updateNextRequestTime(NodeId nodeid, SteadyMilliseconds timeout);
321  bool latchAvaproofsSent(NodeId nodeid);
322 
323  // Randomly select a node to poll.
324  NodeId selectNode();
325 
329  bool shouldRequestMoreNodes() { return needMoreNodes.exchange(false); }
330 
331  template <typename Callable>
332  bool forNode(NodeId nodeid, Callable &&func) const {
333  auto it = nodes.find(nodeid);
334  return it != nodes.end() && func(*it);
335  }
336 
337  template <typename Callable>
338  void forEachNode(const Peer &peer, Callable &&func) const {
339  auto &nview = nodes.get<next_request_time>();
340  auto range = nview.equal_range(peer.peerid);
341  for (auto it = range.first; it != range.second; ++it) {
342  func(*it);
343  }
344  }
345 
355  const std::chrono::seconds &nextTime);
356 
360  bool setFinalized(PeerId peerid);
361 
369  enum class RegistrationMode {
370  DEFAULT,
371  FORCE_ACCEPT,
372  };
373 
374  bool registerProof(const ProofRef &proof,
375  ProofRegistrationState &registrationState,
377  bool registerProof(const ProofRef &proof,
380  return registerProof(proof, dummy, mode);
381  }
382 
392  enum class RejectionMode {
393  DEFAULT,
394  INVALIDATE,
395  };
396 
397  bool rejectProof(const ProofId &proofid,
399 
400  bool exists(const ProofId &proofid) const {
401  return getProof(proofid) != nullptr;
402  }
403 
405  std::unordered_set<ProofRef, SaltedProofHasher> &registeredProofs);
406 
407  template <typename Callable>
408  bool forPeer(const ProofId &proofid, Callable &&func) const {
409  auto &pview = peers.get<by_proofid>();
410  auto it = pview.find(proofid);
411  return it != pview.end() && func(*it);
412  }
413 
414  template <typename Callable> void forEachPeer(Callable &&func) const {
415  for (const auto &p : peers) {
416  func(p);
417  }
418  }
419 
423  std::unordered_set<ProofRef, SaltedProofHasher> updatedBlockTip();
424 
428  void addUnbroadcastProof(const ProofId &proofid);
429  void removeUnbroadcastProof(const ProofId &proofid);
431 
432  /*
433  * Quorum management
434  */
435  uint32_t getTotalPeersScore() const { return totalPeersScore; }
436  uint32_t getConnectedPeersScore() const { return connectedPeersScore; }
437 
438  bool saveRemoteProof(const ProofId &proofid, const NodeId nodeid,
439  const bool present);
440  std::vector<RemoteProof> getRemoteProofs(const NodeId nodeid) const;
441 
442  template <typename Callable>
443  void updateAvailabilityScores(const double decayFactor,
444  Callable &&getNodeAvailabilityScore) {
445  for (auto it = peers.begin(); it != peers.end(); it++) {
446  peers.modify(it, [&](Peer &peer) {
447  // Calculate average of current node scores
448  double peerScore{0.0};
449  forEachNode(peer, [&](const avalanche::Node &node) {
450  peerScore += getNodeAvailabilityScore(node.nodeid);
451  });
452 
453  // Calculate exponential moving average of averaged node scores
454  peer.availabilityScore =
455  decayFactor * peerScore +
456  (1. - decayFactor) * peer.availabilityScore;
457  });
458  }
459  }
460 
461  /****************************************************
462  * Functions which are public for testing purposes. *
463  ****************************************************/
464 
468  bool removePeer(const PeerId peerid);
469 
473  PeerId selectPeer() const;
474 
479  uint64_t compact();
480 
484  bool verify() const;
485 
486  // Accessors.
487  uint64_t getSlotCount() const { return slotCount; }
488  uint64_t getFragmentation() const { return fragmentation; }
489 
490  const ProofPool &getValidProofPool() const { return validProofPool; }
492  return conflictingProofPool;
493  }
495 
496  ProofRef getProof(const ProofId &proofid) const;
497  bool isBoundToPeer(const ProofId &proofid) const;
498  bool isImmature(const ProofId &proofid) const;
499  bool isInConflictingPool(const ProofId &proofid) const;
500  bool isDangling(const ProofId &proofid) const;
501 
502  void setInvalid(const ProofId &proofid);
503  bool isInvalid(const ProofId &proofid) const;
504  void clearAllInvalid();
505 
507  return shareableProofs;
508  }
509 
511  return stakeUtxoDustThreshold;
512  }
513 
518  bool selectStakingRewardWinner(const CBlockIndex *pprev,
519  std::vector<CScript> &winners);
520 
521  bool dumpPeersToFile(const fs::path &dumpPath) const;
522  bool loadPeersFromFile(
523  const fs::path &dumpPath,
524  std::unordered_set<ProofRef, SaltedProofHasher> &registeredProofs);
525 
526 private:
527  template <typename ProofContainer>
528  void moveToConflictingPool(const ProofContainer &proofs);
529 
530  bool addOrUpdateNode(const PeerSet::iterator &it, NodeId nodeid);
531  bool addNodeToPeer(const PeerSet::iterator &it);
532  bool removeNodeFromPeer(const PeerSet::iterator &it, uint32_t count = 1);
533 
541  std::optional<bool> getRemotePresenceStatus(const ProofId &proofid) const;
542 
543  bool isFlaky(const ProofId &proofid) const;
544 
545  friend struct ::avalanche::TestPeerManager;
546 };
547 
551 PeerId selectPeerImpl(const std::vector<Slot> &slots, const uint64_t slot,
552  const uint64_t max);
553 
554 } // namespace avalanche
555 
556 #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:1146
Template for capturing information about block/transaction validation.
Definition: validation.h:82
uint32_t connectedPeersScore
Definition: peermanager.h:239
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:224
std::vector< RemoteProof > getRemoteProofs(const NodeId nodeid) const
bool removeNode(NodeId nodeid)
bool selectStakingRewardWinner(const CBlockIndex *pprev, std::vector< CScript > &winners)
Deterministically select a list of payout scripts based on the proof set and the previous block hash.
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:281
uint64_t getFragmentation() const
Definition: peermanager.h:488
uint32_t getConnectedPeersScore() const
Definition: peermanager.h:436
bool isDangling(const ProofId &proofid) const
bool updateNextRequestTime(NodeId nodeid, SteadyMilliseconds timeout)
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:87
bool shouldRequestMoreNodes()
Returns true if we encountered a lack of node since the last call.
Definition: peermanager.h:329
bool exists(const ProofId &proofid) const
Definition: peermanager.h:400
size_t getNodeCount() const
Definition: peermanager.h:311
PendingNodeSet pendingNodes
Definition: peermanager.h:225
bool verify() const
Perform consistency check on internal data structures.
bool forNode(NodeId nodeid, Callable &&func) const
Definition: peermanager.h:332
bool forPeer(const ProofId &proofid, Callable &&func) const
Definition: peermanager.h:408
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:203
uint32_t getTotalPeersScore() const
Definition: peermanager.h:435
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:377
bool addNode(NodeId nodeid, const ProofId &proofid)
Node API.
Definition: peermanager.cpp:31
uint64_t getSlotCount() const
Definition: peermanager.h:487
static constexpr int SELECT_PEER_MAX_RETRY
Definition: peermanager.h:227
ProofIdSet m_unbroadcast_proofids
Track proof ids to broadcast.
Definition: peermanager.h:233
bool loadPeersFromFile(const fs::path &dumpPath, std::unordered_set< ProofRef, SaltedProofHasher > &registeredProofs)
RejectionMode
Rejection mode.
Definition: peermanager.h:392
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)
bool isBoundToPeer(const ProofId &proofid) const
const ProofPool & getConflictingProofPool() const
Definition: peermanager.h:491
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:275
size_t getPendingNodeCount() const
Definition: peermanager.h:312
ProofRadixTree shareableProofs
Definition: peermanager.h:191
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:295
uint64_t compact()
Trigger maintenance of internal data structures.
PeerManager(const Amount &stakeUtxoDustThresholdIn, ChainstateManager &chainmanIn, const ProofRef &localProofIn=ProofRef())
Definition: peermanager.h:300
std::vector< Slot > slots
Definition: peermanager.h:163
uint32_t totalPeersScore
Quorum management.
Definition: peermanager.h:238
ProofPool danglingProofPool
Definition: peermanager.h:188
void forEachPeer(Callable &&func) const
Definition: peermanager.h:414
const ProofPool & getValidProofPool() const
Definition: peermanager.h:490
void setInvalid(const ProofId &proofid)
void forEachNode(const Peer &peer, Callable &&func) const
Definition: peermanager.h:338
const Amount & getStakeUtxoDustThreshold() const
Definition: peermanager.h:510
bool isFlaky(const ProofId &proofid) const
ChainstateManager & chainman
Definition: peermanager.h:243
bool isInvalid(const ProofId &proofid) const
bool removePeer(const PeerId peerid)
Remove an existing peer.
const ProofPool & getImmatureProofPool() const
Definition: peermanager.h:494
bool isImmature(const ProofId &proofid) const
bool addOrUpdateNode(const PeerSet::iterator &it, NodeId nodeid)
Definition: peermanager.cpp:46
bool rejectProof(const ProofId &proofid, RejectionMode mode=RejectionMode::DEFAULT)
ProofPool immatureProofPool
Definition: peermanager.h:187
RegistrationMode
Registration mode.
Definition: peermanager.h:369
ProofPool conflictingProofPool
Definition: peermanager.h:186
static constexpr size_t MAX_REMOTE_PROOFS
Definition: peermanager.h:298
std::atomic< bool > needMoreNodes
Flag indicating that we failed to select a node and need to expand our node set.
Definition: peermanager.h:211
PeerId selectPeer() const
Randomly select a peer to poll.
const ProofRadixTree & getShareableProofsSnapshot() const
Definition: peermanager.h:506
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:180
void updateAvailabilityScores(const double decayFactor, Callable &&getNodeAvailabilityScore)
Definition: peermanager.h:443
auto getUnbroadcastProofs() const
Definition: peermanager.h:430
bool isInConflictingPool(const ProofId &proofid) const
static constexpr int SELECT_NODE_MAX_RETRY
Definition: peermanager.h:228
void cleanupDanglingProofs(std::unordered_set< ProofRef, SaltedProofHasher > &registeredProofs)
ProofRef getProof(const ProofId &proofid) const
bool registerProof(const ProofRef &proof, ProofRegistrationState &registrationState, RegistrationMode mode=RegistrationMode::DEFAULT)
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)
Map a proof to each utxo.
Definition: proofpool.h:57
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:30
ProofRegistrationResult
Definition: peermanager.h:145
static constexpr uint32_t AVALANCHE_MAX_IMMATURE_PROOFS
Maximum number of immature proofs the peer manager will accept from the network.
Definition: peermanager.h:44
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:185
Definition: init.h:28
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition: rcu.h:257
int64_t NodeId
Definition: nodeid.h:10
Definition: amount.h:19
SteadyMilliseconds nextRequestTime
Definition: node.h:23
std::chrono::seconds registration_time
Definition: peermanager.h:93
std::chrono::seconds nextPossibleConflictTime
Definition: peermanager.h:94
uint32_t node_count
Definition: peermanager.h:87
double availabilityScore
Definition: peermanager.h:96
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:86
uint32_t getScore() const
Definition: peermanager.h:111
ProofRef proof
Definition: peermanager.h:89
Peer(PeerId peerid_, ProofRef proof_, std::chrono::seconds nextPossibleConflictTime_)
Definition: peermanager.h:104
PendingNode(ProofId proofid_, NodeId nodeid_)
Definition: peermanager.h:130
std::chrono::seconds lastUpdate
Definition: peermanager.h:141
Slot(uint64_t startIn, uint32_t scoreIn, PeerId peeridIn)
Definition: peermanager.h:59
uint32_t score
Definition: peermanager.h:55
uint64_t start
Definition: peermanager.h:54
Slot withPeerId(PeerId peeridIn) const
Definition: peermanager.h:68
uint32_t getScore() const
Definition: peermanager.h:74
bool follows(uint64_t slot) const
Definition: peermanager.h:81
Slot withScore(uint64_t scoreIn) const
Definition: peermanager.h:65
Slot withStart(uint64_t startIn) const
Definition: peermanager.h:62
uint64_t getStop() const
Definition: peermanager.h:73
uint64_t getStart() const
Definition: peermanager.h:72
PeerId getPeerId() const
Definition: peermanager.h:75
bool precedes(uint64_t slot) const
Definition: peermanager.h:80
bool contains(uint64_t slot) const
Definition: peermanager.h:77
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
Definition: tests.c:31
int64_t GetTime()
Definition: time.cpp:109
std::chrono::time_point< std::chrono::steady_clock, std::chrono::milliseconds > SteadyMilliseconds
Definition: time.h:31