Skip to content

Commit 624d523

Browse files
committed
Improve naming and parsing for TxDurationLimit config flag
1 parent a2f7947 commit 624d523

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

cmd/run/cmd.go

Lines changed: 3 additions & 10 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

@@ -248,8 +242,7 @@ var (
248242
cloudKMSLocationID,
249243
cloudKMSKeyRingID,
250244
walletKey,
251-
txStateValidation,
252-
txDurationLimit string
245+
txStateValidation string
253246

254247
initHeight,
255248
forceStartHeight uint64
@@ -287,6 +280,6 @@ func init() {
287280
Cmd.Flags().StringVar(&cfg.ProfilerHost, "profiler-host", "localhost", "Host for the Profiler server")
288281
Cmd.Flags().IntVar(&cfg.ProfilerPort, "profiler-port", 6060, "Port for the Profiler server")
289282
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.")
283+
Cmd.Flags().Uint64Var(&cfg.TxRequestLimit, "tx-request-limit", 0, "Number of transaction submissions to allow per the specified interval.")
284+
Cmd.Flags().DurationVar(&cfg.TxRequestDurationLimit, "tx-request-duration-limit", time.Second*3, "Time interval upon which to enforce transaction submission rate limiting.")
292285
}

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)