Merge branch 'getwork_dedupe' into unique_coinbase
This commit is contained in:
commit
b760e25458
2 changed files with 9 additions and 8 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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…
Reference in a new issue