Skip to content

Commit

Permalink
fix(store-sync): update latest block for live logs API (#3323)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Oct 23, 2024
1 parent 4e92fde commit dfc2d64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-chefs-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store-sync": patch
---

Fixed an issue where the sync progress was not moving to "live" when synced from the MUD indexer's live logs API.
4 changes: 4 additions & 0 deletions packages/store-sync/src/createStoreSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
mergeMap,
throwError,
mergeWith,
ignoreElements,
} from "rxjs";
import { debug as parentDebug } from "./debug";
import { SyncStep } from "./SyncStep";
Expand Down Expand Up @@ -283,6 +284,9 @@ export async function createStoreSync({
debug("falling back to streaming logs from ETH RPC");
return storedEthRpcLogs$;
}),
// subscribe to `latestBlockNumber$` so the sync progress is updated
// but don't merge/emit anything
mergeWith(latestBlockNumber$.pipe(ignoreElements())),
tap(async ({ logs, blockNumber }) => {
debug("stored", logs.length, "logs for block", blockNumber);
lastBlockNumberProcessed = blockNumber;
Expand Down

0 comments on commit dfc2d64

Please sign in to comment.