Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions internal/certificatetransparency/ct-watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,10 @@ func (w *worker) runStandardWorker(ctx context.Context) error {
return errCreatingClient
}

// If recovery is enabled, we start at the saved index. Otherwise, we start at the latest STH.
recoveryEnabled := config.AppConfig.General.Recovery.Enabled
if !recoveryEnabled {
// If recovery is enabled AND we have a saved index > 0, use it.
// Otherwise, fetch the current STH and start from there.
hasSavedIndex := config.AppConfig.General.Recovery.Enabled && w.ctIndex > 0
if !hasSavedIndex {
sth, getSTHerr := jsonClient.GetSTH(ctx)
if getSTHerr != nil {
// TODO this can happen due to a 429 error. We should retry the request
Expand Down Expand Up @@ -416,9 +417,10 @@ func (w *worker) runStandardWorker(ctx context.Context) error {
func (w *worker) runTiledWorker(ctx context.Context) error {
hc := &http.Client{Timeout: 30 * time.Second}

// If recovery is enabled and the CT index is set, we start at the saved index. Otherwise we start at the latest checkpoint.
validSavedCTIndexExists := config.AppConfig.General.Recovery.Enabled && w.ctIndex >= 0
if !validSavedCTIndexExists {
// If recovery is enabled AND we have a saved index > 0, use it.
// Otherwise, fetch the current checkpoint and start from there.
hasSavedIndex := config.AppConfig.General.Recovery.Enabled && w.ctIndex > 0
if !hasSavedIndex {
checkpoint, err := FetchCheckpoint(ctx, hc, w.ctURL)
if err != nil {
log.Printf("Could not get checkpoint for '%s': %s\n", w.ctURL, err)
Expand Down