Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for cancellation error #1346

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions relayer/relays/beefy/on-demand-sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package beefy

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -94,6 +95,9 @@ func (relay *OnDemandRelay) Start(ctx context.Context) error {

paraNonce, ethNonce, err := relay.queryNonces(ctx)
if err != nil {
if errors.Is(err, context.Canceled) {
return nil
}
log.WithError(err).Error("Query nonces")
continue
}
Expand All @@ -115,18 +119,27 @@ func (relay *OnDemandRelay) Start(ctx context.Context) error {

beefyBlockHash, err := relay.relaychainConn.API().RPC.Beefy.GetFinalizedHead()
if err != nil {
if errors.Is(err, context.Canceled) {
return nil
}
log.WithError(err).Error("Fetch latest beefy block hash")
continue
}

header, err := relay.relaychainConn.API().RPC.Chain.GetHeader(beefyBlockHash)
if err != nil {
if errors.Is(err, context.Canceled) {
return nil
}
log.WithError(err).Error("Fetch latest beefy block header")
continue
}

err = relay.sync(ctx, uint64(header.Number))
if err != nil {
if errors.Is(err, context.Canceled) {
return nil
}
log.WithError(err).Error("Sync failed")
continue
}
Expand All @@ -143,6 +156,9 @@ func (relay *OnDemandRelay) waitUntilMessagesSynced(ctx context.Context, paraNon
for {
ethNonce, err := relay.fetchEthereumNonce(ctx)
if err != nil {
if errors.Is(err, context.Canceled) {
return
}
log.WithError(err).Error("fetch latest ethereum nonce")
sleep(ctx, time.Minute*1)
continue
Expand Down
Loading