Skip to content
Open
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
34 changes: 17 additions & 17 deletions apps/rest-api-server/src/syncers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { PublicClient } from "viem";
import { createPublicClient, http } from "viem";
import * as chains from "viem/chains";

import { prisma } from "@blobscan/db";
Copy link
Member Author

Choose a reason for hiding this comment

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

should be a procedure

import { env } from "@blobscan/env";
import { PriceFeed } from "@blobscan/price-feed";
import type { BaseSyncer } from "@blobscan/syncers";
Expand All @@ -20,23 +21,22 @@ export async function setUpSyncers() {
const connection = createRedisConnection(env.REDIS_URI);
const syncers: BaseSyncer[] = [];

if (env.SWARM_STORAGE_ENABLED) {
if (!env.SWARM_BATCH_ID) {
logger.error(`Can't initialize Swarm stamp job: no batch ID provided`);
} else if (!env.BEE_ENDPOINT) {
logger.error(
"Can't initialize Swarm stamp job: no Bee endpoint provided"
);
} else {
syncers.push(
new SwarmStampSyncer({
cronPattern: env.SWARM_STAMP_CRON_PATTERN,
redisUriOrConnection: connection,
batchId: env.SWARM_BATCH_ID,
beeEndpoint: env.BEE_ENDPOINT,
})
);
}
// SwarmStampSyncer is added if there is already an element with id 1
// This is useful in case Swarm storage is temporarily disabled, so that
// the Swarm TTL is still updated.
const blobStoragesState = await prisma.blobStoragesState.findUnique({
where: { id: 1 },
});
if (blobStoragesState) {
logger.info("SwarmStampSyncer added");
syncers.push(
new SwarmStampSyncer({
cronPattern: env.SWARM_STAMP_CRON_PATTERN,
redisUriOrConnection: connection,
batchId: env.SWARM_BATCH_ID || blobStoragesState.swarmDataId,
beeEndpoint: env.BEE_ENDPOINT || "http://localhost:1633",
})
);
}

syncers.push(
Expand Down
Loading