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

fix(store-sync): await fetchAndStoreLogs #2702

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Changes from 1 commit
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
7 changes: 1 addition & 6 deletions packages/store-sync/src/createStoreSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
shareReplay,
combineLatest,
scan,
identity,
mergeMap,
} from "rxjs";
import { debug as parentDebug } from "./debug";
Expand Down Expand Up @@ -199,9 +198,7 @@ export async function createStoreSync<config extends StoreConfig = StoreConfig>(
startBlock = range.startBlock;
endBlock = range.endBlock;
}),
// We use `map` instead of `concatMap` here to send the fetch request immediately when a new block range appears,
// instead of sending the next request only when the previous one completed.
map((range) => {
concatMap((range) => {
const storedBlocks = fetchAndStoreLogs({
publicClient,
address,
Expand All @@ -217,8 +214,6 @@ export async function createStoreSync<config extends StoreConfig = StoreConfig>(

return from(storedBlocks);
}),
// `concatMap` turns the stream of promises into their awaited values
concatMap(identity),
tap(({ blockNumber, logs }) => {
debug("stored", logs.length, "logs for block", blockNumber);
lastBlockNumberProcessed = blockNumber;
Expand Down
Loading