mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-22 19:49:22 +00:00
Reduce target peers a bit
This commit is contained in:
parent
67a0ff825b
commit
2ba6d77ee7
1 changed files with 3 additions and 3 deletions
|
@ -371,7 +371,7 @@ impl LibP2p {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: If a network has less than TARGET_PEERS, this will cause retries ad infinitum
|
// TODO: If a network has less than TARGET_PEERS, this will cause retries ad infinitum
|
||||||
const TARGET_PEERS: usize = 8;
|
const TARGET_PEERS: usize = 5;
|
||||||
|
|
||||||
// The addrs we're currently dialing, and the networks associated with them
|
// The addrs we're currently dialing, and the networks associated with them
|
||||||
let dialing_peers = Arc::new(RwLock::new(HashMap::new()));
|
let dialing_peers = Arc::new(RwLock::new(HashMap::new()));
|
||||||
|
@ -493,8 +493,8 @@ impl LibP2p {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Randomly select up to 2 * TARGET_PEERS
|
// Randomly select up to 150% of the TARGET_PEERS
|
||||||
for _ in 0 .. (2 * TARGET_PEERS) {
|
for _ in 0 .. ((3 * TARGET_PEERS) / 2) {
|
||||||
if !nodes.is_empty() {
|
if !nodes.is_empty() {
|
||||||
let to_connect = nodes.swap_remove(
|
let to_connect = nodes.swap_remove(
|
||||||
usize::try_from(OsRng.next_u64() % u64::try_from(nodes.len()).unwrap())
|
usize::try_from(OsRng.next_u64() % u64::try_from(nodes.len()).unwrap())
|
||||||
|
|
Loading…
Reference in a new issue