Skip to content

Commit

Permalink
fix: bring back time warping
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower committed Dec 25, 2024
1 parent 46a61dc commit 85e57b5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/attachSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Config } from "./config/index.js";
import { DI } from "./di.js";
import type { ILogger } from "./log/index.js";
import type Client from "./services/Client.js";
import { formatTs } from "./utils/index.js";

export default async function attachSDK(): Promise<CreditAccountsService> {
const config: Config = DI.get(DI.Config);
Expand Down Expand Up @@ -54,14 +55,15 @@ export default async function attachSDK(): Promise<CreditAccountsService> {
redstoneHistoricTimestamp: optimisticTimestamp,
logger,
});
// in optimistic mode, warp time if redstone timestamp does not match it
// service.sdk.priceFeeds.addHook(
// "updatesGenerated",
// async ({ timestamp }) => {
// const block = await client.anvil.evmMineDetailed(timestamp);
// logger.debug({ tag: "timing" }, `new block ts: ${formatTs(block)}`);
// },
// );
if (config.optimistic) {
// in optimistic mode, warp time if redstone timestamp does not match it
sdk.priceFeeds.addHook("updatesGenerated", async ({ timestamp }) => {
try {
const block = await client.anvil.evmMineDetailed(timestamp);
logger.debug({ tag: "timing" }, `new block ts: ${formatTs(block)}`);
} catch {}
});
}
const service = new CreditAccountsService(sdk, {
batchSize: config.compressorBatchSize,
});
Expand Down

0 comments on commit 85e57b5

Please sign in to comment.