33 if (!rttWork.has_value()) {
42 "Block %s at height %d violates the real time target %08x (%s "
43 "> %s, time diff %ds)\n",
78static constexpr double RTT_K{6.};
82 std::pow(600.,
RTT_K - 1.);
85 std::pow(2400.,
RTT_K - 1.);
88 std::pow(6000.,
RTT_K - 1.);
91 std::pow(9600.,
RTT_K - 1.);
101std::optional<uint32_t>
107 std::vector<int64_t> prevHeaderReceivedTime(18, 0);
108 for (
size_t i = 1; i < 18; i++) {
109 if (!previousIndex) {
114 if (prevHeaderReceivedTime[i] == 0) {
120 previousIndex = previousIndex->
pprev;
127 const double prevTargetDouble = prevTarget.
getdouble();
130 for (
size_t i : {2, 5, 11, 17}) {
132 const int64_t diffTime =
133 std::max<int64_t>(1, now - prevHeaderReceivedTime[i]);
136 std::pow(
double(diffTime),
RTT_K - 1.);
138 minTarget = std::min(minTarget, target);
142 if (minTarget < 1. ||
bool IsAugustoEnabled(const Consensus::Params ¶ms, int64_t nMedianTimePast)
Check if May 15th, 2024 protocol upgrade has activated.
arith_uint256 UintToArith256(const uint256 &a)
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
int64_t GetHeaderReceivedTime() const
BlockHash GetBlockHash() const
int nHeight
height of the entry in the chain. The genesis block has height 0
const Consensus::Params & m_consensusParams
bool operator()(BlockPolicyValidationState &state) override
const CBlockIndex & m_blockIndex
bool Invalid(Result result, const std::string &reject_reason="", const std::string &debug_message="")
256-bit unsigned big integer.
uint32_t GetCompact(bool fNegative=false) const
static arith_uint256 fromDouble(double d)
std::string ToString() const
std::string ToString() const
@ POLICY_VIOLATION
A block policy rule was violated. This block should be parked.
bool CheckProofOfWork(const BlockHash &hash, uint32_t nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
bool NBitsToTarget(const Consensus::Params ¶ms, uint32_t nBits, arith_uint256 &target)
Convert a header bits difficulty representation to a 256 bits hash target.
static const double RTT_CONSTANT_FACTOR_5
static const std::vector< double > RTT_CONSTANT_FACTOR
std::optional< uint32_t > GetNextRTTWorkRequired(const CBlockIndex *pprev, int64_t now, const Consensus::Params &consensusParams)
Compute the real time block hash target given the previous block parameters.
static const double RTT_CONSTANT_FACTOR_11
bool isRTTEnabled(const Consensus::Params ¶ms, const CBlockIndex *pprev)
Whether the RTT feature is enabled.
static const double RTT_CONSTANT_FACTOR_17
static const double RTT_CONSTANT_FACTOR_2
static constexpr double RTT_K
target(t) = target(prev_block) * RTT_CONSTANT_FACTOR * t^(RTT_K - 1) Where t is the time since the pr...
static constexpr bool DEFAULT_ENABLE_RTT
Default for -enablertt.
Parameters that influence chain consensus.
uint256 powLimit
Proof of work parameters.