Skip to content

Commit 35a2220

Browse files
committed
Improve naming and parsing for TxDurationLimit config flag
1 parent 5ed32fe commit 35a2220

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

cmd/run/cmd.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,6 @@ func parseConfigFromFlags() error {
222222
return fmt.Errorf("unknown tx state validation: %s", txStateValidation)
223223
}
224224

225-
txDuration, err := time.ParseDuration(txDurationLimit)
226-
if err != nil {
227-
return fmt.Errorf("invalid unit %s for TX duration limit: %w", txDuration, err)
228-
}
229-
cfg.TxDurationLimit = txDuration
230-
231225
return nil
232226
}
233227

@@ -287,6 +281,6 @@ func init() {
287281
Cmd.Flags().StringVar(&cfg.ProfilerHost, "profiler-host", "localhost", "Host for the Profiler server")
288282
Cmd.Flags().IntVar(&cfg.ProfilerPort, "profiler-port", 6060, "Port for the Profiler server")
289283
Cmd.Flags().StringVar(&txStateValidation, "tx-state-validation", "tx-seal", "Sets the transaction validation mechanism. It can validate using the local state index, or wait for the outer Flow transaction to seal. Available values ('local-index' / 'tx-seal'), defaults to 'tx-seal'.")
290-
Cmd.Flags().Uint64Var(&cfg.TxRequestLimit, "tx-request-limit", 1, "Number of transaction submissions to allow per the specified interval. Applies only on Testnet.")
291-
Cmd.Flags().StringVar(&txDurationLimit, "tx-duration-limit", "3s", "Time interval upon which to enforce transaction submission rate limiting. Applies only on Testnet.")
284+
Cmd.Flags().Uint64Var(&cfg.TxRequestLimit, "tx-request-limit", 0, "Number of transaction submissions to allow per the specified interval.")
285+
Cmd.Flags().DurationVar(&cfg.TxRequestDurationLimit, "tx-request-duration-limit", time.Second*3, "Time interval upon which to enforce transaction submission rate limiting.")
292286
}

config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ type Config struct {
9191
TxStateValidation string
9292
// TxRequestLimit is the number of transaction submissions to allow per interval.
9393
TxRequestLimit uint64
94-
// TxDurationLimit is the time interval upon which to enforce transaction submission
94+
// TxRequestDurationLimit is the time interval upon which to enforce transaction submission
9595
// rate limiting.
96-
TxDurationLimit time.Duration
96+
TxRequestDurationLimit time.Duration
9797
}

services/requester/requester.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func NewEVM(
172172
ratelimiter, err := memorystore.New(
173173
&memorystore.Config{
174174
Tokens: config.TxRequestLimit,
175-
Interval: config.TxDurationLimit,
175+
Interval: config.TxRequestDurationLimit,
176176
},
177177
)
178178
if err != nil {

0 commit comments

Comments
 (0)