Skip to content

Commit

Permalink
feat: add time.Sleep when subscribing failed and update backOff duration
Browse files Browse the repository at this point in the history
  • Loading branch information
0x6e616d committed Aug 10, 2024
1 parent dda04ec commit 3cd1b8d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/pkg/listener/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/gob"
"fmt"
"math"
"time"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -139,9 +140,10 @@ func (s *EventService) Start(ctx context.Context) error {
return err
}

s.sub = event.ResubscribeErr(10, func(ctx context.Context, err error) (event.Subscription, error) {
s.sub = event.ResubscribeErr(5*time.Second, func(ctx context.Context, err error) (event.Subscription, error) {
if err != nil {
s.l.Errorw("Failed to re-subscribe the event", "err", err)
time.Sleep(1 * time.Second)
}

return s.subscribeNewHead(ctx)
Expand Down

0 comments on commit 3cd1b8d

Please sign in to comment.