gossip: choose a random subset on send instead of limiting connections (#2776)

* gossip: choose random subset on send

* naming bikeshed
This commit is contained in:
Andronik Ordian
2021-03-30 20:59:53 +02:00
committed by GitHub
parent a3115401c3
commit 9ac35d9f2b
10 changed files with 41 additions and 27 deletions
@@ -31,7 +31,10 @@ use polkadot_subsystem::{
SubsystemContext, SubsystemResult,
jaeger,
};
use polkadot_node_subsystem_util::metrics::{self, prometheus};
use polkadot_node_subsystem_util::{
metrics::{self, prometheus},
self as util, MIN_GOSSIP_PEERS,
};
use polkadot_primitives::v1::{Hash, SignedAvailabilityBitfield, SigningContext, ValidatorId};
use polkadot_node_network_protocol::{v1 as protocol_v1, PeerId, View, UnifiedReputationChange as Rep, OurView};
use std::collections::{HashMap, HashSet};
@@ -358,6 +361,7 @@ where
}
})
.collect::<Vec<PeerId>>();
let interested_peers = util::choose_random_sqrt_subset(interested_peers, MIN_GOSSIP_PEERS);
drop(_span);
if interested_peers.is_empty() {