Skip to content

Commit 192fa46

Browse files
committed
feat(network): enhance Gossipsub configuration for small networks
- Updated Gossipsub configuration to support small networks, specifically for 2-node setups. - Adjusted mesh and gossip parameters to relax requirements, ensuring better performance in limited peer environments.
1 parent 8c31495 commit 192fa46

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/src/actors_v2/network/swarm_factory.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,19 @@ fn create_behaviour(
8484
use std::collections::hash_map::DefaultHasher;
8585
use std::hash::{Hash, Hasher};
8686

87-
// Configure Gossipsub
87+
// Configure Gossipsub for small networks
88+
// For 2-node networks, we need to relax mesh requirements
8889
let gossipsub_config = gossipsub::ConfigBuilder::default()
8990
.max_transmit_size(config.message_size_limit)
9091
.validation_mode(gossipsub::ValidationMode::Strict)
92+
// Small network mesh parameters (minimum 1 peer)
93+
.mesh_n_low(1) // Minimum peers in mesh (default: 4)
94+
.mesh_n(2) // Target peers in mesh (default: 6)
95+
.mesh_n_high(3) // Max peers in mesh (default: 12)
96+
.mesh_outbound_min(1) // Minimum outbound peers (default: 2)
97+
// Relax gossip parameters for small networks
98+
.gossip_lazy(3) // Gossip to this many peers (default: 6)
99+
.gossip_factor(0.5) // Gossip factor (default: 0.25)
91100
.message_id_fn(|msg: &gossipsub::Message| {
92101
// Use first 20 bytes of hash as message ID
93102
let mut hasher = DefaultHasher::new();

0 commit comments

Comments
 (0)