Browse Source

Reset extraNonce only when prevBlock changes, so miners can continue updating the time on their work until it's stale

0.8
Luke Dashjr 13 years ago
parent
commit
02d87b3aa3
  1. 9
      main.cpp

9
main.cpp

@ -3447,12 +3447,13 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) @@ -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();
}

Loading…
Cancel
Save