diff --git a/src/miner.cpp b/src/miner.cpp index 9ae9de8c97..a864e22ee0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -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; { @@ -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; @@ -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) ) @@ -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. @@ -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"); { @@ -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) }