Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proofcomparator.h
Show All 9 Lines | |||||
#include <cstdint> | #include <cstdint> | ||||
#include <memory> | #include <memory> | ||||
namespace avalanche { | namespace avalanche { | ||||
/** | /** | ||||
* Compare proofs by score, then by id in case of equality. | * Compare proofs by score, then by id in case of equality. | ||||
*/ | */ | ||||
struct ProofComparator { | struct ProofComparatorByScore { | ||||
bool operator()(const Proof &lhs, const Proof &rhs) const { | bool operator()(const Proof &lhs, const Proof &rhs) const { | ||||
uint32_t scoreLhs = lhs.getScore(); | uint32_t scoreLhs = lhs.getScore(); | ||||
uint32_t scoreRhs = rhs.getScore(); | uint32_t scoreRhs = rhs.getScore(); | ||||
return (scoreLhs != scoreRhs) ? scoreLhs > scoreRhs | return (scoreLhs != scoreRhs) ? scoreLhs > scoreRhs | ||||
: lhs.getId() < rhs.getId(); | : lhs.getId() < rhs.getId(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |