This repository was archived by the owner on May 11, 2024. It is now read-only.
Commit d244ddc 1 parent 18f29a1 commit d244ddc Copy full SHA for d244ddc
File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -245,12 +245,8 @@ func (s *Sender) sendTx(confirmTx *TxConfirm) error {
245
245
func (s * Sender ) loop () {
246
246
defer s .wg .Done ()
247
247
248
- headCh := make (chan * types.Header , 2 )
249
- sub , err := s .client .SubscribeNewHead (s .ctx , headCh )
250
- if err != nil {
251
- panic (err )
252
- }
253
- defer sub .Unsubscribe ()
248
+ hTick := time .NewTicker (time .Second * 3 )
249
+ defer hTick .Stop ()
254
250
255
251
tick := time .NewTicker (time .Second * 2 )
256
252
defer tick .Stop ()
@@ -259,9 +255,19 @@ func (s *Sender) loop() {
259
255
select {
260
256
case <- tick .C :
261
257
s .resendTransaction ()
262
- case header := <- headCh :
258
+ case <- hTick .C :
259
+ header , err := s .client .HeaderByNumber (s .ctx , nil )
260
+ if err != nil {
261
+ log .Error ("failed to get the latest header" , "err" , err )
262
+ return
263
+ }
264
+
263
265
// If chain appear reorg then handle mempool transactions.
264
266
// TODO: handle reorg transactions
267
+
268
+ if s .header .Hash () == header .Hash () {
269
+ continue
270
+ }
265
271
s .header = header
266
272
// Update the gas tip and gas fee
267
273
err = s .updateGasTipGasFee (header )
You can’t perform that action at this time.
0 commit comments