aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/mining.cpp
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2017-12-28 15:04:08 +0000
committerRoss Nicoll <[email protected]>2018-09-19 19:24:06 +0100
commit1be681a1b97b686f838af90682a57f2030d26015 (patch)
treeb2795e4a1d35004dbfd84d49b07bc54413a2a9e1 /src/rpc/mining.cpp
parentChange BIP65/66 enforcement to match Dogecoin (#1403) (diff)
downloaddiscoin-1be681a1b97b686f838af90682a57f2030d26015.tar.xz
discoin-1be681a1b97b686f838af90682a57f2030d26015.zip
Modify chain consensus parameters to be height aware (#1396)
* Modify chain consensus parameters to be height aware * Correct implementation of simplified rewards in parameters * Correct max money * Use base block version in IsSuperMajority() instead of full version * Correct mining of blocks in AuxPoW tests * Add in missing pre-AuxPoW consensus checks
Diffstat (limited to 'src/rpc/mining.cpp')
-rw-r--r--src/rpc/mining.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index b355ccdc9..0e2dbe2cb 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -48,7 +48,8 @@ UniValue GetNetworkHashPS(int lookup, int height) {
// If lookup is -1, then use blocks since last difficulty change.
if (lookup <= 0)
- lookup = pb->nHeight % Params().GetConsensus().DifficultyAdjustmentInterval() + 1;
+ lookup = pb->nHeight % Params().GetConsensus(pb->nHeight).DifficultyAdjustmentInterval() + 1;
+ //
// If lookup is larger than chain, then set it to chain length.
if (lookup > pb->nHeight)
@@ -125,7 +126,7 @@ UniValue generateBlocks(boost::shared_ptr<CReserveScript> coinbaseScript, int nG
}
CAuxPow::initAuxPow(*pblock);
CPureBlockHeader& miningHeader = pblock->auxpow->parentBlock;
- while (nMaxTries > 0 && miningHeader.nNonce < nInnerLoopCount && !CheckProofOfWork(miningHeader.GetHash(), pblock->nBits, Params().GetConsensus())) {
+ while (nMaxTries > 0 && miningHeader.nNonce < nInnerLoopCount && !CheckProofOfWork(miningHeader.GetHash(), pblock->nBits, Params().GetConsensus(nHeight))) {
++miningHeader.nNonce;
--nMaxTries;
}
@@ -561,7 +562,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
pindexPrev = pindexPrevNew;
}
CBlock* pblock = &pblocktemplate->block; // pointer for convenience
- const Consensus::Params& consensusParams = Params().GetConsensus();
+ const Consensus::Params& consensusParams = Params().GetConsensus(pindexPrev->nHeight + 1);
// Update nTime
UpdateTime(pblock, consensusParams, pindexPrev);
@@ -778,7 +779,8 @@ UniValue submitblock(const JSONRPCRequest& request)
LOCK(cs_main);
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
if (mi != mapBlockIndex.end()) {
- UpdateUncommittedBlockStructures(block, mi->second, Params().GetConsensus());
+ int nHeight = chainActive.Height() + 1;
+ UpdateUncommittedBlockStructures(block, mi->second, Params().GetConsensus(nHeight));
}
}
@@ -990,7 +992,7 @@ UniValue getauxblock(const JSONRPCRequest& request)
past the point of merge-mining start. Check nevertheless. */
{
LOCK(cs_main);
- if (chainActive.Height() + 1 < Params().GetConsensus().nAuxpowStartHeight)
+ if (Params().GetConsensus(chainActive.Height() + 1).fAllowLegacyBlocks)
throw std::runtime_error("getauxblock method is not yet available");
}