aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp9
-rw-r--r--src/rpc.cpp8
2 files changed, 9 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f483312065..480d2d8bbf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2797,12 +2797,13 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce, int64& nPrevTime)
{
// Update nExtraNonce
- int64 nNow = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
- if (++nExtraNonce >= 0x7f && nNow > nPrevTime+1)
+ static uint256 hashPrevBlock;
+ if (hashPrevBlock != pblock->hashPrevBlock)
{
- nExtraNonce = 1;
- nPrevTime = nNow;
+ nExtraNonce = 0;
+ hashPrevBlock = pblock->hashPrevBlock;
}
+ ++nExtraNonce;
pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce);
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
}
diff --git a/src/rpc.cpp b/src/rpc.cpp
index fdb57b3b83..9e7cfc5b3c 100644
--- a/src/rpc.cpp
+++ b/src/rpc.cpp
@@ -1614,15 +1614,15 @@ Value getwork(const Array& params, bool fHelp)
vNewBlock.push_back(pblock);
}
- // Update nTime
- pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
- pblock->nNonce = 0;
-
// Update nExtraNonce
static unsigned int nExtraNonce = 0;
static int64 nPrevTime = 0;
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce, nPrevTime);
+ // Update nTime
+ pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
+ pblock->nNonce = 0;
+
// Save
mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, nExtraNonce);