aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-09-16 06:55:47 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-09-16 06:55:47 +0200
commit5dd7318db75db580d602c72a2322df97d8712233 (patch)
treee15a3c55d610d8c9e26ac2224d746e8b36a0450a /src/main.cpp
parentc1e667222ad7eac6403cd60aab4d5d09ed0ff02d (diff)
parent217208a36d210e7d51e405d0e531ac2b75a3a087 (diff)
Merge branch 'master' of https://github.com/bitcoin/bitcoin
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4d5cb87b07..fc520df8ec 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2809,16 +2809,17 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
}
-void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce, int64& nPrevTime)
+void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
{
// 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;
}
- pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce);
+ ++nExtraNonce;
+ pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nTime << CBigNum(nExtraNonce);
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
}
@@ -2916,7 +2917,6 @@ void static BitcoinMiner(CWallet *pwallet)
// Each thread has its own key and counter
CReserveKey reservekey(pwallet);
unsigned int nExtraNonce = 0;
- int64 nPrevTime = 0;
while (fGenerateBitcoins)
{
@@ -2943,7 +2943,7 @@ void static BitcoinMiner(CWallet *pwallet)
auto_ptr<CBlock> pblock(CreateNewBlock(reservekey));
if (!pblock.get())
return;
- IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce, nPrevTime);
+ IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce);
printf("Running BitcoinMiner with %d transactions in block\n", pblock->vtx.size());