Skip to content

Commit

Permalink
fix: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
polsar88 committed Aug 18, 2024
1 parent 6c02c16 commit c40eb46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion internal/checks/latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
// https://docs.infura.io/api/networks/ethereum/json-rpc-methods/eth_chainid
LatencyCheckMethod = "eth_chainId"
// If the latency threshold is not specified in the config, we use this value.
// TODO(polsar): We should probably use a lower value than RPCRequestTimeout.
defaultMaxLatency = RPCRequestTimeout
)

Expand Down Expand Up @@ -140,7 +141,8 @@ func (c *LatencyCheck) runCheckForMethod(method string, maxLatency time.Duration

if !exists {
// This is the first time we are checking this method so initialize its failure counts.
// TODO(polsar): We could initialize all (method, FailureCounts) pairs in the Initialize method instead.
// TODO(polsar): Initialize all (method, FailureCounts) pairs in the Initialize method instead.
// Once initialized, the map will only be read, eliminating the need for the lock.
val = NewFailureCounts()
c.methodFailureCounts[method] = val
}
Expand Down
8 changes: 4 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ type UpstreamConfig struct {
RequestHeadersConfig []RequestHeaderConfig `yaml:"requestHeaders"`
}

func newDuration(d time.Duration) *time.Duration {
return &d
}

func (c *UpstreamConfig) isValid(groups []GroupConfig) bool {
isValid := true
if c.HTTPURL == "" {
Expand Down Expand Up @@ -213,6 +209,10 @@ type RoutingConfig struct {
MaxBlocksBehind int `yaml:"maxBlocksBehind"`
}

func newDuration(d time.Duration) *time.Duration {
return &d
}

func (r *RoutingConfig) setDefaults() {
if r.Errors == nil && r.Latency == nil {
return
Expand Down

0 comments on commit c40eb46

Please sign in to comment.