aboutsummaryrefslogtreecommitdiff
path: root/src/rpcmining.cpp
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2015-07-09 22:06:41 +0100
committerRoss Nicoll <[email protected]>2015-07-19 16:42:22 +0000
commit949b1ccd88ff13c74a3c1a7b9faa7f36c1085904 (patch)
tree378278514e847511b46e5f8d67fd6e3a61e80fe7 /src/rpcmining.cpp
parentMerge pull request #1200 from rnicoll/1.10-auxpow-clean (diff)
downloaddiscoin-949b1ccd88ff13c74a3c1a7b9faa7f36c1085904.tar.xz
discoin-949b1ccd88ff13c74a3c1a7b9faa7f36c1085904.zip
Modify chain consensus parameters to be height aware
Diffstat (limited to 'src/rpcmining.cpp')
-rw-r--r--src/rpcmining.cpp14
1 files changed, 3 insertions, 11 deletions
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