Skip to content

Commit 4e60c99

Browse files
committed
Apply tx rate-limit based on the configured TxRequestLimit flag value
1 parent 624d523 commit 4e60c99

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

services/requester/requester.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,12 @@ func (e *EVM) SendRawTransaction(ctx context.Context, data []byte) (common.Hash,
216216
return common.Hash{}, fmt.Errorf("failed to derive the sender: %w", err)
217217
}
218218

219-
if e.config.FlowNetworkID == flowGo.Testnet {
220-
_, _, _, ok, _ := e.limiter.Take(ctx, from.Hex())
219+
rateLimitEnabled := e.config.TxRequestLimit > 0
220+
if rateLimitEnabled {
221+
_, _, _, ok, err := e.limiter.Take(ctx, from.Hex())
222+
if err != nil {
223+
return common.Hash{}, fmt.Errorf("failed to check rate limit: %w", err)
224+
}
221225
if !ok {
222226
return common.Hash{}, errs.ErrRateLimit
223227
}

0 commit comments

Comments
 (0)