From 45420bfacad5c0b82280f1b5a7f45bcd6d5f2a3f Mon Sep 17 00:00:00 2001 From: Fico <70634661+fbozic@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:01:12 +0200 Subject: [PATCH] fix: remove success logs when rendezvous discovery fails due to no external addrs (#16) * fix: remove success logs when rendezvous discovery is failed due to no external addrs * chore: bump version --- Cargo.lock | 2 +- examples/chat/Cargo.toml | 2 +- examples/chat/README.md | 4 ++-- examples/chat/src/network/discovery.rs | 4 +++- examples/chat/src/network/events.rs | 6 +----- examples/chat/src/network/events/gossipsub.rs | 8 ++------ examples/chat/src/network/types.rs | 5 +---- 7 files changed, 11 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5f62d7..df120bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -454,7 +454,7 @@ dependencies = [ [[package]] name = "chat-example" -version = "0.4.0" +version = "0.5.0" dependencies = [ "bytes", "clap", diff --git a/examples/chat/Cargo.toml b/examples/chat/Cargo.toml index 4c6c624..23c52c2 100644 --- a/examples/chat/Cargo.toml +++ b/examples/chat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chat-example" -version = "0.4.0" +version = "0.5.0" authors = ["Calimero Limited "] edition = "2021" repository = "https://github.com/calimero-network/boot-node" diff --git a/examples/chat/README.md b/examples/chat/README.md index d400e6f..6a7e5c2 100644 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -8,12 +8,12 @@ This examples show cases how to build chat application with DCUtR, mDNS, Relay, ## Run Run first chat session in interactive mode with remote peer dial. ``` -cargo run -p chat-example -- --mode interactive --port 4002 --secret-key-seed 102 --gossip-topic-names calimero-network/examples/chat/v0.0.2 --boot-nodes /ip4/35.156.78.13/udp/4001/quic-v1/p2p/12D3KooWRnt7EmBwrNALhAXAgM151MdH7Ka9tvYS91ZUqnqwpjVg +cargo run -p chat-example -- --mode interactive --port 4002 --secret-key-seed 102 --gossip-topic-names calimero-network/examples/chat/v0.0.2 --boot-nodes /ip4/18.156.18.6/udp/4001/quic-v1/p2p/12D3KooWMgoF9xzyeKJHtRvrYwdomheRbHPELagWZwTLmXb6bCVC ``` Run second chat session in interactive mode with remote peer dial. ``` -cargo run -p chat-example -- --mode interactive --port 4003 --secret-key-seed 103 --gossip-topic-names calimero-network/examples/chat/v0.0.2 --boot-nodes /ip4/35.156.78.13/udp/4001/quic-v1/p2p/12D3KooWRnt7EmBwrNALhAXAgM151MdH7Ka9tvYS91ZUqnqwpjVg +cargo run -p chat-example -- --mode interactive --port 4003 --secret-key-seed 103 --gossip-topic-names calimero-network/examples/chat/v0.0.2 --boot-nodes /ip4/18.156.18.6/udp/4001/quic-v1/p2p/12D3KooWMgoF9xzyeKJHtRvrYwdomheRbHPELagWZwTLmXb6bCVC ``` In any interactive session publish new message manually: diff --git a/examples/chat/src/network/discovery.rs b/examples/chat/src/network/discovery.rs index 8e3d6e1..2fd3e4b 100644 --- a/examples/chat/src/network/discovery.rs +++ b/examples/chat/src/network/discovery.rs @@ -166,7 +166,9 @@ impl EventLoop { None, ) { match err { - libp2p::rendezvous::client::RegisterError::NoExternalAddresses => {} + libp2p::rendezvous::client::RegisterError::NoExternalAddresses => { + return Ok(()); + } err => eyre::bail!(err), } } diff --git a/examples/chat/src/network/events.rs b/examples/chat/src/network/events.rs index 95a7ff7..8a2a876 100644 --- a/examples/chat/src/network/events.rs +++ b/examples/chat/src/network/events.rs @@ -31,15 +31,11 @@ impl EventLoop { } BehaviourEvent::Stream(()) => {} }, - SwarmEvent::NewListenAddr { - listener_id, - address, - } => { + SwarmEvent::NewListenAddr { address, .. } => { let local_peer_id = *self.swarm.local_peer_id(); if let Err(err) = self .event_sender .send(types::NetworkEvent::ListeningOn { - listener_id, address: address.with(multiaddr::Protocol::P2p(local_peer_id)), }) .await diff --git a/examples/chat/src/network/events/gossipsub.rs b/examples/chat/src/network/events/gossipsub.rs index b235a7f..027fdee 100644 --- a/examples/chat/src/network/events/gossipsub.rs +++ b/examples/chat/src/network/events/gossipsub.rs @@ -9,14 +9,10 @@ impl EventHandler for EventLoop { debug!("{}: {:?}", "gossipsub".yellow(), event); match event { - gossipsub::Event::Message { - message_id: id, - message, - .. - } => { + gossipsub::Event::Message { message, .. } => { if let Err(err) = self .event_sender - .send(types::NetworkEvent::Message { id, message }) + .send(types::NetworkEvent::Message { message }) .await { error!("Failed to send message event: {:?}", err); diff --git a/examples/chat/src/network/types.rs b/examples/chat/src/network/types.rs index 0219714..eabefbf 100644 --- a/examples/chat/src/network/types.rs +++ b/examples/chat/src/network/types.rs @@ -1,5 +1,4 @@ -use libp2p::core::transport; -pub use libp2p::gossipsub::{Message, MessageId, TopicHash}; +pub use libp2p::gossipsub::{Message, TopicHash}; pub use libp2p::identity::PeerId; use super::stream; @@ -7,7 +6,6 @@ use super::stream; #[derive(Debug)] pub enum NetworkEvent { ListeningOn { - listener_id: transport::ListenerId, address: libp2p::Multiaddr, }, Subscribed { @@ -15,7 +13,6 @@ pub enum NetworkEvent { topic: TopicHash, }, Message { - id: MessageId, message: Message, }, StreamOpened {