Skip to content

Commit

Permalink
chore: satisfy golint
Browse files Browse the repository at this point in the history
  • Loading branch information
postables committed Jun 10, 2019
1 parent 21925da commit 3a56b8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func randomConns(tb testing.TB) (c [5000]network.Conn) {
for i, _ := range c {
for i := range c {
c[i] = randConn(tb, nil)
}
return c
Expand Down
7 changes: 7 additions & 0 deletions connmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"go.uber.org/zap"
)

// SilencePeriod does something
// seems to allow us to silence periodic runs
var SilencePeriod = 10 * time.Second

// BasicConnMgr is a ConnManager that trims connections whenever the count exceeds the
Expand Down Expand Up @@ -112,10 +114,14 @@ func NewConnManager(ctx context.Context, wg *sync.WaitGroup, logger *zap.Logger,
return cm
}

// Close is here to satisfy the interface of ConnectionManager
// previously in the libp2p version this called a cancel func
func (cm *BasicConnMgr) Close() error {
return nil
}

// Protect can be used to mark a peer as protected
// from connection closing
func (cm *BasicConnMgr) Protect(id peer.ID, tag string) {
cm.plk.Lock()
defer cm.plk.Unlock()
Expand All @@ -128,6 +134,7 @@ func (cm *BasicConnMgr) Protect(id peer.ID, tag string) {
tags[tag] = struct{}{}
}

// Unprotect removes protection status from a peer
func (cm *BasicConnMgr) Unprotect(id peer.ID, tag string) (protected bool) {
cm.plk.Lock()
defer cm.plk.Unlock()
Expand Down

0 comments on commit 3a56b8a

Please sign in to comment.