feat: switch to a single routability event

This means we can make the event _stateful_ so subscribing always gives us the
last state.
This commit is contained in:
Steven Allen 2020-03-04 11:29:42 -08:00
parent bcf3ad5c24
commit 8157087fc9
2 changed files with 26 additions and 16 deletions

View File

@ -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{}
import (
"github.com/libp2p/go-libp2p-core/network"
)
// 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).
// 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 EvtLocalRoutabilityPublic struct{}
// 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).
//
// This event is usually emitted by the AutoNAT subsystem.
type EvtLocalRoutabilityUnknown struct{}
type EvtLocalRoutability struct {
Routability network.Routability
}

View File

@ -53,6 +53,24 @@ const (
CannotConnect
)
// Routability indicates how reachable a node is.
type Routability int
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