Skip to content

Commit 9ae9c28

Browse files
committed
chunk hyperlane events
1 parent 4575d04 commit 9ae9c28

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/handlers/runHyperlane.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { insertConfigEntriesForAdapter } from "../utils/adapter";
2-
import hyperlane, { build, getEvents } from "../adapters/hyperlane";
2+
import { build, getEvents } from "../adapters/hyperlane";
33
import dayjs from "dayjs";
4+
import _ from "lodash";
45
import { insertTransactionRows } from "../utils/wrappa/postgres/write";
56
import { getBridgeID } from "../utils/wrappa/postgres/query";
67
import { sql } from "../utils/db";
@@ -40,7 +41,11 @@ export const handler = async () => {
4041
}));
4142
startTs = toTs;
4243
await sql.begin(async (sql) => {
43-
await insertTransactionRows(sql, true, transactions, "upsert");
44+
const batchSize = 200;
45+
const transactionChunks = _.chunk(transactions, batchSize);
46+
for (const batch of transactionChunks) {
47+
await insertTransactionRows(sql, true, batch, "upsert");
48+
}
4449
});
4550
console.log(`Inserted ${transactions.length} transactions for ${startTs} to ${endTs}`);
4651
}
@@ -49,4 +54,5 @@ export const handler = async () => {
4954
throw error;
5055
}
5156
};
57+
5258
export default handler;

0 commit comments

Comments
 (0)