Skip to content

discv4::DialHistory

Tracks recently-dialed peers and suppresses retry attempts until a configurable cooldown expires. More...

#include <dial_history.hpp>

Public Types

Name
using std::chrono::steady_clock Clock
using Clock::time_point TimePoint
using Clock::duration Duration

Public Functions

Name
DialHistory(Duration expiry =kDefaultExpiry)
void add(const std::array< uint8_t, 64 > & node_id)
Record that a node has just been dialed.
bool contains(const std::array< uint8_t, 64 > & node_id) const
Returns true if the node was recently dialed and the cooldown has not yet expired. Does NOT call expire() automatically — call expire() first if you want stale entries pruned.
void expire()
Remove all entries whose expiry time has passed.
std::size_t size() const
Number of active (non-expired) entries.

Public Attributes

Name
Duration kDefaultExpiry
Default expiry duration matching go-ethereum's dialHistoryExpiration.

Detailed Description

class discv4::DialHistory;

Tracks recently-dialed peers and suppresses retry attempts until a configurable cooldown expires.

Mirrors go-ethereum's expHeap-backed dial history in p2p/dial.go. The default expiry (35 s) matches go-ethereum's dialHistoryExpiration (inboundThrottleTime 30 s + 5 s guard).

Not thread-safe — callers must serialise access if needed.

Public Types Documentation

using Clock

using discv4::DialHistory::Clock = std::chrono::steady_clock;

using TimePoint

using discv4::DialHistory::TimePoint = Clock::time_point;

using Duration

using discv4::DialHistory::Duration = Clock::duration;

Public Functions Documentation

function DialHistory

inline explicit DialHistory(
    Duration expiry =kDefaultExpiry
)

Parameters:

  • expiry How long a dialed node is suppressed before being retried.

function add

inline void add(
    const std::array< uint8_t, 64 > & node_id
)

Record that a node has just been dialed.

Parameters:

  • node_id 64-byte secp256k1 public key identifying the peer.

function contains

inline bool contains(
    const std::array< uint8_t, 64 > & node_id
) const

Returns true if the node was recently dialed and the cooldown has not yet expired. Does NOT call expire() automatically — call expire() first if you want stale entries pruned.

Parameters:

  • node_id 64-byte secp256k1 public key identifying the peer.

function expire

inline void expire()

Remove all entries whose expiry time has passed.

function size

inline std::size_t size() const

Number of active (non-expired) entries.

Public Attributes Documentation

variable kDefaultExpiry

static Duration kDefaultExpiry = kDefaultDialHistoryExpiry;

Default expiry duration matching go-ethereum's dialHistoryExpiration.


Updated on 2026-04-13 at 23:22:46 -0700