Skip to content

Commit

Permalink
fix: remove duplicated certificate push on gossipsub (#458)
Browse files Browse the repository at this point in the history
Signed-off-by: Monir Hadji <hadji.szs@gmail.com>
Co-authored-by: David <dvdplm@gmail.com>
  • Loading branch information
hadjiszs and dvdplm authored Feb 16, 2024
1 parent 2aaa500 commit b0e88dc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/topos-p2p/src/behaviour/gossip.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::{
collections::{HashMap, HashSet, VecDeque},
env,
Expand Down Expand Up @@ -35,7 +37,9 @@ impl Behaviour {
) -> Result<usize, &'static str> {
match topic {
TOPOS_GOSSIP => {
_ = self.gossipsub.publish(IdentTopic::new(topic), message);
if let Ok(msg_id) = self.gossipsub.publish(IdentTopic::new(topic), message) {
debug!("Published on topos_gossip: {:?}", msg_id);
}
}
TOPOS_ECHO | TOPOS_READY => self.pending.entry(topic).or_default().push_back(message),
_ => return Err("Invalid topic"),
Expand Down Expand Up @@ -68,6 +72,12 @@ impl Behaviour {
let gossipsub = gossipsub::ConfigBuilder::default()
.max_transmit_size(2 * 1024 * 1024)
.validation_mode(gossipsub::ValidationMode::Strict)
.message_id_fn(|msg_id| {
// Content based id
let mut s = DefaultHasher::new();
msg_id.data.hash(&mut s);
gossipsub::MessageId::from(s.finish().to_be_bytes())
})
.build()
.unwrap();

Expand Down

0 comments on commit b0e88dc

Please sign in to comment.