Skip to content

Commit 6a21116

Browse files
committed
Improve readability of condition
1 parent ff7b58e commit 6a21116

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

services/requester/batch_tx_pool.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,19 @@ func (t *BatchTxPool) Add(
137137
// transactions that might come from the same EOA.
138138
// [X] is equal to the configured `TxBatchInterval` duration.
139139
lastActivityTime, found := t.eoaActivity.Get(from)
140-
if !found || time.Since(lastActivityTime) > t.config.TxBatchInterval {
140+
141+
if !found {
142+
// Case 1. EOA activity not found:
143+
if err := t.submitSingleTransaction(ctx, hexEncodedTx); err != nil {
144+
return err
145+
}
146+
} else if time.Since(lastActivityTime) > t.config.TxBatchInterval {
147+
// Case 2. EOA activity found AND it was more than [X] seconds ago:
141148
if err := t.submitSingleTransaction(ctx, hexEncodedTx); err != nil {
142149
return err
143150
}
144151
} else {
152+
// Case 3. EOA activity found AND it was less than [X] seconds ago:
145153
userTx := pooledEvmTx{txPayload: hexEncodedTx, nonce: tx.Nonce()}
146154
t.pooledTxs[from] = append(t.pooledTxs[from], userTx)
147155
}

0 commit comments

Comments
 (0)