@@ -1917,9 +1917,25 @@ void PeerManagerImpl::BlockConnected(
1917
1917
const std::shared_ptr<const CBlock>& pblock,
1918
1918
const CBlockIndex* pindex)
1919
1919
{
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.
1921
1922
m_last_tip_update = GetTime<std::chrono::seconds>();
1922
1923
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
+
1923
1939
{
1924
1940
LOCK (m_recent_confirmed_transactions_mutex);
1925
1941
for (const auto & ptx : pblock->vtx ) {
@@ -1936,16 +1952,6 @@ void PeerManagerImpl::BlockConnected(
1936
1952
m_txrequest.ForgetTxHash (ptx->GetWitnessHash ());
1937
1953
}
1938
1954
}
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
- }
1949
1955
}
1950
1956
1951
1957
void PeerManagerImpl::BlockDisconnected (const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex)
0 commit comments