Browse Source

Merge branch 'getwork_dedupe' into unique_coinbase

0.8
Luke Dashjr 13 years ago
parent
commit
b760e25458
  1. 9
      src/main.cpp
  2. 8
      src/rpc.cpp

9
src/main.cpp

@ -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();
} }

8
src/rpc.cpp

@ -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);

Loading…
Cancel
Save