@@ -169,11 +169,6 @@ func (s *Sender) SendTransaction(tx *types.Transaction) (string, error) {
169
169
return "" , fmt .Errorf ("too many pending transactions" )
170
170
}
171
171
172
- // Update the gas tip and gas fee.
173
- if err := s .updateGasTipGasFee (s .header ); err != nil {
174
- return "" , err
175
- }
176
-
177
172
txData , err := s .makeTxData (tx )
178
173
if err != nil {
179
174
return "" , err
@@ -202,31 +197,33 @@ func (s *Sender) sendTx(confirmTx *TxConfirm) error {
202
197
203
198
baseTx := confirmTx .baseTx
204
199
205
- // Try 3 RetryTimes if nonce is not correct.
206
- rawTx , err := s .Opts .Signer (s .Opts .From , types .NewTx (baseTx ))
207
- if err != nil {
208
- return err
209
- }
210
- confirmTx .Tx = rawTx
211
- err = s .client .SendTransaction (s .ctx , rawTx )
212
- confirmTx .Err = err
213
- // Check if the error is nonce too low.
214
- if err != nil {
215
- if strings .Contains (err .Error (), "nonce too low" ) {
216
- s .AdjustNonce (baseTx )
217
- log .Warn ("nonce is not correct, retry to send transaction" , "tx_hash" , rawTx .Hash ().String (), "err" , err )
218
- return nil
200
+ for i := 0 ; i < 3 ; i ++ {
201
+ // Try 3 RetryTimes if nonce is not correct.
202
+ rawTx , err := s .Opts .Signer (s .Opts .From , types .NewTx (baseTx ))
203
+ if err != nil {
204
+ return err
219
205
}
220
- if err .Error () == "replacement transaction underpriced" {
221
- s .adjustGas (baseTx )
222
- log .Warn ("replacement transaction underpriced" , "tx_hash" , rawTx .Hash ().String (), "err" , err )
223
- return nil
206
+ confirmTx .Tx = rawTx
207
+ err = s .client .SendTransaction (s .ctx , rawTx )
208
+ confirmTx .Err = err
209
+ // Check if the error is nonce too low.
210
+ if err != nil {
211
+ if strings .Contains (err .Error (), "nonce too low" ) {
212
+ s .AdjustNonce (baseTx )
213
+ log .Warn ("nonce is not correct, retry to send transaction" , "tx_hash" , rawTx .Hash ().String (), "err" , err )
214
+ continue
215
+ }
216
+ if err .Error () == "replacement transaction underpriced" {
217
+ s .adjustGas (baseTx )
218
+ log .Warn ("replacement transaction underpriced" , "tx_hash" , rawTx .Hash ().String (), "err" , err )
219
+ continue
220
+ }
221
+ log .Error ("failed to send transaction" , "tx_hash" , rawTx .Hash ().String (), "err" , err )
222
+ return err
224
223
}
225
- log . Error ( "failed to send transaction" , "tx_hash" , rawTx . Hash (). String (), "err" , err )
226
- return err
224
+ s . Opts . Nonce = big . NewInt ( s . Opts . Nonce . Int64 () + 1 )
225
+ break
227
226
}
228
- s .Opts .Nonce = big .NewInt (s .Opts .Nonce .Int64 () + 1 )
229
-
230
227
return nil
231
228
}
232
229
0 commit comments