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 mem leak issue #297

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 13 additions & 16 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
getBatchEthBalance,
} from "./account";
import {
downscaleProtection,
// downscaleProtection,
prepareOrdersForRound,
getOrderbookOwnersProfileMapFromSg,
handleAddOrderbookOwnersProfileMap,
Expand Down Expand Up @@ -613,9 +613,6 @@ export const main = async (argv: any, version?: string) => {
}
});

// periodically fetch and set gas price in state (once every 20 seconds)
setInterval(() => getGasPrice(config, state), 20_000);

const lastReadOrdersMap = options.subgraph.map((v) => ({
sg: v,
skip: 0,
Expand Down Expand Up @@ -849,7 +846,7 @@ export const main = async (argv: any, version?: string) => {
startTime: lastReadOrdersTimestamp,
}),
);
let ordersDidChange = false;
// let ordersDidChange = false;
const results = await Promise.allSettled(
lastReadOrdersMap.map((v) =>
getOrderChanges(
Expand All @@ -864,9 +861,9 @@ export const main = async (argv: any, version?: string) => {
for (let i = 0; i < results.length; i++) {
const res = results[i];
if (res.status === "fulfilled") {
if (res.value.addOrders.length || res.value.removeOrders.length) {
ordersDidChange = true;
}
// if (res.value.addOrders.length || res.value.removeOrders.length) {
// ordersDidChange = true;
// }
lastReadOrdersMap[i].skip += res.value.count;
try {
await handleAddOrderbookOwnersProfileMap(
Expand All @@ -892,14 +889,14 @@ export const main = async (argv: any, version?: string) => {
}
}

// in case there are new orders or removed order, re evaluate owners limits
if (ordersDidChange) {
await downscaleProtection(
orderbooksOwnersProfileMap,
config.viemClient as any as ViemClient,
options.ownerProfile,
);
}
// // in case there are new orders or removed order, re evaluate owners limits
// if (ordersDidChange) {
// await downscaleProtection(
// orderbooksOwnersProfileMap,
// config.viemClient as any as ViemClient,
// options.ownerProfile,
// );
// }
} catch {
/**/
}
Expand Down
Loading
Loading