Changeset View
Changeset View
Standalone View
Standalone View
src/policy/block/rtt.h
// Copyright (c) 2024 The Bitcoin developers | // Copyright (c) 2024 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_POLICY_BLOCK_RTT_H | #ifndef BITCOIN_POLICY_BLOCK_RTT_H | ||||
#define BITCOIN_POLICY_BLOCK_RTT_H | #define BITCOIN_POLICY_BLOCK_RTT_H | ||||
#include <policy/block/parkingpolicy.h> | |||||
#include <cstdint> | #include <cstdint> | ||||
#include <optional> | #include <optional> | ||||
class arith_uint256; | class arith_uint256; | ||||
class CBlockIndex; | |||||
namespace Consensus { | namespace Consensus { | ||||
struct Params; | struct Params; | ||||
} | } | ||||
/** Default for -enablertt */ | |||||
static constexpr bool DEFAULT_ENABLE_RTT{false}; | |||||
class RTTPolicy : public ParkingPolicy { | |||||
private: | |||||
const Consensus::Params &m_consensusParams; | |||||
const CBlockIndex &m_blockIndex; | |||||
public: | |||||
RTTPolicy(const Consensus::Params &consensusParams, | |||||
const CBlockIndex &blockIndex) | |||||
: m_consensusParams(consensusParams), m_blockIndex(blockIndex) {} | |||||
bool operator()(BlockPolicyValidationState &state) override; | |||||
}; | |||||
/** | /** | ||||
* Compute the real time block hash target given the previous block parameters. | * Compute the real time block hash target given the previous block parameters. | ||||
*/ | */ | ||||
std::optional<arith_uint256> | std::optional<arith_uint256> | ||||
GetNextRTTWorkRequired(uint32_t prevNBits, int64_t prevHeaderReceivedTime, | GetNextRTTWorkRequired(uint32_t prevNBits, int64_t prevHeaderReceivedTime, | ||||
int64_t now, const Consensus::Params &consensusParams); | int64_t now, const Consensus::Params &consensusParams); | ||||
#endif // BITCOIN_POLICY_BLOCK_RTT_H | #endif // BITCOIN_POLICY_BLOCK_RTT_H |