Skip to content

Commit 337bd57

Browse files
jamescowensclaude
andcommitted
refactor: add verbose logging to OrphanBlockManager expiry and add
Log orphan additions (hash, prev, map size) and expirations (hash, age, count expired, remaining) at VERBOSE level for observability during forking events. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cdf2df9 commit 337bd57

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/node/orphan_blocks.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ bool OrphanBlockManager::Add(const uint256& hash, const CBlock& block, int64_t n
3636
m_orphans.emplace(hash, std::move(entry));
3737
m_by_prev.emplace(prev_hash, hash);
3838

39+
LogPrint(BCLog::LogFlags::VERBOSE, "OrphanBlockManager: added orphan %s (prev=%s, map size %u)",
40+
hash.ToString(), prev_hash.ToString(), m_orphans.size());
41+
3942
return true;
4043
}
4144

@@ -108,6 +111,10 @@ size_t OrphanBlockManager::EraseExpired(int64_t now)
108111
for (auto it = m_orphans.begin(); it != m_orphans.end(); ) {
109112
if (now - it->second.time_received > MAX_ORPHAN_AGE_SECONDS) {
110113
const uint256 hash = it->first;
114+
const int64_t age = now - it->second.time_received;
115+
116+
LogPrint(BCLog::LogFlags::VERBOSE, "OrphanBlockManager: expiring orphan %s (age %" PRId64 "s, map size %u)",
117+
hash.ToString(), age, m_orphans.size());
111118

112119
// Clean up SeenStakes before erasing.
113120
if (it->second.block->IsProofOfStake()) {
@@ -123,6 +130,11 @@ size_t OrphanBlockManager::EraseExpired(int64_t now)
123130
}
124131
}
125132

133+
if (count > 0) {
134+
LogPrint(BCLog::LogFlags::VERBOSE, "OrphanBlockManager: expired %u orphans, %u remaining",
135+
count, m_orphans.size());
136+
}
137+
126138
return count;
127139
}
128140

0 commit comments

Comments
 (0)