Skip to content

Commit

Permalink
change var name
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanut Lertwarachai authored and Tanut Lertwarachai committed Jan 31, 2025
1 parent e453063 commit 090f73f
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion internal/relayertest/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var CustomCfg = falcon.Config{
Global: falcon.GlobalConfig{
CheckingPacketInterval: 1 * time.Minute,
SyncTunnelsInterval: 5 * time.Minute,
PenaltyAttempts: 3,
PenaltySkipRounds: 3,
LogLevel: "info",
},
BandChain: band.Config{
Expand Down
2 changes: 1 addition & 1 deletion internal/relayertest/testdata/custom_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
log_level = 'info'
checking_packet_interval = 60000000000
sync_tunnels_interval = 300000000000
penalty_attempts = 3
penalty_skip_rounds = 3

[bandchain]
rpc_endpoints = ['http://localhost:26657', 'http://localhost:26658']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
log_level = 'info'
checking_packet_interval = '1m'
sync_tunnels_interval = '5m'
penalty_attempts = 3
penalty_skip_rounds = 3

[bandchain]
rpc_endpoints = ['http://localhost:26657', 'http://localhost:26658']
Expand Down
2 changes: 1 addition & 1 deletion internal/relayertest/testdata/default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
log_level = 'info'
checking_packet_interval = 60000000000
sync_tunnels_interval = 300000000000
penalty_attempts = 3
penalty_skip_rounds = 3

[bandchain]
rpc_endpoints = ['http://localhost:26657']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
log_level = 'info'
checking_packet_interval = 60000000000
sync_tunnels_interval = 300000000000
penalty_attempts = 3
penalty_skip_rounds = 3

[bandchain]
rpc_endpoints = ['http://localhost:26657']
Expand Down
2 changes: 1 addition & 1 deletion relayer/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ func (a *App) Start(ctx context.Context, tunnelIDs []uint64) error {
tunnelRelayers,
a.Config.Global.CheckingPacketInterval,
a.Config.Global.SyncTunnelsInterval,
a.Config.Global.PenaltyAttempts,
a.Config.Global.PenaltySkipRounds,
isSyncTunnelsAllowed,
a.BandClient,
a.TargetChains,
Expand Down
4 changes: 2 additions & 2 deletions relayer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type GlobalConfig struct {
LogLevel string `mapstructure:"log_level" toml:"log_level"`
CheckingPacketInterval time.Duration `mapstructure:"checking_packet_interval" toml:"checking_packet_interval"`
SyncTunnelsInterval time.Duration `mapstructure:"sync_tunnels_interval" toml:"sync_tunnels_interval"`
PenaltyAttempts uint `mapstructure:"penalty_attempts" toml:"penalty_attempts"`
PenaltySkipRounds uint `mapstructure:"penalty_skip_rounds" toml:"penalty_skip_rounds"`
}

// Config defines the configuration for the falcon tunnel relayer.
Expand Down Expand Up @@ -135,7 +135,7 @@ func DefaultConfig() *Config {
Global: GlobalConfig{
LogLevel: "info",
CheckingPacketInterval: time.Minute,
PenaltyAttempts: 3,
PenaltySkipRounds: 3,
SyncTunnelsInterval: 5 * time.Minute,
},
}
Expand Down
34 changes: 17 additions & 17 deletions relayer/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type Scheduler struct {
TunnelRelayers []*TunnelRelayer
CheckingPacketInterval time.Duration
SyncTunnelsInterval time.Duration
PenaltyAttempts uint
PenaltySkipRounds uint

PenaltyAttemptssRemaining []uint
isSyncTunnelsAllowed bool
PenaltySkipRemaining []uint
isSyncTunnelsAllowed bool

BandClient band.Client
ChainProviders chains.ChainProviders
Expand All @@ -37,15 +37,15 @@ func NewScheduler(
chainProviders chains.ChainProviders,
) *Scheduler {
return &Scheduler{
Log: log,
TunnelRelayers: tunnelRelayers,
CheckingPacketInterval: checkingPacketInterval,
SyncTunnelsInterval: syncTunnelsInterval,
PenaltyAttempts: penaltyAttempts,
PenaltyAttemptssRemaining: make([]uint, len(tunnelRelayers)),
isSyncTunnelsAllowed: isSyncTunnelsAllowed,
BandClient: bandClient,
ChainProviders: chainProviders,
Log: log,
TunnelRelayers: tunnelRelayers,
CheckingPacketInterval: checkingPacketInterval,
SyncTunnelsInterval: syncTunnelsInterval,
PenaltySkipRounds: penaltyAttempts,
PenaltySkipRemaining: make([]uint, len(tunnelRelayers)),
isSyncTunnelsAllowed: isSyncTunnelsAllowed,
BandClient: bandClient,
ChainProviders: chainProviders,
}
}

Expand Down Expand Up @@ -78,14 +78,14 @@ func (s *Scheduler) Start(ctx context.Context) error {
func (s *Scheduler) Execute(ctx context.Context) {
// Execute the task for each tunnel relayer
for i, tr := range s.TunnelRelayers {
if s.PenaltyAttemptssRemaining[i] > 0 {
if s.PenaltySkipRemaining[i] > 0 {
s.Log.Debug(
"Skipping tunnel execution due to penalty from previous failure.",
zap.Uint64("tunnel_id", tr.TunnelID),
zap.Int("relayer_id", i),
zap.Uint("penalty_attempts_remaining", s.PenaltyAttemptssRemaining[i]),
zap.Uint("penalty_attempts_remaining", s.PenaltySkipRemaining[i]),
)
s.PenaltyAttemptssRemaining[i] -= 1
s.PenaltySkipRemaining[i] -= 1

continue
}
Expand Down Expand Up @@ -113,7 +113,7 @@ func (s *Scheduler) TriggerTunnelRelayer(ctx context.Context, task Task) {

// Check and relay the packet, if error occurs, set the error flag.
if err := tr.CheckAndRelay(ctx); err != nil {
s.PenaltyAttemptssRemaining[task.RelayerID] = s.PenaltyAttempts
s.PenaltySkipRemaining[task.RelayerID] = s.PenaltySkipRounds

s.Log.Error(
"Failed to execute, Penalty for the tunnel relayer",
Expand Down Expand Up @@ -170,7 +170,7 @@ func (s *Scheduler) SyncTunnels(ctx context.Context) {
)

s.TunnelRelayers = append(s.TunnelRelayers, &tr)
s.PenaltyAttemptssRemaining = append(s.PenaltyAttemptssRemaining, 0)
s.PenaltySkipRemaining = append(s.PenaltySkipRemaining, 0)
s.Log.Info(
"New tunnel synchronized successfully",
zap.String("chain_name", tunnels[i].TargetChainID),
Expand Down

0 comments on commit 090f73f

Please sign in to comment.