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 1 commit
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
24 changes: 8 additions & 16 deletions event/routability.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
package event

// EvtLocalRoutabilityPrivate is an event struct to be emitted with the local's
// node routability changes to PRIVATE (i.e. not routable from the Internet).
//
// This event is usually emitted by the AutoNAT subsystem.
type EvtLocalRoutabilityPrivate struct{}

// EvtLocalRoutabilityPublic is an event struct to be emitted with the local's
// node routability changes to PUBLIC (i.e. appear to routable from the
// Internet).
//
// This event is usually emitted by the AutoNAT subsystem.
type EvtLocalRoutabilityPublic struct{}
import (
"github.com/libp2p/go-libp2p-core/network"
)

// EvtLocalRoutabilityUnknown is an event struct to be emitted with the local's
// node routability changes to UNKNOWN (i.e. we were unable to make a
// determination about our NAT status with enough confidence).
// EvtLocalRoutability is an event struct to be emitted with the local's node
// routability changes state.
//
// This event is usually emitted by the AutoNAT subsystem.
type EvtLocalRoutabilityUnknown struct{}
type EvtLocalRoutability struct {
Stebalien marked this conversation as resolved.
Show resolved Hide resolved
Routability network.Routability
}
18 changes: 18 additions & 0 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ const (
CannotConnect
)

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

Choose a reason for hiding this comment

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

worth making this a byte?

Copy link
Contributor

Choose a reason for hiding this comment

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

@willscott What's the advantage of making this a byte ? Saving space ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@willscott What's the advantage of making this a byte ? Saving space ?

Right. Could potentially allow for better packing

Copy link
Member

Choose a reason for hiding this comment

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

I'd support it.

Copy link
Member Author

Choose a reason for hiding this comment

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

No real reason not to.

Copy link
Member Author

@Stebalien Stebalien Mar 4, 2020

Choose a reason for hiding this comment

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

Hm, well, except for consistency with Connectedness, Direction, and most other enums.


const (
// RoutabilityUnknown indicates that the routability status is unknown.
RoutabilityUnknown = iota

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

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

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