mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
p2p: Make timeout mockable and type safe, speed up test
This commit is contained in:
@@ -4312,9 +4312,10 @@ void PeerManagerImpl::CheckForStaleTipAndEvictPeers()
|
||||
|
||||
void PeerManagerImpl::MaybeSendPing(CNode& node_to, Peer& peer, std::chrono::microseconds now)
|
||||
{
|
||||
if (m_connman.ShouldRunInactivityChecks(node_to, std::chrono::duration_cast<std::chrono::seconds>(now).count()) &&
|
||||
if (m_connman.ShouldRunInactivityChecks(node_to, std::chrono::duration_cast<std::chrono::seconds>(now)) &&
|
||||
peer.m_ping_nonce_sent &&
|
||||
now > peer.m_ping_start.load() + std::chrono::seconds{TIMEOUT_INTERVAL}) {
|
||||
now > peer.m_ping_start.load() + TIMEOUT_INTERVAL)
|
||||
{
|
||||
// The ping timeout is using mocktime. To disable the check during
|
||||
// testing, increase -peertimeout.
|
||||
LogPrint(BCLog::NET, "ping timeout: %fs peer=%d\n", 0.000001 * count_microseconds(now - peer.m_ping_start.load()), peer.m_id);
|
||||
|
||||
Reference in New Issue
Block a user