Skip to content

Commit 479ae82

Browse files
committed
merge bitcoin#23235: Reduce unnecessary default logging
1 parent 6a51ab2 commit 479ae82

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

src/logging.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ const CLogCategoryDesc LogCategories[] =
161161
{BCLog::I2P, "i2p"},
162162
{BCLog::IPC, "ipc"},
163163
{BCLog::LOCK, "lock"},
164+
{BCLog::BLOCKSTORE, "blockstorage"},
164165
{BCLog::TXRECONCILIATION, "txreconciliation"},
165166
{BCLog::ALL, "1"},
166167
{BCLog::ALL, "all"},

src/logging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ namespace BCLog {
6262
I2P = (1 << 22),
6363
IPC = (1 << 23),
6464
LOCK = (1 << 24),
65+
BLOCKSTORE = (1 << 26),
6566
TXRECONCILIATION = (1 << 27),
6667

6768
//Start Dash

src/node/blockstorage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ void UnlinkPrunedFiles(const std::set<int>& setFilesToPrune)
585585
FlatFilePos pos(*it, 0);
586586
fs::remove(BlockFileSeq().FileName(pos));
587587
fs::remove(UndoFileSeq().FileName(pos));
588-
LogPrintf("Prune: %s deleted blk/rev (%05u)\n", __func__, *it);
588+
LogPrint(BCLog::BLOCKSTORE, "Prune: %s deleted blk/rev (%05u)\n", __func__, *it);
589589
}
590590
}
591591

@@ -642,7 +642,7 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne
642642

643643
if ((int)nFile != m_last_blockfile) {
644644
if (!fKnown) {
645-
LogPrint(BCLog::VALIDATION, "Leaving block file %i: %s\n", m_last_blockfile, m_blockfile_info[m_last_blockfile].ToString());
645+
LogPrint(BCLog::BLOCKSTORE, "Leaving block file %i: %s\n", m_last_blockfile, m_blockfile_info[m_last_blockfile].ToString());
646646
}
647647
FlushBlockFile(!fKnown, finalize_undo);
648648
m_last_blockfile = nFile;

src/validation.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,8 +2463,8 @@ bool CChainState::FlushStateToDisk(
24632463
// Flush best chain related state. This can only be done if the blocks / block index write was also done.
24642464
if (fDoFullFlush && !CoinsTip().GetBestBlock().IsNull()) {
24652465
{
2466-
LOG_TIME_SECONDS(strprintf("write coins cache to disk (%d coins, %.2fkB)",
2467-
coins_count, coins_mem_usage / 1000));
2466+
LOG_TIME_MILLIS_WITH_CATEGORY(strprintf("write coins cache to disk (%d coins, %.2fkB)",
2467+
coins_count, coins_mem_usage / 1000), BCLog::BENCHMARK);
24682468

24692469
// Typical Coin structures on disk are around 48 bytes in size.
24702470
// Pushing a new one to the database can cause it to be written
@@ -3756,7 +3756,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
37563756
if (ppindex)
37573757
*ppindex = pindex;
37583758
if (pindex->nStatus & BLOCK_FAILED_MASK) {
3759-
LogPrintf("ERROR: %s: block %s is marked invalid\n", __func__, hash.ToString());
3759+
LogPrint(BCLog::VALIDATION, "%s: block %s is marked invalid\n", __func__, hash.ToString());
37603760
return state.Invalid(BlockValidationResult::BLOCK_CACHED_INVALID, "duplicate");
37613761
}
37623762
if (pindex->nStatus & BLOCK_CONFLICT_CHAINLOCK) {
@@ -3775,25 +3775,26 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
37753775
CBlockIndex* pindexPrev = nullptr;
37763776
BlockMap::iterator mi{m_blockman.m_block_index.find(block.hashPrevBlock)};
37773777
if (mi == m_blockman.m_block_index.end()) {
3778-
LogPrintf("ERROR: %s: prev block not found\n", __func__);
3778+
LogPrint(BCLog::VALIDATION, "%s: %s prev block not found\n", __func__, hash.ToString());
37793779
return state.Invalid(BlockValidationResult::BLOCK_MISSING_PREV, "prev-blk-not-found");
37803780
}
37813781
pindexPrev = &((*mi).second);
37823782
assert(pindexPrev);
37833783

37843784
if (pindexPrev->nStatus & BLOCK_FAILED_MASK) {
3785-
LogPrintf("ERROR: %s: prev block invalid\n", __func__);
3785+
LogPrint(BCLog::VALIDATION, "%s: %s prev block invalid\n", __func__, hash.ToString());
37863786
return state.Invalid(BlockValidationResult::BLOCK_INVALID_PREV, "bad-prevblk");
37873787
}
37883788

37893789
if (pindexPrev->nStatus & BLOCK_CONFLICT_CHAINLOCK) {
37903790
// it's ok-ish, the other node is probably missing the latest chainlock
3791-
LogPrintf("ERROR: %s: prev block %s conflicts with chainlock\n", __func__, block.hashPrevBlock.ToString());
3791+
LogPrint(BCLog::VALIDATION, "%s: prev block %s conflicts with chainlock\n", __func__, block.hashPrevBlock.ToString());
37923792
return state.Invalid(BlockValidationResult::BLOCK_CHAINLOCK, "bad-prevblk-chainlock");
37933793
}
37943794

37953795
if (!ContextualCheckBlockHeader(block, state, m_blockman, chainparams, pindexPrev, GetAdjustedTime())) {
3796-
return error("%s: Consensus::ContextualCheckBlockHeader: %s, %s", __func__, hash.ToString(), state.ToString());
3796+
LogPrint(BCLog::VALIDATION, "%s: Consensus::ContextualCheckBlockHeader: %s, %s\n", __func__, hash.ToString(), state.ToString());
3797+
return false;
37973798
}
37983799

37993800
/* Determine if this block descends from any block which has been found
@@ -3829,7 +3830,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
38293830
m_blockman.m_dirty_blockindex.insert(invalid_walk);
38303831
invalid_walk = invalid_walk->pprev;
38313832
}
3832-
LogPrintf("ERROR: %s: prev block invalid\n", __func__);
3833+
LogPrint(BCLog::VALIDATION, "%s: %s prev block invalid\n", __func__, hash.ToString());
38333834
return state.Invalid(BlockValidationResult::BLOCK_INVALID_PREV, "bad-prevblk");
38343835
}
38353836
}

test/functional/rpc_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def run_test(self):
5757
self.log.info("test logging rpc and help")
5858

5959
# Test logging RPC returns the expected number of logging categories.
60-
assert_equal(len(node.logging()), 39)
60+
assert_equal(len(node.logging()), 40)
6161

6262
# Test toggling a logging category on/off/on with the logging RPC.
6363
assert_equal(node.logging()['qt'], True)

0 commit comments

Comments
 (0)