From 4cc61416f12ebb03e4e12ab7e4ea75118a9101c7 Mon Sep 17 00:00:00 2001 From: billettc Date: Tue, 30 Jan 2024 08:02:44 -0500 Subject: [PATCH] Move some logic to the core --- Dockerfile | 2 +- block/fetcher/rpc.go | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 88243915..7babc1c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.2 -FROM ghcr.io/streamingfast/firehose-core:f839e5d as core +FROM ghcr.io/streamingfast/firehose-core:c2781fa as core FROM ubuntu:20.04 diff --git a/block/fetcher/rpc.go b/block/fetcher/rpc.go index 0a365630..d5d0135f 100644 --- a/block/fetcher/rpc.go +++ b/block/fetcher/rpc.go @@ -53,6 +53,10 @@ func NewRPC(rpcClient *rpc.Client, fetchInterval time.Duration, latestBlockRetry return f } +func (f *RPCFetcher) IsBlockAvailable(requestedSlot uint64) bool { + return requestedSlot <= f.latestConfirmedSlot +} + func (f *RPCFetcher) Fetch(ctx context.Context, requestedSlot uint64) (out *pbbstream.Block, skip bool, err error) { f.logger.Info("fetching block", zap.Uint64("block_num", requestedSlot)) @@ -103,15 +107,10 @@ func (f *RPCFetcher) Fetch(ctx context.Context, requestedSlot uint64) (out *pbbs return block, false, nil } -func (f *RPCFetcher) fetchRpcBlock(ctx context.Context, requestedSlot uint64) (out *rpc.GetBlockResult, err error) { - b, err := f.rpcClient.GetBlockWithOpts(ctx, requestedSlot, GetBlockOpts) - return b, err -} - func (f *RPCFetcher) fetch(ctx context.Context, requestedSlot uint64) (out *rpc.GetBlockResult, skip bool, err error) { currentSlot := requestedSlot //f.logger.Info("getting block", zap.Uint64("block_num", currentSlot)) - blockResult, err := f.fetchRpcBlock(ctx, currentSlot) + blockResult, err := f.rpcClient.GetBlockWithOpts(ctx, requestedSlot, GetBlockOpts) if err != nil { var rpcErr *jsonrpc.RPCError