Skip to content

Commit

Permalink
Simplify and rename CheckWork to ProcessBlockFound
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimon committed Jul 30, 2014
1 parent b45e782 commit f0c2915
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
return CreateNewBlock(scriptPubKey);
}

bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
{
uint256 hash = pblock->GetHash();
uint256 hashTarget = uint256().SetCompact(pblock->nBits);

if (hash > hashTarget)
return false;

//// debug print
LogPrintf("BitcoinMiner:\n");
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex(), hashTarget.GetHex());
pblock->print();
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue));

Expand Down Expand Up @@ -500,7 +491,9 @@ void static BitcoinMiner(CWallet *pwallet)
assert(hash == pblock->GetHash());

SetThreadPriority(THREAD_PRIORITY_NORMAL);
CheckWork(pblock, *pwallet, reservekey);
LogPrintf("BitcoinMiner:\n");
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex(), hashTarget.GetHex());
ProcessBlockFound(pblock, *pwallet, reservekey);
SetThreadPriority(THREAD_PRIORITY_LOWEST);

// In regression test mode, stop mining after a block is found.
Expand Down

0 comments on commit f0c2915

Please sign in to comment.