Skip to content

Commit

Permalink
Merge pull request #774 from forta-network/caner/forta-1042-recalcula…
Browse files Browse the repository at this point in the history
…ting-shard-ids-in-registry-store

Add warning and explanation to force reload interval
  • Loading branch information
canercidam authored Jun 19, 2023
2 parents 027dbff + d087a83 commit c3eba88
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion store/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ var (
const (
keyDefaultChainSetting = "default"
minShardCount = 1

// This is the force reload interval that helps us ignore the on-chain assignment
// list hash. This helps avoid getting stuck with bad state.
//
// WARNING: This also affects how fast the nodes react to shard ID changes
// because the bot assignment hash may not change for a scanner when
// the scanner list for a bot changes (i.e. when another scanner is unassigned).
assignmentForceReloadInterval = time.Minute * 5
)

type RegistryStore interface {
Expand Down Expand Up @@ -56,7 +64,8 @@ func (rs *registryStore) GetAgentsIfChanged(scanner string) ([]config.AgentConfi
return nil, false, err
}

shouldUpdate := rs.lastCompletedVersion != hash.Hash || time.Since(rs.lastUpdate) > 5*time.Minute
shouldUpdate := rs.lastCompletedVersion != hash.Hash ||
time.Since(rs.lastUpdate) > assignmentForceReloadInterval
if !shouldUpdate {
return nil, false, nil
}
Expand Down

0 comments on commit c3eba88

Please sign in to comment.