aboutsummaryrefslogtreecommitdiffstats
path: root/les
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2019-09-16 17:16:30 +0800
committerGitHub <noreply@github.com>2019-09-16 17:16:30 +0800
commitb1c3010bf2c334241a8cb01eab110e5f1cd88f71 (patch)
tree91c3aa83639b19cc4cbb00bf89e5c5dec1632911 /les
parentaff986958da831d85788f33fe11aab31995ac072 (diff)
downloadgo-tangerine-b1c3010bf2c334241a8cb01eab110e5f1cd88f71.tar
go-tangerine-b1c3010bf2c334241a8cb01eab110e5f1cd88f71.tar.gz
go-tangerine-b1c3010bf2c334241a8cb01eab110e5f1cd88f71.tar.bz2
go-tangerine-b1c3010bf2c334241a8cb01eab110e5f1cd88f71.tar.lz
go-tangerine-b1c3010bf2c334241a8cb01eab110e5f1cd88f71.tar.xz
go-tangerine-b1c3010bf2c334241a8cb01eab110e5f1cd88f71.tar.zst
go-tangerine-b1c3010bf2c334241a8cb01eab110e5f1cd88f71.zip
common/mclock: clean up AfterFunc support (#20054)
This change adds tests for the virtual clock and aligns the interface with the time package by renaming Cancel to Stop. It also removes the binary search from Stop because it complicates the code unnecessarily.
Diffstat (limited to 'les')
-rw-r--r--les/balance.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/les/balance.go b/les/balance.go
index 4f08a304e..a36a997cf 100644
--- a/les/balance.go
+++ b/les/balance.go
@@ -42,7 +42,7 @@ type balanceTracker struct {
negTimeFactor, negRequestFactor float64
sumReqCost uint64
lastUpdate, nextUpdate, initTime mclock.AbsTime
- updateEvent mclock.Event
+ updateEvent mclock.Timer
// since only a limited and fixed number of callbacks are needed, they are
// stored in a fixed size array ordered by priority threshold.
callbacks [balanceCallbackCount]balanceCallback
@@ -86,7 +86,7 @@ func (bt *balanceTracker) stop(now mclock.AbsTime) {
bt.timeFactor = 0
bt.requestFactor = 0
if bt.updateEvent != nil {
- bt.updateEvent.Cancel()
+ bt.updateEvent.Stop()
bt.updateEvent = nil
}
}
@@ -235,7 +235,7 @@ func (bt *balanceTracker) checkCallbacks(now mclock.AbsTime) {
// updateAfter schedules a balance update and callback check in the future
func (bt *balanceTracker) updateAfter(dt time.Duration) {
- if bt.updateEvent == nil || bt.updateEvent.Cancel() {
+ if bt.updateEvent == nil || bt.updateEvent.Stop() {
if dt == 0 {
bt.updateEvent = nil
} else {