Page MenuHomePhabricator

No OneTemporary

diff --git a/src/avalanche/stakecontender.h b/src/avalanche/stakecontender.h
index 2bdf3ec314..98f25fb0ef 100644
--- a/src/avalanche/stakecontender.h
+++ b/src/avalanche/stakecontender.h
@@ -1,47 +1,47 @@
// Copyright (c) 2024 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_AVALANCHE_STAKECONTENDER_H
#define BITCOIN_AVALANCHE_STAKECONTENDER_H
#include <arith_uint256.h>
#include <hash.h>
#include <uint256.h>
#include <cmath>
struct BlockHash;
namespace avalanche {
struct ProofId;
/**
* StakeContenderIds are unique for each block to ensure that the peer polling
* for their acceptance has strong guarantees that a newly finalizing block does
* not disrupt determining if the previous block had valid stake winners.
*/
struct StakeContenderId : public uint256 {
explicit StakeContenderId() : uint256() {}
explicit StakeContenderId(const uint256 &b) : uint256(b) {}
explicit StakeContenderId(const BlockHash &prevblockhash,
const ProofId &proofid)
: uint256(Hash(prevblockhash, proofid)) {}
/**
* To make sure the selection is properly weighted according to the proof
* score, we normalize the contenderId to a number between 0 and 1, then
* take the logarithm and divide by the weight. Since it is
* scale-independent, we can simplify by removing constants and use base 2
* logarithm. Inspired by: https://stackoverflow.com/a/30226926.
*/
- double ComputeProofRewardRank(uint32_t proofScore) {
+ double ComputeProofRewardRank(uint32_t proofScore) const {
return (256.0 - std::log2(UintToArith256(*this).getdouble())) /
proofScore;
}
};
} // namespace avalanche
#endif // BITCOIN_AVALANCHE_STAKECONTENDER_H

File Metadata

Mime Type
text/x-diff
Expires
Wed, May 21, 18:43 (22 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5865718
Default Alt Text
(1 KB)

Event Timeline