Skip to content

Commit

Permalink
fix: remove success logs when rendezvous discovery fails due to no ex…
Browse files Browse the repository at this point in the history
…ternal addrs (#16)

* fix: remove success logs when rendezvous discovery is failed due to no external addrs

* chore: bump version
  • Loading branch information
fbozic authored Jul 17, 2024
1 parent 83d1f64 commit 45420bf
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/chat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chat-example"
version = "0.4.0"
version = "0.5.0"
authors = ["Calimero Limited <[email protected]>"]
edition = "2021"
repository = "https://github.com/calimero-network/boot-node"
Expand Down
4 changes: 2 additions & 2 deletions examples/chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion examples/chat/src/network/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand Down
6 changes: 1 addition & 5 deletions examples/chat/src/network/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions examples/chat/src/network/events/gossipsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ impl EventHandler<gossipsub::Event> 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);
Expand Down
5 changes: 1 addition & 4 deletions examples/chat/src/network/types.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
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;

#[derive(Debug)]
pub enum NetworkEvent {
ListeningOn {
listener_id: transport::ListenerId,
address: libp2p::Multiaddr,
},
Subscribed {
peer_id: PeerId,
topic: TopicHash,
},
Message {
id: MessageId,
message: Message,
},
StreamOpened {
Expand Down

0 comments on commit 45420bf

Please sign in to comment.