@@ -5,7 +5,7 @@ use libp2p::{
5
5
core:: muxing:: StreamMuxerBox ,
6
6
gossipsub, identify, identity,
7
7
multiaddr:: Protocol ,
8
- ping,
8
+ ping, relay ,
9
9
swarm:: { keep_alive, NetworkBehaviour , Swarm , SwarmBuilder , SwarmEvent } ,
10
10
Multiaddr , PeerId , Transport ,
11
11
} ;
@@ -59,6 +59,9 @@ async fn main() -> Result<()> {
59
59
SwarmEvent :: ConnectionClosed { peer_id, cause, .. } => {
60
60
warn ! ( "Connection to {peer_id} closed: {cause:?}" ) ;
61
61
}
62
+ SwarmEvent :: Behaviour ( BehaviourEvent :: Relay ( e) ) => {
63
+ info ! ( "{:?}" , e) ;
64
+ }
62
65
SwarmEvent :: Behaviour ( BehaviourEvent :: Gossipsub (
63
66
libp2p:: gossipsub:: Event :: Message {
64
67
message_id : _,
@@ -104,6 +107,7 @@ struct Behaviour {
104
107
// kademlia: Kademlia<MemoryStore>,
105
108
keep_alive : keep_alive:: Behaviour ,
106
109
ping : ping:: Behaviour ,
110
+ relay : relay:: Behaviour ,
107
111
}
108
112
109
113
fn create_swarm ( ) -> Result < Swarm < Behaviour > > {
@@ -160,6 +164,7 @@ fn create_swarm() -> Result<Swarm<Behaviour>> {
160
164
identify : identify_config,
161
165
keep_alive : keep_alive:: Behaviour :: default ( ) ,
162
166
ping : ping:: Behaviour :: default ( ) ,
167
+ relay : relay:: Behaviour :: new ( local_peer_id, Default :: default ( ) ) ,
163
168
} ;
164
169
Ok ( SwarmBuilder :: with_tokio_executor ( transport, behaviour, local_peer_id) . build ( ) )
165
170
}
0 commit comments