Bitcoin ABC 0.30.9
P2P Digital Currency
rewardrankcomparator.h
Go to the documentation of this file.
1// Copyright (c) 2025 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_REWARDRANKCOMPARATOR_H
6#define BITCOIN_AVALANCHE_REWARDRANKCOMPARATOR_H
7
8#include <avalanche/proofid.h>
10
11namespace avalanche {
12
14 bool operator()(const StakeContenderId &leftContenderId, double leftRank,
15 const ProofId &leftProofId,
16 const StakeContenderId &rightContenderId, double rightRank,
17 const ProofId &rightProofId) const {
18 if (leftRank != rightRank) {
19 // Lowest rank is best
20 return leftRank < rightRank;
21 }
22
23 // If there's a collision in rank, sort by contender id
24 if (leftContenderId != rightContenderId) {
25 return leftContenderId < rightContenderId;
26 }
27
28 // If there's a collision in contender id, sort by proof id
29 return leftProofId < rightProofId;
30 }
31};
32
33} // namespace avalanche
34
35#endif // BITCOIN_AVALANCHE_REWARDRANKCOMPARATOR_H
bool operator()(const StakeContenderId &leftContenderId, double leftRank, const ProofId &leftProofId, const StakeContenderId &rightContenderId, double rightRank, const ProofId &rightProofId) const
StakeContenderIds are unique for each block to ensure that the peer polling for their acceptance has ...