Changeset View
Changeset View
Standalone View
Standalone View
src/pow/eda.cpp
// Copyright (c) 2017-2020 The Bitcoin developers | // Copyright (c) 2017-2020 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. | ||||
#include <pow/eda.h> | #include <pow/eda.h> | ||||
#include <arith_uint256.h> | #include <arith_uint256.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <consensus/params.h> | #include <consensus/params.h> | ||||
/** | /** | ||||
* Do difficulty adjustement Satoshi's way. | * Do difficulty adjustement Satoshi's way. | ||||
*/ | */ | ||||
uint32_t CalculateNextWorkRequired(const CBlockIndex *pindexPrev, | uint32_t CalculateNextWorkRequired(const CBlockIndex *pindexPrev, | ||||
int64_t nFirstBlockTime, | int64_t nFirstBlockTime, | ||||
const Consensus::Params ¶ms) { | const Consensus::Params ¶ms) { | ||||
if (params.fPowNoRetargeting) { | |||||
return pindexPrev->nBits; | |||||
} | |||||
// Limit adjustment step | // Limit adjustment step | ||||
int64_t nActualTimespan = pindexPrev->GetBlockTime() - nFirstBlockTime; | int64_t nActualTimespan = pindexPrev->GetBlockTime() - nFirstBlockTime; | ||||
if (nActualTimespan < params.nPowTargetTimespan / 4) { | if (nActualTimespan < params.nPowTargetTimespan / 4) { | ||||
nActualTimespan = params.nPowTargetTimespan / 4; | nActualTimespan = params.nPowTargetTimespan / 4; | ||||
} | } | ||||
if (nActualTimespan > params.nPowTargetTimespan * 4) { | if (nActualTimespan > params.nPowTargetTimespan * 4) { | ||||
nActualTimespan = params.nPowTargetTimespan * 4; | nActualTimespan = params.nPowTargetTimespan * 4; | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |