Bitcoin ABC
0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
src
avalanche
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
>
9
#include <
avalanche/stakecontender.h
>
10
11
namespace
avalanche
{
12
13
struct
RewardRankComparator
{
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
avalanche
Definition
avalanche.h:13
proofid.h
GetRand
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition
random.h:85
stakecontender.h
avalanche::ProofId
Definition
proofid.h:17
avalanche::RewardRankComparator
Definition
rewardrankcomparator.h:13
avalanche::RewardRankComparator::operator()
bool operator()(const StakeContenderId &leftContenderId, double leftRank, const ProofId &leftProofId, const StakeContenderId &rightContenderId, double rightRank, const ProofId &rightProofId) const
Definition
rewardrankcomparator.h:14
avalanche::StakeContenderId
StakeContenderIds are unique for each block to ensure that the peer polling for their acceptance has ...
Definition
stakecontender.h:25
Generated on Mon Jan 13 2025 02:38:41 for Bitcoin ABC by
1.9.8