Fix crash when --in-peers & --out-peers both 0 (#14598)

This commit is contained in:
Dmitry Markin authored and GitHub committed 2023-07-20 18:19:19 +03:00
1 parent 14b086263e
commit 0b2e7d4df5
3 files changed
+7 -3

No files matched your search

@@ -153,7 +153,8 @@ where
) -> (Self, ProtocolConfig) {
// Reserve enough request slots for one request per peer when we are at the maximum
// number of peers.
let (tx, request_receiver) = async_channel::bounded(num_peer_hint);
let capacity = std::cmp::max(num_peer_hint, 1);
let (tx, request_receiver) = async_channel::bounded(capacity);
let mut protocol_config = generate_protocol_config(
protocol_id,
@@ -131,7 +131,8 @@ where
) -> (Self, ProtocolConfig) {
// Reserve enough request slots for one request per peer when we are at the maximum
// number of peers.
let (tx, request_receiver) = async_channel::bounded(num_peer_hint);
let capacity = std::cmp::max(num_peer_hint, 1);
let (tx, request_receiver) = async_channel::bounded(capacity);
let mut protocol_config = generate_protocol_config(
protocol_id,