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

block fetcher: FetchReceipts retries if result is nil #90

Merged
merged 2 commits into from
Jul 16, 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
18 changes: 16 additions & 2 deletions blockfetcher/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/abourget/llerrgroup"
"github.com/streamingfast/bstream"
pbbstream "github.com/streamingfast/bstream/pb/sf/bstream/v1"
"github.com/streamingfast/derr"
"github.com/streamingfast/eth-go/rpc"
pbeth "github.com/streamingfast/firehose-ethereum/types/pb/sf/ethereum/type/v2"
"go.uber.org/zap"
Expand Down Expand Up @@ -110,10 +111,23 @@ func FetchReceipts(ctx context.Context, block *rpc.Block, client *rpc.Client) (o
}
hash := tx.Hash
eg.Go(func() error {
receipt, err := client.TransactionReceipt(ctx, hash)
var receipt *rpc.TransactionReceipt
err := derr.RetryContext(ctx, 10, func(ctx context.Context) error {
r, err := client.TransactionReceipt(ctx, hash)
if err != nil {
return err
}
if r == nil {
return fmt.Errorf("receipt is nil")
}

receipt = r
return nil
})
if err != nil {
return fmt.Errorf("fetching receipt for tx %q: %w", hash.Pretty(), err)
return fmt.Errorf("fetching receipt for tx %s: %w", hash.Pretty(), err)
}

lock.Lock()
out[hash.Pretty()] = receipt
lock.Unlock()
Expand Down
Loading