Changeset View
Changeset View
Standalone View
Standalone View
src/pow/pow.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// 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/pow.h> | #include <pow/pow.h> | ||||
#include <arith_uint256.h> | #include <arith_uint256.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <consensus/activation.h> | #include <consensus/activation.h> | ||||
#include <consensus/params.h> | #include <consensus/params.h> | ||||
#include <pow/aserti32d.h> | |||||
#include <pow/daa.h> | #include <pow/daa.h> | ||||
#include <pow/eda.h> | #include <pow/eda.h> | ||||
#include <primitives/blockhash.h> | #include <primitives/blockhash.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
uint32_t GetNextWorkRequired(const CBlockIndex *pindexPrev, | uint32_t GetNextWorkRequired(const CBlockIndex *pindexPrev, | ||||
const CBlockHeader *pblock, | const CBlockHeader *pblock, | ||||
const CChainParams &chainParams) { | const CChainParams &chainParams) { | ||||
// GetNextWorkRequired should never be called on the genesis block | // GetNextWorkRequired should never be called on the genesis block | ||||
assert(pindexPrev != nullptr); | assert(pindexPrev != nullptr); | ||||
const Consensus::Params ¶ms = chainParams.GetConsensus(); | const Consensus::Params ¶ms = chainParams.GetConsensus(); | ||||
// Special rule for regtest: we never retarget. | // Special rule for regtest: we never retarget. | ||||
if (params.fPowNoRetargeting) { | if (params.fPowNoRetargeting) { | ||||
return pindexPrev->nBits; | return pindexPrev->nBits; | ||||
} | } | ||||
if (IsAxionEnabled(params, pindexPrev)) { | |||||
return GetNextASERTWorkRequired(pindexPrev, pblock, params); | |||||
} | |||||
if (IsDAAEnabled(params, pindexPrev)) { | if (IsDAAEnabled(params, pindexPrev)) { | ||||
return GetNextDAAWorkRequired(pindexPrev, pblock, params); | return GetNextDAAWorkRequired(pindexPrev, pblock, params); | ||||
} | } | ||||
return GetNextEDAWorkRequired(pindexPrev, pblock, params); | return GetNextEDAWorkRequired(pindexPrev, pblock, params); | ||||
} | } | ||||
bool CheckProofOfWork(const BlockHash &hash, uint32_t nBits, | bool CheckProofOfWork(const BlockHash &hash, uint32_t nBits, | ||||
Show All 20 Lines |