aboutsummaryrefslogtreecommitdiff
path: root/internal/monitor
diff options
context:
space:
mode:
authorRasmus Dahlberg <rgdd@glasklarteknik.se>2025-01-05 14:59:09 +0100
committerRasmus Dahlberg <rgdd@glasklarteknik.se>2025-01-05 14:59:09 +0100
commitee5c55d82ad70353e8203f6729d4325b59741bfa (patch)
tree0062cbfe2f9c974ae0cb630357dee7a792c0a198 /internal/monitor
parentb8b6ce265ef083d21db155af4a50cee1b9b0b934 (diff)
fix: Ensure backoff for get-sth and proof fetching
Our get-entries fetcher already backs-off exponentially.
Diffstat (limited to 'internal/monitor')
-rw-r--r--internal/monitor/tail.go7
1 files changed, 6 insertions, 1 deletions
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