mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 10:27:59 +00:00
Fix crash when --in-peers & --out-peers both 0 (#14598)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -785,12 +785,14 @@ where
|
||||
};
|
||||
|
||||
let (state_request_protocol_config, state_request_protocol_name) = {
|
||||
let num_peer_hint = net_config.network_config.default_peers_set_num_full as usize +
|
||||
net_config.network_config.default_peers_set.reserved_nodes.len();
|
||||
// Allow both outgoing and incoming requests.
|
||||
let (handler, protocol_config) = StateRequestHandler::new(
|
||||
&protocol_id,
|
||||
config.chain_spec.fork_id(),
|
||||
client.clone(),
|
||||
net_config.network_config.default_peers_set_num_full as usize,
|
||||
num_peer_hint,
|
||||
);
|
||||
let config_name = protocol_config.name.clone();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user