Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
fix: adjusting
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberb committed Mar 22, 2024
1 parent faa5211 commit 4c5f3b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
22 changes: 6 additions & 16 deletions crates/topos-p2p/src/behaviour/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
time::Duration,
};

use libp2p::gossipsub::{MessageId, PublishError};
use libp2p::gossipsub::MessageId;
use libp2p::swarm::{ConnectionClosed, FromSwarm};
use libp2p::PeerId;
use libp2p::{
Expand Down Expand Up @@ -44,7 +44,7 @@ impl Behaviour {
&mut self,
topic: &'static str,
message: Vec<u8>,
) -> Result<MessageId, PublishError> {
) -> Result<MessageId, &'static str> {
println!("Publishing {} {}", message.len(), topic);
debug!("Publishing {} {}", message.len(), topic);
match topic {
Expand All @@ -66,22 +66,12 @@ impl Behaviour {
return Ok(msg_id);
}
}
_ => {}
_ => {
return Err("Unknown topic");
}
}

let messag_id = MessageId::new(&[0]);
// match topic {
// TOPOS_GOSSIP => {
// if let Ok(msg_id) = self.gossipsub.publish(IdentTopic::new(topic), message) {
// messag_id = msg_id.clone();
// debug!("Published on topos_gossip: {:?}", msg_id);
// }
// }
// TOPOS_ECHO | TOPOS_READY => self.pending.entry(topic).or_default().push_back(message),
// _ => (),
// }

Ok(messag_id)
Err("Failed to publish")
}

pub fn subscribe(&mut self) -> Result<(), P2PError> {
Expand Down
3 changes: 2 additions & 1 deletion crates/topos-tce/src/app_context/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use libp2p::gossipsub::MessageId;
use tokio::sync::oneshot;
use topos_core::api::grpc::tce::v1::{double_echo_request, DoubleEchoRequest, Echo, Gossip, Ready};
use topos_tce_broadcast::event::ProtocolEvents;
Expand Down Expand Up @@ -33,7 +34,7 @@ impl AppContext {
error!("Unable to send Gossip: {e}");
}

let message_id = receiver.await.unwrap();
let message_id = receiver.await.unwrap_or(MessageId::from([0; 32]));

debug!(
"Send Gossip for certificate {} with message id {}",
Expand Down

0 comments on commit 4c5f3b8

Please sign in to comment.