Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Switch to a single routability event #126

Merged
merged 2 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions event/reachability.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package event

import (
"github.com/libp2p/go-libp2p-core/network"
)

// EvtLocalReachabilityChanged is an event struct to be emitted when the local's
// node reachability changes state.
//
// This event is usually emitted by the AutoNAT subsystem.
type EvtLocalReachabilityChanged struct {
Reachability network.Reachability
}
21 changes: 0 additions & 21 deletions event/routability.go

This file was deleted.

19 changes: 19 additions & 0 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ const (
CannotConnect
)

// Reachability indicates how reachable a node is.
type Reachability int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for clarification is the reason we're put the enum in the network package instead of the event package because we're hoping reachability will be more general than just the EvtLocalReachabilityChanged event?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Basically, it's not specific to the event itself.


const (
// ReachabilityUnknown indicates that the reachability status of the
// node is unknown.
ReachabilityUnknown = iota

// ReachabilityPublic indicates that the node is reachable from the
// public internet.
ReachabilityPublic

// ReachabilityPrivate indicates that the node is not reachable from the
// public internet.
//
// NOTE: This node may _still_ be reachable via relays.
ReachabilityPrivate
)

// Stat stores metadata pertaining to a given Stream/Conn.
type Stat struct {
Direction Direction
Expand Down