Skip to content

fix: remove unneeded listeners that cleared caches #884

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

Merged
merged 3 commits into from
Apr 24, 2025
Merged
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
4 changes: 1 addition & 3 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { env } from "../shared/utils/env";
import { logger } from "../shared/utils/logger";
import { metricsServer } from "../shared/utils/prometheus";
import { withServerUsageReporting } from "../shared/utils/usage";
import { updateTxListener } from "./listeners/update-tx-listener";
import { withAdminRoutes } from "./middleware/admin-routes";
import { withAuth } from "./middleware/auth";
import { withCors } from "./middleware/cors";
Expand Down Expand Up @@ -132,6 +131,5 @@ export const initServer = async () => {
});

writeOpenApiToFile(server);
await updateTxListener();
await clearCacheCron("server");
await clearCacheCron();
};
88 changes: 0 additions & 88 deletions src/server/listeners/update-tx-listener.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/server/routes/configuration/cache/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function updateCacheConfiguration(fastify: FastifyInstance) {
await updateConfiguration({ ...req.body });
const config = await getConfig(false);
// restarting cache cron with updated cron schedule
await clearCacheCron("server");
await clearCacheCron();
res.status(StatusCodes.OK).send({
result: {
clearCacheCronSchedule: config.clearCacheCronSchedule,
Expand Down
5 changes: 1 addition & 4 deletions src/shared/utils/cache/clear-cache.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import type { env } from "../env";
import { accessTokenCache } from "./access-token";
import { invalidateConfig } from "./get-config";
import { sdkCache } from "./get-sdk";
import { walletsCache } from "./get-wallet";
import { webhookCache } from "./get-webhook";
import { keypairCache } from "./keypair";

export const clearCache = async (
_service: (typeof env)["LOG_SERVICES"][0],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused var

): Promise<void> => {
export const clearCache = async (): Promise<void> => {
invalidateConfig();
webhookCache.clear();
sdkCache.clear();
Expand Down
7 changes: 2 additions & 5 deletions src/shared/utils/cron/clear-cache-cron.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { CronJob } from "cron";
import { clearCache } from "../cache/clear-cache";
import { getConfig } from "../cache/get-config";
import type { env } from "../env";

let task: CronJob;

export const clearCacheCron = async (
service: (typeof env)["LOG_SERVICES"][0],
) => {
export const clearCacheCron = async () => {
const config = await getConfig();

if (!config.clearCacheCronSchedule) {
Expand All @@ -20,7 +17,7 @@ export const clearCacheCron = async (
}

task = new CronJob(config.clearCacheCronSchedule, async () => {
await clearCache(service);
await clearCache();
});
task.start();
};
16 changes: 0 additions & 16 deletions src/worker/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import { chainIndexerListener } from "./listeners/chain-indexer-listener";
import {
newConfigurationListener,
updatedConfigurationListener,
} from "./listeners/config-listener";
import {
newWebhooksListener,
updatedWebhooksListener,
} from "./listeners/webhook-listener";
import { initCancelRecycledNoncesWorker } from "./tasks/cancel-recycled-nonces-worker";
import { initMineTransactionWorker } from "./tasks/mine-transaction-worker";
import { initNonceHealthCheckWorker } from "./tasks/nonce-health-check-worker";
Expand All @@ -31,14 +23,6 @@ export const initWorker = async () => {
await initNonceResyncWorker();
await initWalletSubscriptionWorker();

// Listen for new & updated configuration data.
await newConfigurationListener();
await updatedConfigurationListener();

// Listen for new & updated webhooks data.
await newWebhooksListener();
await updatedWebhooksListener();

// Contract subscriptions.
await chainIndexerListener();
};
114 changes: 0 additions & 114 deletions src/worker/listeners/config-listener.ts

This file was deleted.

Loading