Skip to content

Commit

Permalink
chore: fmt & clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Jan 22, 2024
1 parent 8b8d498 commit 670c4e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 9 additions & 6 deletions crates/torii/libp2p/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ use std::time::Duration;

use futures::StreamExt;
use libp2p::core::multiaddr::Protocol;
use libp2p::core::muxing::StreamMuxerBox;
use libp2p::core::Multiaddr;
use libp2p::gossipsub::{self, IdentTopic};
use libp2p::swarm::{NetworkBehaviour, SwarmEvent};
use libp2p::{
core::muxing::StreamMuxerBox, identify, identity, noise, ping, relay, tcp, yamux,
Swarm, Transport,
};
use libp2p::{identify, identity, noise, ping, relay, tcp, yamux, Swarm, Transport};
use libp2p_webrtc as webrtc;
use rand::thread_rng;
use tracing::info;
Expand Down Expand Up @@ -51,7 +49,8 @@ impl Libp2pRelay {
webrtc::tokio::Certificate::generate(&mut thread_rng())?,
)
.map(|(peer_id, conn), _| (peer_id, StreamMuxerBox::new(conn))))
}).expect("Failed to create WebRTC transport")
})
.expect("Failed to create WebRTC transport")
.with_behaviour(|key| {
let message_id_fn = |message: &gossipsub::Message| {
let mut s = DefaultHasher::new();
Expand Down Expand Up @@ -119,7 +118,11 @@ impl Libp2pRelay {
let message: ClientMessage = serde_json::from_slice(&message.data)
.expect("Failed to deserialize message");

info!("Received message {:?} from peer {:?} with topic {:?} and data {:?}", message_id, peer_id, message.topic, message.data);
info!(
"Received message {:?} from peer {:?} with topic {:?} and data \
{:?}",
message_id, peer_id, message.topic, message.data
);

// forward message to room
let server_message =
Expand Down
4 changes: 1 addition & 3 deletions crates/torii/libp2p/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ mod test {
// This tests subscribing to a topic and receiving a message
#[tokio::test]
async fn test_client_messaging() -> Result<(), Box<dyn Error>> {
let _ = tracing_subscriber::fmt()
.with_env_filter("torii_libp2p=debug")
.try_init();
let _ = tracing_subscriber::fmt().with_env_filter("torii_libp2p=debug").try_init();
// Initialize the relay server
let mut relay_server: Libp2pRelay = Libp2pRelay::new(1010, 2020)?;

Expand Down

0 comments on commit 670c4e5

Please sign in to comment.