diff --git a/common/mclock/simclock.go b/common/mclock/simclock.go index 766ca0f873..f5ad3f8bc0 100644 --- a/common/mclock/simclock.go +++ b/common/mclock/simclock.go @@ -58,7 +58,7 @@ func (s *Simulated) Run(d time.Duration) { s.mu.Lock() s.init() - end := s.now + AbsTime(d) + end := s.now.Add(d) var do []func() for len(s.scheduled) > 0 && s.scheduled[0].at <= end { ev := heap.Pop(&s.scheduled).(*simTimer) @@ -134,7 +134,7 @@ func (s *Simulated) AfterFunc(d time.Duration, fn func()) Timer { func (s *Simulated) schedule(d time.Duration, fn func()) *simTimer { s.init() - at := s.now + AbsTime(d) + at := s.now.Add(d) ev := &simTimer{do: fn, at: at, s: s} heap.Push(&s.scheduled, ev) s.cond.Broadcast() diff --git a/common/prque/lazyqueue.go b/common/prque/lazyqueue.go index 1fa744f399..883d210735 100644 --- a/common/prque/lazyqueue.go +++ b/common/prque/lazyqueue.go @@ -88,13 +88,13 @@ func (q *LazyQueue) Refresh() { // refresh re-evaluates items in the older queue and swaps the two queues func (q *LazyQueue) refresh(now mclock.AbsTime) { - q.maxUntil = now + mclock.AbsTime(q.period) + q.maxUntil = now.Add(q.period) for q.queue[0].Len() != 0 { q.Push(heap.Pop(q.queue[0]).(*item).value) } q.queue[0], q.queue[1] = q.queue[1], q.queue[0] q.indexOffset = 1 - q.indexOffset - q.maxUntil += mclock.AbsTime(q.period) + q.maxUntil = q.maxUntil.Add(q.period) } // Push adds an item to the queue diff --git a/p2p/discv5/ticket.go b/p2p/discv5/ticket.go index 4780e8b866..2ccbfad7ff 100644 --- a/p2p/discv5/ticket.go +++ b/p2p/discv5/ticket.go @@ -107,7 +107,7 @@ func pongToTicket(localTime mclock.AbsTime, topics []Topic, node *Node, p *ingre } // Convert wait periods to local absolute time. for i, wp := range wps { - t.regTime[i] = localTime + mclock.AbsTime(time.Second*time.Duration(wp)) + t.regTime[i] = localTime.Add(time.Second * time.Duration(wp)) } return t, nil } @@ -349,7 +349,7 @@ func (s *ticketStore) nextFilteredTicket() (*ticketRef, time.Duration) { } log.Trace("Found discovery ticket to register", "node", ticket.t.node, "serial", ticket.t.serial, "wait", wait) - regTime := now + mclock.AbsTime(wait) + regTime := now.Add(wait) topic := ticket.t.topics[ticket.idx] if s.tickets[topic] != nil && regTime >= s.tickets[topic].nextReg { return ticket, wait @@ -614,7 +614,7 @@ func (s *ticketStore) cleanupTopicQueries(now mclock.AbsTime) { delete(s.queriesSent, n) } } - s.nextTopicQueryCleanup = now + mclock.AbsTime(topicQueryTimeout) + s.nextTopicQueryCleanup = now.Add(topicQueryTimeout) } func (s *ticketStore) gotTopicNodes(from *Node, hash common.Hash, nodes []rpcNode) (timeout bool) { @@ -625,7 +625,7 @@ func (s *ticketStore) gotTopicNodes(from *Node, hash common.Hash, nodes []rpcNod return true } q, ok := qq[hash] - if !ok || now > q.sent+mclock.AbsTime(topicQueryTimeout) { + if !ok || now > q.sent.Add(topicQueryTimeout) { return true } inside := float64(0) diff --git a/p2p/discv5/topic.go b/p2p/discv5/topic.go index c7c4ca9368..060395e963 100644 --- a/p2p/discv5/topic.go +++ b/p2p/discv5/topic.go @@ -194,7 +194,7 @@ func (t *topicTable) addEntry(node *Node, topic Topic) { topic: topic, fifoIdx: fifoIdx, node: node, - expire: tm + mclock.AbsTime(fallbackRegistrationExpiry), + expire: tm.Add(fallbackRegistrationExpiry), } if printTestImgLogs { fmt.Printf("*+ %d %v %016x %016x\n", tm/1000000, topic, t.self.sha[:8], node.sha[:8]) @@ -251,7 +251,7 @@ func (t *topicTable) useTicket(node *Node, serialNo uint32, topics []Topic, idx } if serialNo != n.lastUsedTicket { n.lastUsedTicket = serialNo - n.noRegUntil = tm + mclock.AbsTime(noRegTimeout()) + n.noRegUntil = tm.Add(noRegTimeout()) t.storeTicketCounters(node) } @@ -263,7 +263,7 @@ func (t *topicTable) useTicket(node *Node, serialNo uint32, topics []Topic, idx t.addEntry(node, topics[idx]) } else { // if there is an active entry, don't move to the front of the FIFO but prolong expire time - e.expire = tm + mclock.AbsTime(fallbackRegistrationExpiry) + e.expire = tm.Add(fallbackRegistrationExpiry) } return true } @@ -293,7 +293,7 @@ func (topictab *topicTable) getTicket(node *Node, topics []Topic) *ticket { waitPeriod = minWaitPeriod } - t.regTime[i] = now + mclock.AbsTime(waitPeriod) + t.regTime[i] = now.Add(waitPeriod) } return t }