Skip to content

Commit 1fffdd7

Browse files
committed
net_processing: validationinterface: ignore some events for bg chain
1 parent fbe0a7d commit 1fffdd7

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/net_processing.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,9 +1917,25 @@ void PeerManagerImpl::BlockConnected(
19171917
const std::shared_ptr<const CBlock>& pblock,
19181918
const CBlockIndex* pindex)
19191919
{
1920-
m_orphanage.EraseForBlock(*pblock);
1920+
// Update this for all chainstate roles so that we don't mistakenly see peers
1921+
// helping us do background IBD as having a stale tip.
19211922
m_last_tip_update = GetTime<std::chrono::seconds>();
19221923

1924+
// In case the dynamic timeout was doubled once or more, reduce it slowly back to its default value
1925+
auto stalling_timeout = m_block_stalling_timeout.load();
1926+
Assume(stalling_timeout >= BLOCK_STALLING_TIMEOUT_DEFAULT);
1927+
if (stalling_timeout != BLOCK_STALLING_TIMEOUT_DEFAULT) {
1928+
const auto new_timeout = std::max(std::chrono::duration_cast<std::chrono::seconds>(stalling_timeout * 0.85), BLOCK_STALLING_TIMEOUT_DEFAULT);
1929+
if (m_block_stalling_timeout.compare_exchange_strong(stalling_timeout, new_timeout)) {
1930+
LogPrint(BCLog::NET, "Decreased stalling timeout to %d seconds\n", count_seconds(new_timeout));
1931+
}
1932+
}
1933+
1934+
if (role == ChainstateRole::BACKGROUND) {
1935+
return;
1936+
}
1937+
m_orphanage.EraseForBlock(*pblock);
1938+
19231939
{
19241940
LOCK(m_recent_confirmed_transactions_mutex);
19251941
for (const auto& ptx : pblock->vtx) {
@@ -1936,16 +1952,6 @@ void PeerManagerImpl::BlockConnected(
19361952
m_txrequest.ForgetTxHash(ptx->GetWitnessHash());
19371953
}
19381954
}
1939-
1940-
// In case the dynamic timeout was doubled once or more, reduce it slowly back to its default value
1941-
auto stalling_timeout = m_block_stalling_timeout.load();
1942-
Assume(stalling_timeout >= BLOCK_STALLING_TIMEOUT_DEFAULT);
1943-
if (stalling_timeout != BLOCK_STALLING_TIMEOUT_DEFAULT) {
1944-
const auto new_timeout = std::max(std::chrono::duration_cast<std::chrono::seconds>(stalling_timeout * 0.85), BLOCK_STALLING_TIMEOUT_DEFAULT);
1945-
if (m_block_stalling_timeout.compare_exchange_strong(stalling_timeout, new_timeout)) {
1946-
LogPrint(BCLog::NET, "Decreased stalling timeout to %d seconds\n", count_seconds(new_timeout));
1947-
}
1948-
}
19491955
}
19501956

19511957
void PeerManagerImpl::BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex)

0 commit comments

Comments
 (0)