Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed Jan 13, 2025
1 parent 957caac commit 65c4165
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions go/ethadapter/geth_rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,13 @@ func (e *gethRPCClient) Nonce(account gethcommon.Address) (uint64, error) {
}

func (e *gethRPCClient) BlockListener() (chan *types.Header, ethereum.Subscription) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

// we do not buffer here, we expect the consumer to always be ready to receive new blocks and not fall behind
ch := make(chan *types.Header)
var sub ethereum.Subscription
var err error
err = retry.Do(func() error {
ctx, cancel := context.WithTimeout(context.Background(), e.timeout)
defer cancel()
sub, err = e.client.SubscribeNewHead(ctx, ch)
if err != nil {
e.logger.Warn("could not subscribe for new head blocks", log.ErrKey, err)
Expand Down
6 changes: 5 additions & 1 deletion go/host/l1/dataservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ func (r *DataService) streamLiveBlocks() {
}

func (r *DataService) resetLiveStream() (chan *types.Header, ethereum.Subscription) {
r.logger.Info("reconnecting to L1 new Heads")
err := retry.Do(func() error {
if !r.running.Load() {
// break out of the loop if repository has stopped
Expand All @@ -339,7 +340,10 @@ func (r *DataService) resetLiveStream() (chan *types.Header, ethereum.Subscripti
r.logger.Warn("unable to reconnect to L1", log.ErrKey, err)
return nil, nil
}
return r.ethClient.BlockListener()

ch, s := r.ethClient.BlockListener()
r.logger.Info("successfully reconnected to L1 new Heads")
return ch, s
}

func (r *DataService) FetchBlockByHeight(height *big.Int) (*types.Header, error) {
Expand Down

0 comments on commit 65c4165

Please sign in to comment.