Browse Source

start mining from randon nonce

pull/5/head
orignal 7 years ago
parent
commit
b2efd40551
  1. 20
      src/main.cpp

20
src/main.cpp

@ -4704,10 +4704,13 @@ void static GostcoinMiner(CWallet *pwallet) @@ -4704,10 +4704,13 @@ void static GostcoinMiner(CWallet *pwallet)
CReserveKey reservekey(pwallet);
unsigned int nExtraNonce = 0;
try { loop {
// TODO:
/* while (vNodes.empty())
MilliSleep(1000);*/
try
{
loop
{
while (vNodes.empty())
MilliSleep(1000);
//
// Create new block
@ -4719,6 +4722,7 @@ void static GostcoinMiner(CWallet *pwallet) @@ -4719,6 +4722,7 @@ void static GostcoinMiner(CWallet *pwallet)
if (!pblocktemplate.get())
return;
CBlock *pblock = &pblocktemplate->block;
RAND_bytes ((uint8_t *)&pblock->nNonce, 4);
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
printf("Running GostcoinMiner with %" PRIszu " transactions in block (%u bytes)\n", pblock->vtx.size(),
@ -4780,9 +4784,8 @@ void static GostcoinMiner(CWallet *pwallet) @@ -4780,9 +4784,8 @@ void static GostcoinMiner(CWallet *pwallet)
// Check for stop or if block needs to be rebuilt
boost::this_thread::interruption_point();
// TODO:
/* if (vNodes.empty())
break;*/
if (vNodes.empty())
break;
if (pblock->nNonce >= 0xffff0000)
break;
if (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)
@ -4793,7 +4796,8 @@ void static GostcoinMiner(CWallet *pwallet) @@ -4793,7 +4796,8 @@ void static GostcoinMiner(CWallet *pwallet)
// Update nTime every few seconds
pblock->UpdateTime(pindexPrev);
}
} }
}
}
catch (boost::thread_interrupted)
{
printf("GostcoinMiner terminated\n");

Loading…
Cancel
Save