@@ -245,7 +245,7 @@ pub enum Event {
245245 dst_peer_id : PeerId ,
246246 error : Option < std:: io:: Error > ,
247247 } ,
248- /// Status has been changed.
248+ /// Own [`Status`] changed.
249249 ///
250250 /// This is triggered based on if the external address
251251 /// has been added or removed.
@@ -267,19 +267,22 @@ pub struct Behaviour {
267267
268268 external_addresses : ExternalAddresses ,
269269
270- status : Status ,
271-
270+ /// Advertisement status.
271+ status : Status .
272272 auto_status_change : bool ,
273273
274274 waker : Option < Waker > ,
275275}
276-
276+ /// Own relay server advertisement status.
277277#[ derive( PartialEq , Copy , Clone , Debug ) ]
278278pub enum Status {
279- /// Enables advertisement of the HOP protocol
279+ /// Enables advertisement of the HOP protocol.
280+ /// This allows other nodes to use us a relay server.
280281 Enable ,
281282
282- /// Disables advertisement of the HOP protocol
283+ /// Disables advertisement of the HOP protocol.
284+ /// New nodes won't be able to use us a relay server anymore.
285+ /// Existing circuits are kept alive until they time out.
283286 Disable ,
284287}
285288
@@ -296,6 +299,11 @@ impl Reservation {
296299}
297300
298301impl Behaviour {
302+ /// Create a new relay server behavior.
303+ ///
304+ /// By default, the node with determine its advertisement [`Status`] automatically
305+ /// based on info about its own external addresses.
306+ /// Alternatively, the advertisement status can be fixed with [`Behavior::set_status`].
299307 pub fn new ( local_peer_id : PeerId , config : Config ) -> Self {
300308 Self {
301309 config,
@@ -310,6 +318,10 @@ impl Behaviour {
310318 }
311319 }
312320
321+ /// Sets the advertisement status of the local node as relay server.
322+ ///
323+ /// If the `status` is set to `None`, the node will configure its status automatically
324+ /// depending on whether it has any external addresses or not.
313325 pub fn set_status ( & mut self , status : Option < Status > ) {
314326 match status {
315327 Some ( status) => {
0 commit comments