Skip to content

Commit

Permalink
Add timing information to StakeMiner
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Dec 17, 2020
1 parent fc5672c commit bc5dd0c
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,13 @@ void StakeMiner(CWallet *pwallet)
//wait for next round
MilliSleep(nMinerSleep);

CBlockIndex* pindexPrev = pindexBest;
bool log_timer = LogInstance().WillLogCategory(BCLog::LogFlags::MINER);

int64_t time_begin;
int64_t time_elapsed;

if (log_timer) time_begin = GetTimeMillis();

CBlock StakeBlock;

{
Expand All @@ -1271,8 +1277,16 @@ void StakeMiner(CWallet *pwallet)
continue;
}

if (log_timer)
{
time_elapsed = GetTimeMillis() - time_begin;
LogPrintf("StakeMiner(): IsMiningAllowed: elapsed %" PRId64 "ms", time_elapsed);
}

LOCK(cs_main);

CBlockIndex* pindexPrev = pindexBest;

// * Create a bare block
StakeBlock.nTime= GetAdjustedTime();
StakeBlock.nNonce= 0;
Expand All @@ -1289,6 +1303,12 @@ void StakeMiner(CWallet *pwallet)
continue;
StakeBlock.nTime= StakeTX.nTime;

if (log_timer)
{
time_elapsed = GetTimeMillis() - time_begin;
LogPrintf("StakeMiner(): CreateCoinStake: elapsed %" PRId64 "ms", time_elapsed);
}

// * create rest of the block. This needs to be moved to after CreateGridcoinReward,
// because stake output splitting needs to be done beforehand for size considerations.
if( !CreateRestOfTheBlock(StakeBlock,pindexPrev) )
Expand All @@ -1301,6 +1321,12 @@ void StakeMiner(CWallet *pwallet)
continue;
}

if (log_timer)
{
time_elapsed = GetTimeMillis() - time_begin;
LogPrintf("StakeMiner(): CreateGridcoinReward: elapsed %" PRId64 "ms", time_elapsed);
}

LogPrintf("StakeMiner: added gridcoin reward to coinstake");

// * If argument is supplied desiring stake output splitting or side staking, then call SplitCoinStakeOutput.
Expand All @@ -1309,11 +1335,24 @@ void StakeMiner(CWallet *pwallet)

AddSuperblockContractOrVote(StakeBlock);

if (log_timer)
{
time_elapsed = GetTimeMillis() - time_begin;
LogPrintf("StakeMiner(): AddSuperblockContractOrVote: elapsed %" PRId64 "ms", time_elapsed);
}


// * sign boinchash, coinstake, wholeblock
if (!SignStakeBlock(StakeBlock, BlockKey, StakeInputs, pwallet)) {
continue;
}

if (log_timer)
{
time_elapsed = GetTimeMillis() - time_begin;
LogPrintf("StakeMiner(): SignStakeBlock: elapsed %" PRId64 "ms", time_elapsed);
}

LogPrintf("StakeMiner: signed boinchash, coinstake, wholeblock");

{
Expand All @@ -1338,6 +1377,11 @@ void StakeMiner(CWallet *pwallet)
g_miner_status.m_last_pos_tx_hash = StakeBlock.vtx[1].GetHash();
}

if (log_timer)
{
time_elapsed = GetTimeMillis() - time_begin;
LogPrintf("StakeMiner(): ProcessBlock: elapsed %" PRId64 "ms", time_elapsed);
}
} //end while(!fShutdown)
}

0 comments on commit bc5dd0c

Please sign in to comment.