Skip to content

Commit

Permalink
Merge pull request #104 from libp2p/misc
Browse files Browse the repository at this point in the history
Trivial context and comments
  • Loading branch information
vyzo authored Feb 19, 2019
2 parents 2b3c820 + c8c717c commit 0cca6c8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
7 changes: 1 addition & 6 deletions p2p/net/swarm/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ type dialJob struct {
}

func (dj *dialJob) cancelled() bool {
select {
case <-dj.ctx.Done():
return true
default:
return false
}
return dj.ctx.Err() != nil
}

func (dj *dialJob) dialTimeout() time.Duration {
Expand Down
8 changes: 4 additions & 4 deletions p2p/net/swarm/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ func (s *Swarm) teardown() error {
s.conns.m = nil
s.conns.Unlock()

// Lots of go routines but we might as well do this in parallel. We want
// to shut down as fast as possible.
// Lots of goroutines but we might as well do this in parallel. We want to shut down as fast as
// possible.

for l := range listeners {
go func(l transport.Listener) {
Expand All @@ -148,8 +148,8 @@ func (s *Swarm) teardown() error {
return nil
}

// AddAddrFilter adds a multiaddr filter to the set of filters the swarm will
// use to determine which addresses not to dial to.
// AddAddrFilter adds a multiaddr filter to the set of filters the swarm will use to determine which
// addresses not to dial to.
func (s *Swarm) AddAddrFilter(f string) error {
m, err := mafilter.NewMask(f)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm_dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
logdial["dial"] = "failure" // start off with failure. set to "success" at the end.

sk := s.peers.PrivKey(s.local)
logdial["encrypted"] = (sk != nil) // log wether this will be an encrypted dial or not.
logdial["encrypted"] = sk != nil // log whether this will be an encrypted dial or not.
if sk == nil {
// fine for sk to be nil, just log.
log.Debug("Dial not given PrivateKey, so WILL NOT SECURE conn.")
Expand Down
4 changes: 3 additions & 1 deletion p2p/net/swarm/swarm_listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func (s *Swarm) AddListenAddr(a ma.Multiaddr) error {
for {
c, err := list.Accept()
if err != nil {
log.Warningf("swarm listener accept error: %s", err)
if s.ctx.Err() == nil {
log.Errorf("swarm listener accept error: %s", err)
}
return
}
log.Debugf("swarm listener accepted connection: %s", c)
Expand Down

0 comments on commit 0cca6c8

Please sign in to comment.