Unverified Commit 6a4fe011 authored by bigs's avatar bigs Committed by GitHub

Merge pull request #74 from libp2p/feat/log-no-transports

log an error when we have no transports configured
parents 67b383f9 486c6372
...@@ -18,6 +18,11 @@ func (s *Swarm) TransportForDialing(a ma.Multiaddr) transport.Transport { ...@@ -18,6 +18,11 @@ func (s *Swarm) TransportForDialing(a ma.Multiaddr) transport.Transport {
s.transports.RLock() s.transports.RLock()
defer s.transports.RUnlock() defer s.transports.RUnlock()
if len(s.transports.m) == 0 {
log.Error("you have no transports configured")
return nil
}
for _, p := range protocols { for _, p := range protocols {
transport, ok := s.transports.m[p.Code] transport, ok := s.transports.m[p.Code]
if !ok { if !ok {
...@@ -41,6 +46,11 @@ func (s *Swarm) TransportForListening(a ma.Multiaddr) transport.Transport { ...@@ -41,6 +46,11 @@ func (s *Swarm) TransportForListening(a ma.Multiaddr) transport.Transport {
s.transports.RLock() s.transports.RLock()
defer s.transports.RUnlock() 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] selected := s.transports.m[protocols[len(protocols)-1].Code]
for _, p := range protocols { for _, p := range protocols {
transport, ok := s.transports.m[p.Code] transport, ok := s.transports.m[p.Code]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment