From 949b1ccd88ff13c74a3c1a7b9faa7f36c1085904 Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Thu, 9 Jul 2015 22:06:41 +0100 Subject: Modify chain consensus parameters to be height aware --- src/rpcmining.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/rpcmining.cpp') diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 7eee8bb05..e0ba823de 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -47,7 +47,7 @@ Value 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) @@ -159,7 +159,7 @@ Value generate(const Array& params, bool fHelp) LOCK(cs_main); IncrementExtraNonce(pblock, chainActive.Tip(), nExtraNonce); } - while (!CheckProofOfWork(pblock->GetPoWHash(), pblock->nBits, Params().GetConsensus())) { + while (!CheckProofOfWork(pblock->GetPoWHash(), pblock->nBits, Params().GetConsensus(nHeight))) { // Yes, there is a chance every nonce could fail to satisfy the -regtest // target -- 1 in 2^(2^32). That ain't gonna happen. ++pblock->nNonce; @@ -518,7 +518,7 @@ Value getblocktemplate(const Array& params, bool fHelp) CBlock* pblock = &pblocktemplate->block; // pointer for convenience // Update nTime - UpdateTime(pblock, Params().GetConsensus(), pindexPrev); + UpdateTime(pblock, Params().GetConsensus(pindexPrev->nHeight), pindexPrev); pblock->nNonce = 0; static const Array aCaps = boost::assign::list_of("proposal"); @@ -773,14 +773,6 @@ Value getauxblock(const Array& params, bool fHelp) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Namecoin is downloading blocks..."); - /* This should never fail, since the chain is already - past the point of merge-mining start. Check nevertheless. */ - { - LOCK(cs_main); - if (chainActive.Height() + 1 < Params().GetConsensus().nAuxpowStartHeight) - throw std::runtime_error("getauxblock method is not yet available"); - } - /* The variables below are used to keep track of created and not yet submitted auxpow blocks. Lock them, just in case. In principle there's only one RPC thread, so it should be fine without locking -- cgit v1.2.3