Merge branch 'getwork_dedupe' into unique_coinbase

This commit is contained in:
Luke Dashjr 2011-09-06 16:43:32 -04:00
commit b760e25458
2 changed files with 9 additions and 8 deletions

View File

@ -2797,12 +2797,13 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce, int64& nPrevTime) void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce, int64& nPrevTime)
{ {
// Update nExtraNonce // Update nExtraNonce
int64 nNow = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); static uint256 hashPrevBlock;
if (++nExtraNonce >= 0x7f && nNow > nPrevTime+1) if (hashPrevBlock != pblock->hashPrevBlock)
{ {
nExtraNonce = 1; nExtraNonce = 0;
nPrevTime = nNow; hashPrevBlock = pblock->hashPrevBlock;
} }
++nExtraNonce;
pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce); pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce);
pblock->hashMerkleRoot = pblock->BuildMerkleTree(); pblock->hashMerkleRoot = pblock->BuildMerkleTree();
} }

View File

@ -1614,15 +1614,15 @@ Value getwork(const Array& params, bool fHelp)
vNewBlock.push_back(pblock); vNewBlock.push_back(pblock);
} }
// Update nTime
pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
pblock->nNonce = 0;
// Update nExtraNonce // Update nExtraNonce
static unsigned int nExtraNonce = 0; static unsigned int nExtraNonce = 0;
static int64 nPrevTime = 0; static int64 nPrevTime = 0;
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce, nPrevTime); IncrementExtraNonce(pblock, pindexPrev, nExtraNonce, nPrevTime);
// Update nTime
pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
pblock->nNonce = 0;
// Save // Save
mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, nExtraNonce); mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, nExtraNonce);