aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2011-09-07 10:51:57 -0400
committerGavin Andresen <gavinandresen@gmail.com>2011-09-07 10:51:57 -0400
commit5a3dea451d8a53ec87cbd7a7d1405a970fb1b263 (patch)
tree84a47b03eb615c8d8a4c3df2f7d0dbb0ad698dc0 /src/main.cpp
parentf92f022edaa2f14951b9ce8304a304ff9693ae16 (diff)
parent83f4cd156e9d52bd7c4351336dfa4806a43ee4e4 (diff)
Merge branch 'unique_coinbase' of git://gitorious.org/~Luke-Jr/bitcoin/luke-jr-bitcoin into unique_coinbase
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 dce26d3599..5b159fe415 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2798,16 +2798,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();
}
@@ -2905,7 +2906,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)
{
@@ -2932,7 +2932,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());