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

8
src/rpc.cpp

@ -1614,15 +1614,15 @@ Value getwork(const Array& params, bool fHelp) @@ -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);

Loading…
Cancel
Save