Browse Source

implicit fallback update

cl-refactor
subtly 10 years ago
parent
commit
ca0ce068c6
  1. 1
      libp2p/Peer.cpp
  2. 3
      libp2p/Peer.h
  3. 2
      libp2p/Session.cpp

1
libp2p/Peer.cpp

@ -44,6 +44,7 @@ unsigned Peer::fallbackSeconds() const
return 30 * (m_failedAttempts + 1);
case UselessPeer:
case TooManyPeers:
return 25 * (m_failedAttempts + 1);
case ClientQuit:
return 15 * (m_failedAttempts + 1);
case NoDisconnect:

3
libp2p/Peer.h

@ -75,6 +75,9 @@ public:
/// Reason peer was previously disconnected.
DisconnectReason lastDisconnect() const { return m_lastDisconnect; }
/// Peer session is noted as useful.
void noteSessionGood() { m_failedAttempts = 0; }
protected:
/// Returns number of seconds to wait until attempting connection, based on attempted connection history.
unsigned fallbackSeconds() const;

2
libp2p/Session.cpp

@ -358,8 +358,6 @@ void Session::drop(DisconnectReason _reason)
}
catch (...) {}
if (m_peer->m_lastDisconnect == NoDisconnect && (_reason == ClientQuit || _reason == DisconnectRequested))
m_peer->m_failedAttempts = 0;
m_peer->m_lastDisconnect = _reason;
if (_reason == BadProtocol)
{

Loading…
Cancel
Save