Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose randomly who to connect to and open slots with #1424

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions light-base/src/network_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use futures_lite::FutureExt as _;
use futures_util::{future, stream, StreamExt as _};
use hashbrown::{HashMap, HashSet};
use itertools::Itertools as _;
use rand::seq::IteratorRandom as _;
use rand_chacha::rand_core::SeedableRng as _;
use smoldot::{
header,
Expand Down Expand Up @@ -1003,7 +1004,12 @@ async fn background_task<TPlat: PlatformRef>(mut task: BackgroundTask<TPlat>) {
WakeUpReason::NetworkEvent(event)
} else if let Some(start_connect) = {
let x = (task.num_recent_connection_opening < task.connections_open_pool_size)
.then(|| task.network.unconnected_desired().next().cloned())
.then(|| {
task.network
.unconnected_desired()
.choose(&mut task.randomness)
.cloned()
})
.flatten();
x
} {
Expand All @@ -1012,7 +1018,7 @@ async fn background_task<TPlat: PlatformRef>(mut task: BackgroundTask<TPlat>) {
let x = task
.network
.connected_unopened_gossip_desired()
.next()
.choose(&mut task.randomness)
.map(|(peer_id, chain_id, _)| (peer_id.clone(), chain_id));
x
} {
Expand Down
1 change: 1 addition & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Changed

- The order in which smoldot connects to peers is now random rather than depending on the peer. ([#1424](https://github.com/smol-dot/smoldot/pull/1424))
- Increase the rate at which connections are opened to 10 per second, with a pool of 8 simultaneous connections openings. ([#1425](https://github.com/smol-dot/smoldot/pull/1425))

## 2.0.12 - 2023-11-27
Expand Down
Loading