Skip to content

Commit

Permalink
feat(proxyd): use a specific redis instance for consensus_ha (ethereu…
Browse files Browse the repository at this point in the history
  • Loading branch information
felipe-op authored Mar 18, 2024
1 parent 56f3d1b commit 010dbf6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions proxyd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ type BackendGroupConfig struct {
ConsensusHA bool `toml:"consensus_ha"`
ConsensusHAHeartbeatInterval TOMLDuration `toml:"consensus_ha_heartbeat_interval"`
ConsensusHALockPeriod TOMLDuration `toml:"consensus_ha_lock_period"`
ConsensusHARedis RedisConfig `toml:"consensus_ha_redis"`
}

type BackendGroupsConfig map[string]*BackendGroupConfig
Expand Down
10 changes: 7 additions & 3 deletions proxyd/proxyd.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ func Start(config *Config) (*Server, func(), error) {

var tracker ConsensusTracker
if bgcfg.ConsensusHA {
if redisClient == nil {
log.Crit("cant start - consensus high availability requires redis")
if bgcfg.ConsensusHARedis.URL == "" {
log.Crit("must specify a consensus_ha_redis config when consensus_ha is true")
}
topts := make([]RedisConsensusTrackerOpt, 0)
if bgcfg.ConsensusHALockPeriod > 0 {
Expand All @@ -345,7 +345,11 @@ func Start(config *Config) (*Server, func(), error) {
if bgcfg.ConsensusHAHeartbeatInterval > 0 {
topts = append(topts, WithLockPeriod(time.Duration(bgcfg.ConsensusHAHeartbeatInterval)))
}
tracker = NewRedisConsensusTracker(context.Background(), redisClient, bg, bg.Name, topts...)
consensusHARedisClient, err := NewRedisClient(bgcfg.ConsensusHARedis.URL)
if err != nil {
return nil, nil, err
}
tracker = NewRedisConsensusTracker(context.Background(), consensusHARedisClient, bg, bg.Name, topts...)
copts = append(copts, WithTracker(tracker))
}

Expand Down

0 comments on commit 010dbf6

Please sign in to comment.