aboutsummaryrefslogtreecommitdiff
path: root/src/dogecoin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dogecoin.cpp')
-rw-r--r--src/dogecoin.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/dogecoin.cpp b/src/dogecoin.cpp
index e946acad6..dd394d5b4 100644
--- a/src/dogecoin.cpp
+++ b/src/dogecoin.cpp
@@ -21,9 +21,9 @@ unsigned int CalculateDogecoinNextWorkRequired(const CBlockIndex* pindexLast, in
int nHeight = pindexLast->nHeight + 1;
bool fNewDifficultyProtocol = (nHeight >= 145000);
// bool fNewDifficultyProtocol = (nHeight >= params.GetDigiShieldForkBlock());
- const int64_t retargetTimespan = fNewDifficultyProtocol
- ? 60 // params.DigiShieldTargetTimespan()
- : params.nPowTargetTimespan;
+ const int64_t retargetTimespan = fNewDifficultyProtocol ? 60 // params.DigiShieldTargetTimespan()
+ :
+ params.nPowTargetTimespan;
const int64_t nActualTimespan = pindexLast->GetBlockTime() - nFirstBlockTime;
int64_t nModulatedTimespan = nActualTimespan;
@@ -75,6 +75,51 @@ unsigned int CalculateDogecoinNextWorkRequired(const CBlockIndex* pindexLast, in
return bnNew.GetCompact();
}
+bool CheckAuxPowProofOfWork(const CBlockHeader& block, const Consensus::Params& params)
+{
+ /* Except for legacy blocks with full version 1, ensure that
+ the chain ID is correct. Legacy blocks are not allowed since
+ the merge-mining start, which is checked in AcceptBlockHeader
+ where the height is known. */
+ if (!block.nVersion.IsLegacy() && params.fStrictChainId && block.nVersion.GetChainId() != params.nAuxpowChainId)
+ return error("%s : block does not have our chain ID"
+ " (got %d, expected %d, full nVersion %d)",
+ __func__,
+ block.nVersion.GetChainId(),
+ params.nAuxpowChainId,
+ block.nVersion.GetFullVersion());
+
+ /* If there is no auxpow, just check the block hash. */
+ if (!block.auxpow) {
+ if (block.nVersion.IsAuxpow())
+ return error("%s : no auxpow on block with auxpow version",
+ __func__);
+
+ if (!CheckProofOfWork(block.GetPoWHash(), block.nBits, params))
+ return error("%s : non-AUX proof of work failed", __func__);
+
+ return true;
+ }
+
+ /* We have auxpow. Check it. */
+
+ if (!block.nVersion.IsAuxpow())
+ return error("%s : auxpow on block with non-auxpow version", __func__);
+
+ /* Temporary check: Disallow parent blocks with auxpow version. This is
+ for compatibility with the old client. */
+ /* FIXME: Remove this check with a hardfork later on. */
+ if (block.auxpow->getParentBlock().nVersion.IsAuxpow())
+ return error("%s : auxpow parent block has auxpow version", __func__);
+
+ if (!block.auxpow->check(block.GetHash(), block.nVersion.GetChainId(), params))
+ return error("%s : AUX POW is not valid", __func__);
+ if (!CheckProofOfWork(block.auxpow->getParentBlockPoWHash(), block.nBits, params))
+ return error("%s : AUX proof of work failed", __func__);
+
+ return true;
+}
+
CAmount GetDogecoinBlockSubsidy(int nHeight, const Consensus::Params& consensusParams, uint256 prevHash)
{
int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;