Skip to content

Commit 41d6206

Browse files
committed
fix format
1 parent dcc7334 commit 41d6206

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

p2p/src/behaviour.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use std::collections::hash_map;
22
use std::hash::{Hash, Hasher};
33
use std::time::Duration;
44

5+
use eyre::{eyre, Result};
56
use libp2p::identity::{Keypair, PeerId, PublicKey};
67
use libp2p::kad::store::MemoryStore;
78
use libp2p::StreamProtocol;
89
use libp2p::{autonat, dcutr, gossipsub, identify, kad, relay};
9-
use eyre::{eyre, Result};
1010

1111
#[derive(libp2p::swarm::NetworkBehaviour)]
1212
pub struct DriaBehaviour {
@@ -43,7 +43,7 @@ impl DriaBehaviour {
4343
fn create_kademlia_behavior(
4444
local_peer_id: PeerId,
4545
protocol_name: StreamProtocol,
46-
) -> kad::Behaviour<MemoryStore>{
46+
) -> kad::Behaviour<MemoryStore> {
4747
use kad::{Behaviour, Config};
4848

4949
const QUERY_TIMEOUT_SECS: u64 = 5 * 60;
@@ -140,29 +140,27 @@ fn create_gossipsub_behavior(author: PeerId) -> Result<gossipsub::Behaviour> {
140140

141141
// TODO: add data transform here later
142142
let config = match ConfigBuilder::default()
143-
.heartbeat_interval(Duration::from_secs(HEARTBEAT_INTERVAL_SECS))
144-
.max_transmit_size(MAX_TRANSMIT_SIZE)
145-
.message_id_fn(message_id_fn)
146-
.message_capacity(MESSAGE_CAPACITY)
147-
.message_ttl(Duration::from_secs(MESSAGE_TTL_SECS))
148-
.gossip_ttl(Duration::from_secs(GOSSIP_TTL_SECS))
149-
.duplicate_cache_time(Duration::from_secs(DUPLICATE_CACHE_TIME_SECS))
150-
.max_ihave_length(MAX_IHAVE_LENGTH)
151-
.send_queue_size(MAX_SEND_QUEUE_SIZE)
152-
.validation_mode(VALIDATION_MODE)
153-
.validate_messages()
154-
.build() {
143+
.heartbeat_interval(Duration::from_secs(HEARTBEAT_INTERVAL_SECS))
144+
.max_transmit_size(MAX_TRANSMIT_SIZE)
145+
.message_id_fn(message_id_fn)
146+
.message_capacity(MESSAGE_CAPACITY)
147+
.message_ttl(Duration::from_secs(MESSAGE_TTL_SECS))
148+
.gossip_ttl(Duration::from_secs(GOSSIP_TTL_SECS))
149+
.duplicate_cache_time(Duration::from_secs(DUPLICATE_CACHE_TIME_SECS))
150+
.max_ihave_length(MAX_IHAVE_LENGTH)
151+
.send_queue_size(MAX_SEND_QUEUE_SIZE)
152+
.validation_mode(VALIDATION_MODE)
153+
.validate_messages()
154+
.build()
155+
{
155156
Ok(config) => config,
156157
Err(e) => {
157158
return Err(eyre!("Failed to create gossipsub config: {}", e));
158159
}
159160
};
160161

161-
match Behaviour::new(
162-
MessageAuthenticity::Author(author),
163-
config
164-
) {
165-
Ok(behaviour) => Ok(behaviour),
166-
Err(e) => Err(eyre!("Failed to create gossipsub behaviour: {}", e)),
167-
}
162+
match Behaviour::new(MessageAuthenticity::Author(author), config) {
163+
Ok(behaviour) => Ok(behaviour),
164+
Err(e) => Err(eyre!("Failed to create gossipsub behaviour: {}", e)),
165+
}
168166
}

p2p/src/client.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::*;
2-
use eyre::{eyre, Result};
2+
use eyre::Result;
33
use libp2p::futures::StreamExt;
44
use libp2p::gossipsub::{
55
Message, MessageAcceptance, MessageId, PublishError, SubscriptionError, TopicHash,
@@ -78,7 +78,8 @@ impl DriaP2PClient {
7878
relay_behavior,
7979
identity_protocol.clone(),
8080
kademlia_protocol.clone(),
81-
).unwrap()
81+
)
82+
.unwrap()
8283
})?
8384
.with_swarm_config(|c| {
8485
c.with_idle_connection_timeout(Duration::from_secs(IDLE_CONNECTION_TIMEOUT_SECS))
@@ -135,7 +136,8 @@ impl DriaP2PClient {
135136
identity_protocol,
136137
kademlia_protocol,
137138
})
138-
} /// Subscribe to a topic.
139+
}
140+
/// Subscribe to a topic.
139141
pub fn subscribe(&mut self, topic_name: &str) -> Result<bool, SubscriptionError> {
140142
log::debug!("Subscribing to {}", topic_name);
141143

0 commit comments

Comments
 (0)