diff --git a/app/plugins/contactRetry.go b/app/plugins/contactRetry.go index 704a984..5a2d81b 100644 --- a/app/plugins/contactRetry.go +++ b/app/plugins/contactRetry.go @@ -9,6 +9,9 @@ import ( "time" ) +// Todo: Move to protocol/connections +// This Plugin is now required and it makes more sense to run more integrated in engine + const tickTimeSec = 30 const tickTime = tickTimeSec * time.Second @@ -121,7 +124,7 @@ func NewConnectionRetry(bus event.Manager, onion string) Plugin { // maxTorCircuitsPending a function to throttle access to tor network during start up func (cr *contactRetry) maxTorCircuitsPending() int { - timeSinceStart := time.Now().Sub(cr.networkUpTime) + timeSinceStart := time.Since(cr.networkUpTime) if timeSinceStart < 30*time.Second { return 4 } else if timeSinceStart < 4*time.Minute { @@ -241,10 +244,6 @@ func (cr *contactRetry) run() { } } -func ticksToSec(ticks int) int { - return ticks * tickTimeSec -} - func (cr *contactRetry) requeueReady() { if !cr.networkUp { return @@ -264,7 +263,7 @@ func (cr *contactRetry) requeueReady() { p := v.(*contact) if p.state == connections.DISCONNECTED && !p.queued { timeout := time.Duration((math.Pow(2, float64(p.failedCount)))*float64(adjustedBaseTimeout /*baseTimeoutSec*/)) * time.Second - if time.Now().Sub(p.lastAttempt) > timeout { + if time.Since(p.lastAttempt) > timeout { retryable = append(retryable, p) } } diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index 2799416..26c5b3f 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -1403,7 +1403,7 @@ func (cp *cwtchPeer) eventHandler() { var cid int if err != nil { // if it's a newly authenticated connection with no conversation storage, init - cid, err = cp.NewContactConversation(handle, model.DefaultP2PAccessControl(), false) + cid, _ = cp.NewContactConversation(handle, model.DefaultP2PAccessControl(), false) } else { cid = ci.ID }