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 shared pointers to proof by score, then by id in case of equality. | * Compare shared pointers to proof by score, then by id in case of equality. | ||||
*/ | */ | ||||
struct ProofSharedPointerComparator { | struct ProofRefComparator { | ||||
bool operator()(const std::shared_ptr<Proof> &lhs, | bool operator()(const ProofRef &lhs, const ProofRef &rhs) const { | ||||
const std::shared_ptr<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(); | ||||
} | } | ||||
}; | }; | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_PROOFCOMPARATOR_H | #endif // BITCOIN_AVALANCHE_PROOFCOMPARATOR_H |