Skip to content

Commit

Permalink
Use CheckStake Function
Browse files Browse the repository at this point in the history
  • Loading branch information
Tranz5 committed May 23, 2014
1 parent 98c1867 commit 66e6c4f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4346,20 +4346,22 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
uint256 hashblock = pblock->GetHash();
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();

if (hashblock > hashTarget && pblock->IsProofOfWork())
return error("BitcoinMiner : proof-of-work not meeting target");
if(!pblock->IsProofOfWork())
return error("CheckWork() : %s is not a proof-of-work block", hashblock.GetHex().c_str());

if (hashblock > hashTarget)
return error("CheckWork() : proof-of-work not meeting target");

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

// Found a solution
{
LOCK(cs_main);
if (pblock->hashPrevBlock != hashBestChain)
return error("BitcoinMiner : generated block is stale");
return error("CheckWork : generated block is stale");

// Remove key from key pool
reservekey.KeepKey();
Expand All @@ -4372,7 +4374,7 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)

// Process this block the same as if we had received it from another node
if (!ProcessBlock(NULL, pblock))
return error("BitcoinMiner : ProcessBlock, block not accepted");
return error("CheckWork : ProcessBlock, block not accepted");
}

return true;
Expand Down Expand Up @@ -4479,7 +4481,7 @@ void BitcoinMiner(CWallet *pwallet, bool fProofOfStake)
strMintWarning = "";
printf("CPUMiner : proof-of-stake block found %s\n", pblock->GetHash().ToString().c_str());
SetThreadPriority(THREAD_PRIORITY_NORMAL);
CheckWork(pblock.get(), *pwalletMain, reservekey);
CheckStake(pblock.get(), *pwalletMain);
SetThreadPriority(THREAD_PRIORITY_LOWEST);
}
Sleep(500);
Expand Down

0 comments on commit 66e6c4f

Please sign in to comment.