Skip to content

Commit

Permalink
Cleanly handle L1 connections that don't support subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower authored and hkalodner committed Apr 21, 2022
1 parent 3c31c92 commit 04d3f91
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arbnode/l1reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/util"
"github.com/pkg/errors"
flag "github.com/spf13/pflag"
)

Expand Down Expand Up @@ -201,8 +203,10 @@ func (s *L1Reader) broadcastLoop(ctx context.Context) {
clientSubscription, err = s.client.SubscribeNewHead(ctx, inputChannel)
if err != nil {
clientSubscription = nil
if time.Now().After(nextSubscribeErr) {
log.Error("failed subscribing to header", "err", err)
if errors.Is(err, rpc.ErrNotificationsUnsupported) {
s.config.PollOnly = true
} else if time.Now().After(nextSubscribeErr) {
log.Warn("failed subscribing to header", "err", err)
nextSubscribeErr = time.Now().Add(s.config.SubscribeErrInterval)
}
}
Expand Down

0 comments on commit 04d3f91

Please sign in to comment.