Skip to content

Commit

Permalink
Move some logic to the core
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Jan 30, 2024
1 parent 683fb30 commit 4cc6141
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
11 changes: 5 additions & 6 deletions block/fetcher/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4cc6141

Please sign in to comment.