Skip to content

Commit fa5eb7f

Browse files
committed
Merge branch 'dl/lru-on-evict' into dl/blockdb
2 parents 3923a26 + 8c9057a commit fa5eb7f

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

cache/lru/cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ func TestCachePutWithOnEvict(t *testing.T) {
4646

4747
cachetest.Basic(t, c)
4848
require.Len(t, evicted, 1)
49-
require.Equal(t, evicted[ids.ID{1}], int64(1))
49+
require.Equal(t, int64(1), evicted[ids.ID{1}])
5050
}

x/sync/manager.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,10 +1030,7 @@ func (m *Manager) enqueueWork(work *workItem) {
10301030
func midPoint(startMaybe, endMaybe maybe.Maybe[[]byte]) maybe.Maybe[[]byte] {
10311031
start := startMaybe.Value()
10321032
end := endMaybe.Value()
1033-
length := len(start)
1034-
if len(end) > length {
1035-
length = len(end)
1036-
}
1033+
length := max(len(end), len(start))
10371034

10381035
if length == 0 {
10391036
if endMaybe.IsNothing() {
@@ -1180,10 +1177,8 @@ func calculateBackoff(attempt int) time.Duration {
11801177
return 0
11811178
}
11821179

1183-
retryWait := initialRetryWait * time.Duration(math.Pow(retryWaitFactor, float64(attempt)))
1184-
if retryWait > maxRetryWait {
1185-
retryWait = maxRetryWait
1186-
}
1187-
1188-
return retryWait
1180+
return min(
1181+
initialRetryWait*time.Duration(math.Pow(retryWaitFactor, float64(attempt))),
1182+
maxRetryWait,
1183+
)
11891184
}

0 commit comments

Comments
 (0)