From e277d8da245f04aa3f2d37bc9def91094a852fb4 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 22 Jan 2018 19:46:27 +0100 Subject: [PATCH] Adapt estimateSequence to replication interval --- update/state/state.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/update/state/state.go b/update/state/state.go index d6dd9f8..f5bfcbc 100644 --- a/update/state/state.go +++ b/update/state/state.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "math" "net/http" "os" "path" @@ -209,6 +210,7 @@ func estimateSequence(url string, timestamp time.Time) int { } } - behind := state.Time.Sub(timestamp) - return state.Sequence - int(behind.Minutes()) + behind := state.Time.Sub(timestamp) + // Sequence unit depends on replication interval (minute, hour, day). + return state.Sequence - int(math.Ceil(behind.Minutes() / config.BaseOptions.ReplicationInterval.Minutes())) }