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

Commit

Permalink
named magic number incantations
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed May 9, 2018
1 parent 6d4bc41 commit fa14117
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion autonat.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const (
var (
AutoNATBootDelay = 15 * time.Second
AutoNATRefreshInterval = 15 * time.Minute

AutoNATRequestTimeout = 60 * time.Second
)

type AutoNAT interface {
Expand Down Expand Up @@ -109,7 +111,7 @@ func (as *AmbientAutoNAT) autodetect() {

for _, p := range peers {
cli := NewAutoNATClient(as.host, p)
ctx, cancel := context.WithTimeout(as.ctx, 60*time.Second)
ctx, cancel := context.WithTimeout(as.ctx, AutoNATRequestTimeout)
a, err := cli.Dial(ctx)
cancel()

Expand Down
4 changes: 3 additions & 1 deletion svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (

const P_CIRCUIT = 290

var AutoNATServiceResetInterval = 1 * time.Minute

type AutoNATService struct {
ctx context.Context
dialer host.Host
Expand Down Expand Up @@ -161,7 +163,7 @@ func (as *AutoNATService) doDial(pi pstore.PeerInfo) *pb.Message_DialResponse {
}

func (as *AutoNATService) resetPeers() {
ticker := time.NewTicker(1 * time.Minute)
ticker := time.NewTicker(AutoNATServiceResetInterval)
defer ticker.Stop()

for {
Expand Down

0 comments on commit fa14117

Please sign in to comment.