Skip to content

Commit 0475003

Browse files
committed
Fetch only recent ops
1 parent c7c3544 commit 0475003

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/pages/Home.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ const ops = ref<FeedUserOp[]>([]);
5656
async function fetch(): Promise<void> {
5757
const LIMIT = 20;
5858
const indexerService = new IndexerService(indexerEndpoint);
59-
const startBlock = ops.value[0]?.blockTimestamp;
59+
const startTimestamp =
60+
ops.value[0]?.blockTimestamp || Math.floor(Date.now() / 1000) - 60 * 60;
6061
const newOps = await indexerService.getLatestUserOps(
6162
LIMIT,
63+
startTimestamp,
6264
chain.value || undefined,
63-
startBlock,
6465
);
6566
const opList = [...newOps, ...ops.value];
6667
opList.sort((a, b) => b.blockTimestamp - a.blockTimestamp);

src/services/indexer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,15 @@ class Service {
269269

270270
public async getLatestUserOps(
271271
limit: number,
272+
startTimestamp: number,
272273
chain?: Chain,
273-
startBlock?: number,
274274
): Promise<FeedUserOp[]> {
275275
const query = `{
276276
UserOp(
277277
limit: ${limit},
278278
where: {
279279
${chain ? `chainId: { _eq: ${chain} },` : ''}
280-
${startBlock ? `blockTimestamp: { _gt: ${startBlock} },` : ''}
280+
${startTimestamp ? `blockTimestamp: { _gt: ${startTimestamp} },` : ''}
281281
},
282282
order_by: {
283283
blockTimestamp: desc

0 commit comments

Comments
 (0)