Skip to content

Commit 6d14916

Browse files
committed
trivial: add CChainState::ToString()
1 parent e354db7 commit 6d14916

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/validation.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4908,6 +4908,13 @@ void CChainState::CheckBlockIndex(const Consensus::Params& consensusParams)
49084908
assert(nNodes == forward.size());
49094909
}
49104910

4911+
std::string CChainState::ToString()
4912+
{
4913+
CBlockIndex* tip = m_chain.Tip();
4914+
return strprintf("Chainstate [%s] @ height %d",
4915+
tip ? tip->nHeight : -1, tip ? tip->GetBlockHash().ToString() : "null");
4916+
}
4917+
49114918
std::string CBlockFileInfo::ToString() const
49124919
{
49134920
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, FormatISO8601Date(nTimeFirst), FormatISO8601Date(nTimeLast));

src/validation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ class CChainState {
618618
*/
619619
std::set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexCandidates;
620620

621+
std::string ToString();
622+
621623
//! @returns A reference to the in-memory cache of the UTXO set.
622624
CCoinsViewCache& CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
623625
{

0 commit comments

Comments
 (0)