@@ -2,11 +2,11 @@ use std::collections::hash_map;
2
2
use std:: hash:: { Hash , Hasher } ;
3
3
use std:: time:: Duration ;
4
4
5
+ use eyre:: { eyre, Result } ;
5
6
use libp2p:: identity:: { Keypair , PeerId , PublicKey } ;
6
7
use libp2p:: kad:: store:: MemoryStore ;
7
8
use libp2p:: StreamProtocol ;
8
9
use libp2p:: { autonat, dcutr, gossipsub, identify, kad, relay} ;
9
- use eyre:: { eyre, Result } ;
10
10
11
11
#[ derive( libp2p:: swarm:: NetworkBehaviour ) ]
12
12
pub struct DriaBehaviour {
@@ -43,7 +43,7 @@ impl DriaBehaviour {
43
43
fn create_kademlia_behavior (
44
44
local_peer_id : PeerId ,
45
45
protocol_name : StreamProtocol ,
46
- ) -> kad:: Behaviour < MemoryStore > {
46
+ ) -> kad:: Behaviour < MemoryStore > {
47
47
use kad:: { Behaviour , Config } ;
48
48
49
49
const QUERY_TIMEOUT_SECS : u64 = 5 * 60 ;
@@ -140,29 +140,27 @@ fn create_gossipsub_behavior(author: PeerId) -> Result<gossipsub::Behaviour> {
140
140
141
141
// TODO: add data transform here later
142
142
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
+ {
155
156
Ok ( config) => config,
156
157
Err ( e) => {
157
158
return Err ( eyre ! ( "Failed to create gossipsub config: {}" , e) ) ;
158
159
}
159
160
} ;
160
161
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
+ }
168
166
}
0 commit comments