Skip to content

Commit

Permalink
Merge pull request #74 from libp2p/feat/log-no-transports
Browse files Browse the repository at this point in the history
log an error when we have no transports configured
  • Loading branch information
bigs authored Sep 4, 2018
2 parents dae9dd1 + 0bc531b commit 484fba6
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 484fba6

Please sign in to comment.