-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #411 from Blobscan/swarm-syncer
Swarm batch information updater
- Loading branch information
Showing
47 changed files
with
859 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blobscan/rest-api-server": minor | ||
--- | ||
|
||
Added Swarm stamp syncer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blobscan/syncers": minor | ||
--- | ||
|
||
Added swarm stamp syncer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
"@blobscan/rest-api-server": minor | ||
"@blobscan/syncers": minor | ||
--- | ||
|
||
Refactored the stats syncer package to support general-purpose synchronization workers/queues. | ||
|
||
Key changes include: | ||
|
||
• Renamed the package to syncers. | ||
• Exported each syncer directly, removing the StatsSyncer managing entity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blobscan/db": minor | ||
--- | ||
|
||
Added an updated at field to blob storages state model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
18.15.0 | ||
20.12.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import type { BaseSyncer } from "@blobscan/syncers"; | ||
import { | ||
DailyStatsSyncer, | ||
OverallStatsSyncer, | ||
SwarmStampSyncer, | ||
createRedisConnection, | ||
} from "@blobscan/syncers"; | ||
|
||
import { env } from "./env"; | ||
import { logger } from "./logger"; | ||
import { getNetworkDencunForkSlot } from "./utils"; | ||
|
||
export 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, | ||
}) | ||
); | ||
} | ||
} | ||
|
||
syncers.push( | ||
new DailyStatsSyncer({ | ||
cronPattern: env.STATS_SYNCER_DAILY_CRON_PATTERN, | ||
redisUriOrConnection: connection, | ||
}) | ||
); | ||
|
||
syncers.push( | ||
new OverallStatsSyncer({ | ||
cronPattern: env.STATS_SYNCER_OVERALL_CRON_PATTERN, | ||
redisUriOrConnection: connection, | ||
lowestSlot: | ||
env.DENCUN_FORK_SLOT ?? getNetworkDencunForkSlot(env.NETWORK_NAME), | ||
}) | ||
); | ||
|
||
Promise.all(syncers.map((syncer) => syncer.start())); | ||
|
||
return () => { | ||
let teardownPromise = Promise.resolve(); | ||
|
||
for (const syncer of syncers) { | ||
teardownPromise = teardownPromise.finally(() => syncer.close()); | ||
} | ||
|
||
return teardownPromise; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/db/prisma/migrations/20240613112056_add_updated_at_field/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "blob_storages_state" ADD COLUMN "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.