Skip to content

Commit

Permalink
log an error when we have no transports configured
Browse files Browse the repository at this point in the history
Modify our two transport lookup functions to log loudly when there are no
transports registered.
  • Loading branch information
Stebalien authored and bigs committed Sep 4, 2018
1 parent dae9dd1 commit 0bc531b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions p2p/net/swarm/swarm_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ func (s *Swarm) TransportForDialing(a ma.Multiaddr) transport.Transport {

s.transports.RLock()
defer s.transports.RUnlock()
if len(s.transports.m) == 0 {
log.Error("you have no transports configured")
return nil
}

for _, p := range protocols {
transport, ok := s.transports.m[p.Code]
if !ok {
Expand All @@ -41,6 +46,11 @@ func (s *Swarm) TransportForListening(a ma.Multiaddr) transport.Transport {

s.transports.RLock()
defer s.transports.RUnlock()
if len(s.transports.m) == 0 {
log.Error("you have no transports configured")
return nil
}

selected := s.transports.m[protocols[len(protocols)-1].Code]
for _, p := range protocols {
transport, ok := s.transports.m[p.Code]
Expand Down

0 comments on commit 0bc531b

Please sign in to comment.