From ee5c55d82ad70353e8203f6729d4325b59741bfa Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sun, 5 Jan 2025 14:59:09 +0100 Subject: fix: Ensure backoff for get-sth and proof fetching Our get-entries fetcher already backs-off exponentially. --- internal/monitor/tail.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/monitor/tail.go b/internal/monitor/tail.go index 43a6d56..2603e81 100644 --- a/internal/monitor/tail.go +++ b/internal/monitor/tail.go @@ -76,13 +76,17 @@ func (t *tail) run(ctx context.Context, mon MonitoredLog, eventCh chan Event, er } func (t *tail) sequence(ctx context.Context, mon MonitoredLog, eventCh chan Event, errorCh chan error, chunkCh chan *chunk) { + var failedAt time.Time state := mon.State heap := newChunks() sendChunk := func(ctx context.Context, force bool) { + if !failedAt.IsZero() && failedAt.Add(30*time.Second).After(time.Now()) { + return // ensures we don't spam get-sth and proof endpoints + } + if heap.gap(state.NextIndex) { return // nothing to send yet } - c := heap.pop() if !force && len(c.matches) == 0 && len(c.leafHashes) < int(t.cfg.ChunkSize) { heap.push(c) @@ -91,6 +95,7 @@ func (t *tail) sequence(ctx context.Context, mon MonitoredLog, eventCh chan Even nextState, err := t.nextState(ctx, state, c) if err != nil { + failedAt = time.Now() errorCh <- err heap.push(c) return -- cgit v1.2.3