Skip to content

discv4::DialScheduler

Per-chain dial scheduler mirroring go-ethereum's dialScheduler. Maintains up to pool->max_per_chain concurrent dial coroutines, respecting the global pool->max_total cap across all chains. All methods run on the single io_context thread — no mutex needed.

#include <dial_scheduler.hpp>

Inherits from std::enable_shared_from_this< DialScheduler >

Public Functions

Name
DialScheduler(boost::asio::io_context & io_, std::shared_ptr< WatcherPool > pool_, DialFn dial_fn_)
void enqueue(ValidatedPeer vp)
Enqueue a validated peer for dialing. If a slot is free (both per-chain and global caps), spawns immediately. Otherwise queues for later drain.
void release()
Called by every dial exit path. Recycles the slot and drains the queue up to the available capacity.
void stop()
Async stop — disconnect all active sessions immediately. Returns immediately; fds are freed on the next io_context cycle.

Public Attributes

Name
boost::asio::io_context & io
std::shared_ptr< WatcherPool > pool
DialFn dial_fn
FilterFn filter_fn
Optional peer filter; nullptr = accept all.
std::shared_ptr< DialHistory > dial_history
int active
int validated_count
currently active validated connections
int total_validated
cumulative count (never decrements)
bool stopping
std::deque< ValidatedPeer > queue
std::vector< std::weak_ptr< rlpx::RlpxSession > > active_sessions

Public Functions Documentation

function DialScheduler

inline DialScheduler(
    boost::asio::io_context & io_,
    std::shared_ptr< WatcherPool > pool_,
    DialFn dial_fn_
)

function enqueue

inline void enqueue(
    ValidatedPeer vp
)

Enqueue a validated peer for dialing. If a slot is free (both per-chain and global caps), spawns immediately. Otherwise queues for later drain.

function release

inline void release()

Called by every dial exit path. Recycles the slot and drains the queue up to the available capacity.

function stop

inline void stop()

Async stop — disconnect all active sessions immediately. Returns immediately; fds are freed on the next io_context cycle.

Public Attributes Documentation

variable io

boost::asio::io_context & io;

variable pool

std::shared_ptr< WatcherPool > pool;

variable dial_fn

DialFn dial_fn;

variable filter_fn

FilterFn filter_fn {};

Optional peer filter; nullptr = accept all.

variable dial_history

std::shared_ptr< DialHistory > dial_history;

variable active

int active {0};

variable validated_count

int validated_count {0};

currently active validated connections

variable total_validated

int total_validated {0};

cumulative count (never decrements)

variable stopping

bool stopping {false};

variable queue

std::deque< ValidatedPeer > queue;

variable active_sessions

std::vector< std::weak_ptr< rlpx::RlpxSession > > active_sessions;

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