Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
aeba523
Gossipsub message signing
AgeManning May 19, 2020
573e4b6
Update ipfs-private example
AgeManning May 19, 2020
d2babd4
Add optimisation to prevent key calculation each message
AgeManning May 22, 2020
8353474
Support multiple versions
AgeManning May 22, 2020
b7db121
Initial porting of peer_scoring from go-libp2p
AgeManning May 22, 2020
ac3c977
Handle forwarding of signed messages and reviewers comments
AgeManning May 25, 2020
f3ff66b
Merge latest gossipsub signing
AgeManning May 25, 2020
c8335cc
Progress to porting scoring functions
AgeManning May 25, 2020
e9afd95
Merge branch 'master' into gossipsub-signing
AgeManning May 27, 2020
984a662
Finish first port of score params
AgeManning May 27, 2020
80ea7df
Add defaults to scoring
AgeManning May 27, 2020
58f61b4
Generalise topic hashing
AgeManning May 27, 2020
238e305
Update topic hashing structure
AgeManning May 27, 2020
fec112a
Update v1.1 tests
AgeManning May 27, 2020
bc09eb7
Add more unit tests
AgeManning May 27, 2020
3d1a025
protocols/gossipsub/src/protocol: Use quickcheck to test signing (#31)
mxinden Jun 1, 2020
31b6849
Shift signing into behaviour
AgeManning Jun 1, 2020
a8cec0b
Merge latest master
AgeManning Jul 1, 2020
2b38112
Address reviewers suggestions
AgeManning Jul 1, 2020
7d678f5
Send subscriptions to all peers
AgeManning Jul 1, 2020
dc050dd
Update examples
AgeManning Jul 1, 2020
5bf1cfc
Shift signing option into the behaviour
AgeManning Jul 1, 2020
4ffe728
Revert changes to core/
AgeManning Jul 9, 2020
24b738c
Reviewers suggestion
AgeManning Jul 9, 2020
a2e4bf0
Merge remote-tracking branch 'origin/master' into gossipsub-signing
AgeManning Jul 9, 2020
2f20571
Merge latest master
AgeManning Jul 23, 2020
2c50ba2
Revert changes to core/
AgeManning Jul 23, 2020
4de878e
Switch gossipsub state to use sets instead of vectors
rklaehn Jul 23, 2020
e43f0a0
Make tests pass
rklaehn Jul 23, 2020
57f07aa
Some clippy
rklaehn Jul 23, 2020
b6eeb3c
Prevent duplicate finding during JOIN
AgeManning Jul 24, 2020
0d5bde4
Merge #1675
AgeManning Jul 24, 2020
aec51e0
Update tests, improve logging
AgeManning Jul 24, 2020
759a5ad
Update the default d_lo constant
AgeManning Jul 24, 2020
495ffe4
Handle errors correctly
AgeManning Jul 24, 2020
1ea2dd9
Add privacy and validation options in the config
AgeManning Jul 24, 2020
8e69465
Merge branch 'master' into gossipsub-v1.1
blacktemplar Jul 24, 2020
1f73ded
A few improvements (#32)
rklaehn Jul 24, 2020
7b76c8f
Improve signing validation logic
AgeManning Jul 24, 2020
f5d32b2
Change the gossipsub rpc protocol to use bytes for message ids (#34)
rklaehn Jul 25, 2020
c3a7757
Add optional privacy and validation settings
AgeManning Jul 26, 2020
0c43ed4
Correct doc link
AgeManning Jul 27, 2020
efa40e3
Prevent invalid messages from being gossiped
AgeManning Jul 27, 2020
a514c60
Remove unvalidated messages from gossip. Reintroduce duplicate cache
AgeManning Jul 27, 2020
b257025
Send grafts when subscriptions are added to the mesh
AgeManning Jul 28, 2020
b20771b
Merge latest master
AgeManning Jul 28, 2020
cacadc0
Merge gossipsub-signing
AgeManning Jul 28, 2020
6566925
implement explicit peers
blacktemplar Jul 28, 2020
81338d5
Merge branch 'gossipsub-v1.1' into gossipsub-v1.1-explicit-peers
blacktemplar Jul 28, 2020
ecb2d8b
Fix ipfs-kad example
AgeManning Jul 28, 2020
2a830b9
Merge branch 'gossipsub-v1.1' into gossipsub-v1.1-explicit-peers
blacktemplar Jul 28, 2020
b78d771
finish merging + rustfmt
blacktemplar Jul 28, 2020
8bffa91
undo changes in ipfs-private
blacktemplar Jul 28, 2020
2f4a50a
Only add messages to memcache if not duplicates
AgeManning Jul 28, 2020
99a37bb
Merge latest signing
AgeManning Jul 28, 2020
284bf1c
Merge pull request #36 from blacktemplar/gossipsub-v1.1-explicit-peers
blacktemplar Jul 28, 2020
be7c9e2
Add mesh maintenance tests and remove excess peers from mesh
AgeManning Jul 29, 2020
e049ff7
Apply reviewers suggestions
AgeManning Jul 29, 2020
74d2779
Merge latest master
AgeManning Jul 29, 2020
81fca56
Merge latest gossipsub-signing
AgeManning Jul 29, 2020
6bac865
Wrap comments
AgeManning Jul 29, 2020
6e0a6b3
implement px and prune backoff + simplify tests for explicit peers
blacktemplar Jul 29, 2020
1257639
Merge pull request #37 from sigp/gossipsub-v1.1-prune-backoff-and-px
blacktemplar Jul 29, 2020
6c77022
improved data structure for storing backoffs + adding configurable sl…
blacktemplar Jul 30, 2020
8b17725
Merge pull request #38 from sigp/gossipsub-v1.1-prune-backoff-and-px
blacktemplar Jul 30, 2020
2518f9f
allow flood publishing (on by default)
blacktemplar Jul 30, 2020
1994c88
Merge pull request #39 from sigp/gossipsub-v1.1-flood-publishing
blacktemplar Jul 30, 2020
dbe0a84
implement adaptive gossip dissemination + complete config debug output
blacktemplar Jul 30, 2020
7155f5c
Merge pull request #40 from sigp/gossipsub-v1.1-adaptive-gossip-disse…
blacktemplar Jul 31, 2020
da34368
fix bug in backoff storage data structure
blacktemplar Jul 31, 2020
66730dd
make GossipsubConfig fields private + add getters + improve validatio…
blacktemplar Jul 31, 2020
8a0b278
implements a configurable minimum number of mesh peers that are outbound
blacktemplar Jul 31, 2020
4e1375a
Merge pull request #41 from sigp/gossipsub-v1.1-outbound-mesh-quota
blacktemplar Aug 1, 2020
94469cf
Ensure sequence number is sent
AgeManning Aug 2, 2020
60f8a1e
Merge latest master
AgeManning Aug 2, 2020
fef66dd
Maintain the debug trait
AgeManning Aug 2, 2020
799137c
use the score module in the behaviour, calling the score update metho…
blacktemplar Aug 6, 2020
efb59ac
Merge pull request #42 from sigp/gossipsub-v1.1-score-wiring
blacktemplar Aug 6, 2020
b6fbf05
implement opportunistic grafting
blacktemplar Aug 6, 2020
189ffc4
remove done TODO
blacktemplar Aug 6, 2020
f405d2a
remove done TODO
blacktemplar Aug 6, 2020
6fe395a
cargo fmt
blacktemplar Aug 6, 2020
47855d6
Merge branch 'gossipsub-v1.1' into gossip-v1.1-opportunistic-grafting
blacktemplar Aug 6, 2020
5954403
ignore grafts in unknown topics
blacktemplar Aug 6, 2020
a228f3b
Merge pull request #43 from sigp/gossip-v1.1-opportunistic-grafting
blacktemplar Aug 6, 2020
3d69944
Merge branch 'gossipsub-v1.1' into gossipsub-v1.1-spam-protection-mea…
blacktemplar Aug 6, 2020
afba384
cap the number of gossipsub retransmission for the iwants of the same…
blacktemplar Aug 6, 2020
223f0d8
cap the number of processed ihaves per peer per heartbeat, plus the m…
blacktemplar Aug 7, 2020
1ced56e
Replace lru cache with custom duplicatecache
AgeManning Aug 7, 2020
27ac942
track iwant messages we send and penalize peers not responding to them
blacktemplar Aug 7, 2020
04d3e2f
removes todo
blacktemplar Aug 7, 2020
5c52843
Improve stream management and error handling
AgeManning Aug 7, 2020
a135fc0
Merge pull request #44 from sigp/gossipsub-v1.1-spam-protection-measures
blacktemplar Aug 7, 2020
d9ee8e4
Merge remote-tracking branch 'origin/gossipsub-signing' into gossipsu…
blacktemplar Aug 7, 2020
714fee3
Merge branch 'master' into gossipsub-v1.1
blacktemplar Aug 7, 2020
7f7fd17
cargo fmt
blacktemplar Aug 7, 2020
ee7dd71
Gossipsub v1.1 check fmt (#45)
blacktemplar Aug 7, 2020
5109fe7
Merge duplicate cache
AgeManning Aug 10, 2020
b748618
Merge substream updates
AgeManning Aug 10, 2020
7bdb378
Propagate signature verification and peer kinds to behaviour (#46)
AgeManning Aug 12, 2020
83280db
treat peers that do not support the protocol as disconnected (#48)
blacktemplar Aug 12, 2020
5d93c0a
Gossipsub v1.1 various improvements (#49)
blacktemplar Aug 17, 2020
3206da5
Gossipsub 1.1 ammendments (#50)
AgeManning Aug 24, 2020
59034e2
Complete porting of go scoring tests (#51)
AgeManning Aug 25, 2020
521ecdb
Add peer blacklisting (#52)
AgeManning Aug 25, 2020
261f78e
Estimate message size (#53)
AgeManning Aug 26, 2020
f71a1bb
Message fragmentation (#54)
AgeManning Aug 27, 2020
c762d6c
Correct tests and merge latest master (#55)
AgeManning Aug 27, 2020
8ec6b66
Merge latest master
AgeManning Aug 27, 2020
4f92599
Remove github workflow
AgeManning Aug 27, 2020
618334a
Cleanup code add logs (#56)
AgeManning Aug 28, 2020
9a03f94
Further improve logging (#57)
AgeManning Aug 28, 2020
e031bce
Remove lru_time_cache_dep (#58)
AgeManning Aug 30, 2020
c7f0716
Various improvements (#60)
blacktemplar Sep 25, 2020
9da2af7
Cache published message ids (#61)
blacktemplar Oct 2, 2020
464c4da
use generic type for message data + cache message ids (#67)
blacktemplar Oct 8, 2020
88ee95e
Adds a fast message id function and an additional cache for it (#68)
blacktemplar Oct 9, 2020
238e5cf
Merge branch 'master' into gossipsub-v1.1
blacktemplar Oct 9, 2020
6ee2c5f
export FastMessageId
blacktemplar Oct 9, 2020
4c95f86
Gossipsub v1.1 bug fixes (#71)
blacktemplar Oct 14, 2020
c2c4a26
add subscription filters + some useful default filters + refactor tes…
blacktemplar Oct 14, 2020
201d533
remove support for multi-topic messages (#73)
blacktemplar Oct 20, 2020
87633a3
also consider allow self origin when using a published message ids di…
blacktemplar Oct 21, 2020
0e28cba
fix clippy warnings (#83)
blacktemplar Oct 21, 2020
9ba9b8a
Merge branch 'master' into gossipsub-v1.1
blacktemplar Oct 22, 2020
6bb58ec
Merge latest master
AgeManning Nov 3, 2020
7a316e8
Merge latest master
AgeManning Nov 6, 2020
d306455
Address reviewers comments (#88)
AgeManning Nov 8, 2020
2d1170b
implement as_ref and as_static_ref to get a &str from PeerKind (#91)
blacktemplar Nov 16, 2020
8bdc378
Merge latest master
AgeManning Nov 17, 2020
34f58fb
Update to latest master
AgeManning Nov 17, 2020
5157e70
only respond to IWANT if message got already validated (#96)
blacktemplar Nov 26, 2020
82be02d
protocols/gossipsub: Review (#93)
mxinden Dec 7, 2020
ffee445
Merge latest master
AgeManning Dec 7, 2020
23d7d04
Add optional compression to gossipsub (#100)
AgeManning Dec 16, 2020
1b5a35e
Remove feature gating from gossipsub
AgeManning Dec 16, 2020
1b19338
Merge latest master
AgeManning Dec 17, 2020
a15b246
Remove compression in favour of a more general data transform
AgeManning Dec 17, 2020
4cca4d3
Loosen trait bounds on gossipsub
AgeManning Dec 18, 2020
88ed4e5
Merge latest master
AgeManning Jan 6, 2021
f47ae78
Fix doclinks
AgeManning Jan 6, 2021
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
Prev Previous commit
Next Next commit
make GossipsubConfig fields private + add getters + improve validatio…
…n in builder
  • Loading branch information
blacktemplar committed Jul 31, 2020
commit 66730dd83651556ed57d394088b080df7d11e2d3
2 changes: 1 addition & 1 deletion examples/gossipsub-chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.heartbeat_interval(Duration::from_secs(10))
.message_id_fn(message_id_fn) // content-address messages. No two messages of the
//same content will be propagated.
.build();
.build().expect("Valid config");
// build a gossipsub network behaviour
let mut gossipsub =
gossipsub::Gossipsub::new(MessageAuthenticity::Signed(local_key), gossipsub_config);
Expand Down
2 changes: 1 addition & 1 deletion examples/ipfs-private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut swarm = {
let gossipsub_config = GossipsubConfigBuilder::new()
.max_transmit_size(262144)
.build();
.build().expect("valid config");
let mut behaviour = MyBehaviour {
gossipsub: Gossipsub::new(
MessageAuthenticity::Signed(local_key.clone()),
Expand Down
99 changes: 50 additions & 49 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,34 +359,34 @@ impl Gossipsub {

// We do not allow configurations where a published message would also be rejected if it
// were received locally.
validate_config(&privacy, &config.validation_mode);
validate_config(&privacy, &config.validation_mode());

// Set up message publishing parameters.

Gossipsub {
events: VecDeque::new(),
control_pool: HashMap::new(),
publish_info: privacy.into(),
duplication_cache: LruCache::with_expiry_duration(config.duplicate_cache_time),
duplication_cache: LruCache::with_expiry_duration(config.duplicate_cache_time()),
topic_peers: HashMap::new(),
peer_topics: HashMap::new(),
explicit_peers: HashSet::new(),
mesh: HashMap::new(),
fanout: HashMap::new(),
fanout_last_pub: HashMap::new(),
backoffs: BackoffStorage::new(
&config.prune_backoff,
config.heartbeat_interval,
config.backoff_slack,
&config.prune_backoff(),
config.heartbeat_interval(),
config.backoff_slack(),
),
mcache: MessageCache::new(
config.history_gossip,
config.history_length,
config.message_id_fn,
config.history_gossip(),
config.history_length(),
config.message_id_fn(),
),
heartbeat: Interval::new_at(
Instant::now() + config.heartbeat_initial_delay,
config.heartbeat_interval,
Instant::now() + config.heartbeat_initial_delay(),
config.heartbeat_interval(),
),
heartbeat_ticks: 0,
config,
Expand Down Expand Up @@ -485,7 +485,7 @@ impl Gossipsub {
) -> Result<(), PublishError> {
let message =
self.build_message(topics.into_iter().map(|t| t.hash()).collect(), data.into())?;
let msg_id = (self.config.message_id_fn)(&message);
let msg_id = (self.config.message_id_fn())(&message);

// Add published message to the duplicate cache.
if self.duplication_cache.insert(msg_id.clone(), ()).is_some() {
Expand All @@ -504,11 +504,12 @@ impl Gossipsub {
debug!("Publishing message: {:?}", msg_id);

// If we are not flood publishing forward the message to mesh peers.
let mesh_peers_sent = !self.config.flood_publish && self.forward_msg(message.clone(), None);
let mesh_peers_sent =
!self.config.flood_publish() && self.forward_msg(message.clone(), None);

let mut recipient_peers = HashSet::new();
for topic_hash in &message.topics {
if self.config.flood_publish {
if self.config.flood_publish() {
//forward to all peers above score
if let Some(set) = self.topic_peers.get(&topic_hash) {
recipient_peers.extend(set.iter().map(|p| p.clone()));
Expand All @@ -524,7 +525,7 @@ impl Gossipsub {
}
} else {
// we have no fanout peers, select mesh_n of them and add them to the fanout
let mesh_n = self.config.mesh_n;
let mesh_n = self.config.mesh_n();
let new_peers =
Self::get_random_peers(&self.topic_peers, &topic_hash, mesh_n, {
|_| true
Expand Down Expand Up @@ -561,7 +562,7 @@ impl Gossipsub {
Ok(())
}

/// This function should be called when `config.validate_messages` is `true` in order to
/// This function should be called when `config.validate_messages()` is `true` in order to
/// validate and propagate messages. Messages are stored in the ['Memcache'] and validation is expected to be
/// fast enough that the messages should still exist in the cache.
///
Expand Down Expand Up @@ -636,7 +637,7 @@ impl Gossipsub {

// add up to mesh_n of them them to the mesh
// Note: These aren't randomly added, currently FIFO
let add_peers = std::cmp::min(peers.len(), self.config.mesh_n);
let add_peers = std::cmp::min(peers.len(), self.config.mesh_n());
debug!(
"JOIN: Adding {:?} peers from the fanout for topic: {:?}",
add_peers, topic_hash
Expand All @@ -651,12 +652,12 @@ impl Gossipsub {
}

// check if we need to get more peers, which we randomly select
if added_peers.len() < self.config.mesh_n {
if added_peers.len() < self.config.mesh_n() {
// get the peers
let new_peers = Self::get_random_peers(
&self.topic_peers,
topic_hash,
self.config.mesh_n - added_peers.len(),
self.config.mesh_n() - added_peers.len(),
|peer| !added_peers.contains(peer) && !self.explicit_peers.contains(peer),
);
added_peers.extend(new_peers.clone());
Expand Down Expand Up @@ -695,7 +696,7 @@ impl Gossipsub {
//TODO check the receving peers version and if not 1.1 do not send any exchange peers
//select peers for peer exchange
let peers = if do_px {
Self::get_random_peers(&self.topic_peers, &topic_hash, self.config.prune_peers, {
Self::get_random_peers(&self.topic_peers, &topic_hash, self.config.prune_peers(), {
|p| p != peer //TODO score threshold
})
.into_iter()
Expand All @@ -707,12 +708,12 @@ impl Gossipsub {

//update backoff
self.backoffs
.update_backoff(topic_hash, peer, self.config.prune_backoff);
.update_backoff(topic_hash, peer, self.config.prune_backoff());

GossipsubControlAction::Prune {
topic_hash: topic_hash.clone(),
peers,
backoff: Some(self.config.prune_backoff.as_secs()),
backoff: Some(self.config.prune_backoff().as_secs()),
}
}

Expand All @@ -725,7 +726,7 @@ impl Gossipsub {
for peer in peers {
// Send a PRUNE control message
info!("LEAVE: Sending PRUNE to peer: {:?}", peer);
let control = self.make_prune(topic_hash, &peer, self.config.do_px);
let control = self.make_prune(topic_hash, &peer, self.config.do_px());
Self::control_pool_add(&mut self.control_pool, peer.clone(), control);
}
}
Expand Down Expand Up @@ -820,7 +821,7 @@ impl Gossipsub {

let mut to_prune_topics = HashSet::new();

let mut do_px = self.config.do_px;
let mut do_px = self.config.do_px();

// we don't GRAFT to/from explicit peers; complain loudly if this happens
if self.explicit_peers.contains(peer_id) {
Expand Down Expand Up @@ -911,7 +912,7 @@ impl Gossipsub {
if let Some(backoff) = backoff {
Duration::from_secs(backoff)
} else {
self.config.prune_backoff
self.config.prune_backoff()
},
);

Expand All @@ -926,7 +927,7 @@ impl Gossipsub {
}

fn px_connect(&mut self, mut px: Vec<PeerInfo>) {
let n = self.config.prune_peers;
let n = self.config.prune_peers();
//ignore peerInfo with no ID
//TODO can we use peerInfo without any IDs if they have a signed peer record?
px = px.into_iter().filter(|p| p.peer.is_some()).collect();
Expand All @@ -953,7 +954,7 @@ impl Gossipsub {
/// Handles a newly received GossipsubMessage.
/// Forwards the message to all peers in the mesh.
fn handle_received_message(&mut self, mut msg: GossipsubMessage, propagation_source: &PeerId) {
let msg_id = (self.config.message_id_fn)(&msg);
let msg_id = (self.config.message_id_fn())(&msg);
debug!(
"Handling message: {:?} from peer: {}",
msg_id,
Expand All @@ -963,7 +964,7 @@ impl Gossipsub {
// If we are not validating messages, assume this message is validated
// This will allow the message to be gossiped without explicitly calling
// `validate_message`.
if !self.config.validate_messages {
if !self.config.validate_messages() {
msg.validated = true;
}

Expand All @@ -983,8 +984,8 @@ impl Gossipsub {
}

// forward the message to mesh peers, if no validation is required
if !self.config.validate_messages {
let message_id = (self.config.message_id_fn)(&msg);
if !self.config.validate_messages() {
let message_id = (self.config.message_id_fn())(&msg);
self.forward_msg(msg, Some(propagation_source));
debug!("Completed message handling for message: {:?}", message_id);
}
Expand Down Expand Up @@ -1041,7 +1042,7 @@ impl Gossipsub {
// if the mesh needs peers add the peer to the mesh
if !self.explicit_peers.contains(propagation_source) {
if let Some(peers) = self.mesh.get_mut(&subscription.topic_hash) {
if peers.len() < self.config.mesh_n_low {
if peers.len() < self.config.mesh_n_low() {
if peers.insert(propagation_source.clone()) {
debug!(
"SUBSCRIPTION: Adding peer {} to the mesh for topic {:?}",
Expand Down Expand Up @@ -1133,7 +1134,7 @@ impl Gossipsub {
self.backoffs.heartbeat();

//check connections to explicit peers
if self.heartbeat_ticks % self.config.check_explicit_peers_ticks == 0 {
if self.heartbeat_ticks % self.config.check_explicit_peers_ticks() == 0 {
for p in self.explicit_peers.clone() {
self.check_explicit_peer_connection(&p);
}
Expand All @@ -1143,15 +1144,15 @@ impl Gossipsub {
let explicit_peers = &self.explicit_peers;
for (topic_hash, peers) in self.mesh.iter_mut() {
// too little peers - add some
if peers.len() < self.config.mesh_n_low {
if peers.len() < self.config.mesh_n_low() {
debug!(
"HEARTBEAT: Mesh low. Topic: {} Contains: {} needs: {}",
topic_hash,
peers.len(),
self.config.mesh_n_low
self.config.mesh_n_low()
);
// not enough peers - get mesh_n - current_length more
let desired_peers = self.config.mesh_n - peers.len();
let desired_peers = self.config.mesh_n() - peers.len();
let backoffs = &self.backoffs;
let peer_list =
Self::get_random_peers(&self.topic_peers, topic_hash, desired_peers, {
Expand All @@ -1171,14 +1172,14 @@ impl Gossipsub {
}

// too many peers - remove some
if peers.len() > self.config.mesh_n_high {
if peers.len() > self.config.mesh_n_high() {
debug!(
"HEARTBEAT: Mesh high. Topic: {} Contains: {} needs: {}",
topic_hash,
peers.len(),
self.config.mesh_n_high
self.config.mesh_n_high()
);
let excess_peer_no = peers.len() - self.config.mesh_n;
let excess_peer_no = peers.len() - self.config.mesh_n();
// shuffle the peers
let mut rng = thread_rng();
let mut shuffled = peers.iter().cloned().collect::<Vec<_>>();
Expand All @@ -1198,7 +1199,7 @@ impl Gossipsub {
// remove expired fanout topics
{
let fanout = &mut self.fanout; // help the borrow checker
let fanout_ttl = self.config.fanout_ttl;
let fanout_ttl = self.config.fanout_ttl();
self.fanout_last_pub.retain(|topic_hash, last_pub_time| {
if *last_pub_time + fanout_ttl < Instant::now() {
debug!(
Expand Down Expand Up @@ -1239,13 +1240,13 @@ impl Gossipsub {
}

// not enough peers
if peers.len() < self.config.mesh_n {
if peers.len() < self.config.mesh_n() {
debug!(
"HEARTBEAT: Fanout low. Contains: {:?} needs: {:?}",
peers.len(),
self.config.mesh_n
self.config.mesh_n()
);
let needed_peers = self.config.mesh_n - peers.len();
let needed_peers = self.config.mesh_n() - peers.len();
let new_peers =
Self::get_random_peers(&self.topic_peers, topic_hash, needed_peers, |peer| {
!peers.contains(peer)
Expand Down Expand Up @@ -1282,8 +1283,8 @@ impl Gossipsub {
// dynamic number of peers to gossip based on `gossip_factor` with minimum `gossip_lazy`
let n_map = |m| {
max(
self.config.gossip_lazy,
(self.config.gossip_factor * m as f64) as usize,
self.config.gossip_lazy(),
(self.config.gossip_factor() * m as f64) as usize,
)
};
// get gossip_lazy random peers
Expand Down Expand Up @@ -1328,7 +1329,7 @@ impl Gossipsub {
if let Some(topics) = to_prune.remove(peer) {
let mut prunes = topics
.iter()
.map(|topic_hash| self.make_prune(topic_hash, peer, self.config.do_px))
.map(|topic_hash| self.make_prune(topic_hash, peer, self.config.do_px()))
.collect::<Vec<_>>();
control_msgs.append(&mut prunes);
}
Expand All @@ -1348,7 +1349,7 @@ impl Gossipsub {
for (peer, topics) in to_prune.iter() {
let remaining_prunes = topics
.iter()
.map(|topic_hash| self.make_prune(topic_hash, peer, self.config.do_px))
.map(|topic_hash| self.make_prune(topic_hash, peer, self.config.do_px()))
.collect();
self.send_message(
peer.clone(),
Expand All @@ -1364,7 +1365,7 @@ impl Gossipsub {
/// Helper function which forwards a message to mesh\[topic\] peers.
/// Returns true if at least one peer was messaged.
fn forward_msg(&mut self, message: GossipsubMessage, source: Option<&PeerId>) -> bool {
let msg_id = (self.config.message_id_fn)(&message);
let msg_id = (self.config.message_id_fn())(&message);
debug!("Forwarding message: {:?}", msg_id);
let mut recipient_peers = HashSet::new();

Expand Down Expand Up @@ -1589,9 +1590,9 @@ impl NetworkBehaviour for Gossipsub {

fn new_handler(&mut self) -> Self::ProtocolsHandler {
GossipsubHandler::new(
self.config.protocol_id_prefix.clone(),
self.config.max_transmit_size,
self.config.validation_mode.clone(),
self.config.protocol_id_prefix().clone(),
self.config.max_transmit_size(),
self.config.validation_mode().clone(),
)
}

Expand Down
Loading