aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2011-06-12 20:16:54 -0400
committerLuke Dashjr <luke-jr+git@utopios.org>2011-06-12 20:17:01 -0400
commit02d87b3aa375810bcd63dcf72637e788a75fc7d4 (patch)
tree2ed3f254ae58f99b476286a54219b70677341a29
parentaa4a9c5250f94c82a9e4077a1b56ba634a9841fa (diff)
Reset extraNonce only when prevBlock changes, so miners can continue updating the time on their work until it's stale
-rw-r--r--main.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/main.cpp b/main.cpp
index bf7c99349d..d71d411644 100644
--- a/main.cpp
+++ b/main.cpp
@@ -3447,12 +3447,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+15)
+ 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();
}