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

This commit is contained in:
Dmitry Markin
2023-07-20 18:19:19 +03:00
committed by GitHub
parent 14b086263e
commit 0b2e7d4df5
3 changed files with 7 additions and 3 deletions
@@ -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,