Skip to content

Commit 3a61fc5

Browse files
committed
refactor: move CBlockIndex#ToString() from header to implementation
which allows dropping tinyformat.h from the header file.
1 parent 57865eb commit 3a61fc5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/chain.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
#include <chain.h>
7+
#include <tinyformat.h>
78
#include <util/time.h>
89

910
std::string CBlockFileInfo::ToString() const
1011
{
1112
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, FormatISO8601Date(nTimeFirst), FormatISO8601Date(nTimeLast));
1213
}
1314

15+
std::string CBlockIndex::ToString() const
16+
{
17+
return strprintf("CBlockIndex(pprev=%p, nHeight=%d, merkle=%s, hashBlock=%s)",
18+
pprev, nHeight, hashMerkleRoot.ToString(), GetBlockHash().ToString());
19+
}
20+
1421
void CChain::SetTip(CBlockIndex *pindex) {
1522
if (pindex == nullptr) {
1623
vChain.clear();

src/chain.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <flatfile.h>
1212
#include <primitives/block.h>
1313
#include <sync.h>
14-
#include <tinyformat.h>
1514
#include <uint256.h>
1615

1716
#include <vector>
@@ -302,13 +301,7 @@ class CBlockIndex
302301
return pbegin[(pend - pbegin) / 2];
303302
}
304303

305-
std::string ToString() const
306-
{
307-
return strprintf("CBlockIndex(pprev=%p, nHeight=%d, merkle=%s, hashBlock=%s)",
308-
pprev, nHeight,
309-
hashMerkleRoot.ToString(),
310-
GetBlockHash().ToString());
311-
}
304+
std::string ToString() const;
312305

313306
//! Check whether this block index entry is valid up to the passed validity level.
314307
bool IsValid(enum BlockStatus nUpTo = BLOCK_VALID_TRANSACTIONS) const

0 commit comments

Comments
 (0)