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

Trivial context and comments #104

Merged
merged 5 commits into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions 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 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 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 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