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

Commit

Permalink
fix: a type switch nit
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Apr 30, 2020
1 parent ee3e1b3 commit f022e9f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions autonat.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (as *AmbientAutoNAT) background() {
}

case e := <-subChan:
switch e.(type) {
switch e := e.(type) {
case event.EvtLocalAddressesUpdated:
if !lastAddrUpdated.Add(time.Second).After(time.Now()) {
lastAddrUpdated = time.Now()
Expand All @@ -197,13 +197,14 @@ func (as *AmbientAutoNAT) background() {
}
}
case event.EvtPeerIdentificationCompleted:
peer = e.(event.EvtPeerIdentificationCompleted).Peer
if s, err := as.host.Peerstore().SupportsProtocols(peer, AutoNATProto); err == nil && len(s) > 0 {
if s, err := as.host.Peerstore().SupportsProtocols(e.Peer, AutoNATProto); err == nil && len(s) > 0 {
currentStatus := as.status.Load().(autoNATResult)
if currentStatus.Reachability == network.ReachabilityUnknown {
as.tryProbe(peer)
as.tryProbe(e.Peer)
}
}
default:
log.Errorf("unknown event type: %T", e)
}

// probe finished.
Expand Down

0 comments on commit f022e9f

Please sign in to comment.