Bugfix: Use timestamp in coinbase rather than "bits", needed to ensure coinbase txn is unique even if address is the same
This commit is contained in:
parent
49c8e53ee2
commit
83f4cd156e
3 changed files with 8 additions and 10 deletions
|
@ -2794,7 +2794,7 @@ 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
|
// Update nExtraNonce
|
||||||
static uint256 hashPrevBlock;
|
static uint256 hashPrevBlock;
|
||||||
|
@ -2804,7 +2804,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
|
||||||
hashPrevBlock = pblock->hashPrevBlock;
|
hashPrevBlock = pblock->hashPrevBlock;
|
||||||
}
|
}
|
||||||
++nExtraNonce;
|
++nExtraNonce;
|
||||||
pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce);
|
pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nTime << CBigNum(nExtraNonce);
|
||||||
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
|
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2902,7 +2902,6 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||||
// Each thread has its own key and counter
|
// Each thread has its own key and counter
|
||||||
CReserveKey reservekey(pwallet);
|
CReserveKey reservekey(pwallet);
|
||||||
unsigned int nExtraNonce = 0;
|
unsigned int nExtraNonce = 0;
|
||||||
int64 nPrevTime = 0;
|
|
||||||
|
|
||||||
while (fGenerateBitcoins)
|
while (fGenerateBitcoins)
|
||||||
{
|
{
|
||||||
|
@ -2929,7 +2928,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||||
auto_ptr<CBlock> pblock(CreateNewBlock(reservekey));
|
auto_ptr<CBlock> pblock(CreateNewBlock(reservekey));
|
||||||
if (!pblock.get())
|
if (!pblock.get())
|
||||||
return;
|
return;
|
||||||
IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce, nPrevTime);
|
IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce);
|
||||||
|
|
||||||
printf("Running BitcoinMiner with %d transactions in block\n", pblock->vtx.size());
|
printf("Running BitcoinMiner with %d transactions in block\n", pblock->vtx.size());
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ bool ProcessMessages(CNode* pfrom);
|
||||||
bool SendMessages(CNode* pto, bool fSendTrickle);
|
bool SendMessages(CNode* pto, bool fSendTrickle);
|
||||||
void GenerateBitcoins(bool fGenerate, CWallet* pwallet);
|
void GenerateBitcoins(bool fGenerate, CWallet* pwallet);
|
||||||
CBlock* CreateNewBlock(CReserveKey& reservekey);
|
CBlock* CreateNewBlock(CReserveKey& reservekey);
|
||||||
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce, int64& nPrevTime);
|
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce);
|
||||||
void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1);
|
void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1);
|
||||||
bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
|
bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
|
||||||
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
|
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
|
||||||
|
|
|
@ -1615,15 +1615,14 @@ Value getwork(const Array& params, bool fHelp)
|
||||||
vNewBlock.push_back(pblock);
|
vNewBlock.push_back(pblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update nExtraNonce
|
|
||||||
static unsigned int nExtraNonce = 0;
|
|
||||||
static int64 nPrevTime = 0;
|
|
||||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce, nPrevTime);
|
|
||||||
|
|
||||||
// Update nTime
|
// Update nTime
|
||||||
pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
||||||
pblock->nNonce = 0;
|
pblock->nNonce = 0;
|
||||||
|
|
||||||
|
// Update nExtraNonce
|
||||||
|
static unsigned int nExtraNonce = 0;
|
||||||
|
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig);
|
mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue