diff options
| author | tv <tv@krebsco.de> | 2026-11-22 12:00:44 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-22 12:00:44 +0000 |
| commit | 448089f452025ec8c655532c758ea6ca9520b6ae (patch) | |
| tree | 9359c5769217293a44f6ddaf98af398e0663782b /src/transport/libp2p/mod.rs | |
| parent | 46dbc0a3485f1d5d7624a0e450d51f4866a840ff (diff) | |
libp2p: room for inbound streams that come in at once
libp2p-stream hands each inbound stream to the consumer through a
channel with room for one (Control::accept, mpsc::channel(0), try_send):
one arriving while another waits is dropped, unread, logged at debug
under libp2p's target alone. Messages sent to a node at once were lost
but one, and a proof is two since wire versions side by side (SPEAKS,
then WHO): a joiner's WHO went unanswered until RESOLVE_TIMEOUT, 10 s,
and nodes_over_libp2p failed now and then.
The transport accepts with Control::accept_with_buffer, with room for
as many streams as it reads at once (WAITING, READS + STRANGER_READS):
beyond them, one is dropped still. messages_sent_at_once_all_come_in
sends 30 at once from three peers; without this, 3 to 7 came in.
Diffstat (limited to 'src/transport/libp2p/mod.rs')
| -rw-r--r-- | src/transport/libp2p/mod.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/transport/libp2p/mod.rs b/src/transport/libp2p/mod.rs index 24f5f34..2e3e897 100644 --- a/src/transport/libp2p/mod.rs +++ b/src/transport/libp2p/mod.rs @@ -155,6 +155,10 @@ const READS: usize = 32; /// Of peers not admitted (`transport::Admission`), apart: their streams never take /// members' turns. One more is refused, unread (a peer's HELLO is sent again). const STRANGER_READS: usize = 8; +/// Inbound streams waiting for the consumer to take them (`libp2p_stream`), as many as it +/// reads at once: one more is dropped unread, as streams that come in at once otherwise +/// are, all but one (a proof's SPEAKS and WHO, say). +const WAITING: usize = READS + STRANGER_READS; /// Addresses kept per peer, and peers with addresses at most. const ADDRESSES_PER_PEER: usize = 8; /// Addresses known not to be a peer's (`Book::wrong`), per peer at most. @@ -270,7 +274,7 @@ impl Libp2pTransport { let incoming = if config.continuum { Some( control - .accept(PROTOCOL) + .accept_with_buffer(PROTOCOL, WAITING) .map_err(|error| anyhow!("Accepting {PROTOCOL}: {error}"))?, ) } else { |
