diff --git a/CHANGELOG.md b/CHANGELOG.md index 56a21a6..159d1f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.4.10 +- fix: emit event when arkiver is synced +- - fix: set maxQueueSize to 3 + # v0.4.9 - chore: add environment flag to deploy command diff --git a/cli.ts b/cli.ts index 9a45308..e350cd3 100644 --- a/cli.ts +++ b/cli.ts @@ -14,7 +14,7 @@ import { } from './cli/mod.ts' import 'https://deno.land/std@0.179.0/dotenv/load.ts' -export const version = 'v0.4.9' +export const version = 'v0.4.10' const command = new Command() .name('arkiver') diff --git a/deno.lock b/deno.lock index 5cd74c2..042d859 100644 --- a/deno.lock +++ b/deno.lock @@ -375,6 +375,21 @@ "https://deno.land/x/robo_arkiver@v0.4.8/src/graphql/entity.ts": "2ffe65f4f5c2e84ce12c65389f406f691ac197dc96fa72eda715238c8be58cc5", "https://deno.land/x/robo_arkiver@v0.4.8/src/logger.ts": "55777c14947494a7e5fbfae5d759ff9b6727eb0d4a3e2841ace284b3126f4d12", "https://deno.land/x/robo_arkiver@v0.4.8/src/utils.ts": "9cdbb1e71c2d7fbc4583f40ecce999e4e8af28b36cf63bbef1873fe4d549e1dc", + "https://deno.land/x/robo_arkiver@v0.4.9/mod.ts": "90324bff69d360a337ba9872b57419c4cc7ef03baea68733fa9e1dd302098809", + "https://deno.land/x/robo_arkiver@v0.4.9/src/arkiver/arkive-metadata.ts": "cb215c002fc91acd12ce94a9a65a5c560555c91533d3660c3f1228b39f6b02b7", + "https://deno.land/x/robo_arkiver@v0.4.9/src/arkiver/arkiver.ts": "229304d15ff45bd21a95090282bda43504b98a520cf0eaeeaf0b638dc9722bf6", + "https://deno.land/x/robo_arkiver@v0.4.9/src/arkiver/data-source.ts": "2f93e0a27b9eeb52c657a32a407c7adfcdab6e13693876a1b7b7b6f5f2623933", + "https://deno.land/x/robo_arkiver@v0.4.9/src/arkiver/manifest-builder.ts": "301631ffb49a6c946ddc24e227cd562d55cfb9b998e81109babde7e22f7791cd", + "https://deno.land/x/robo_arkiver@v0.4.9/src/arkiver/providers/interfaces.ts": "0f048fc8d8f6296220f32b378f1b86426f1f2b144aa96fa474c3871604f723de", + "https://deno.land/x/robo_arkiver@v0.4.9/src/arkiver/providers/mongodb.ts": "bb4634f3d83ee3fef93c297cf1005b3d75788dea756df3faa4939342a7357f8b", + "https://deno.land/x/robo_arkiver@v0.4.9/src/arkiver/store.ts": "c7f89caab378a61e940565ff381fb45e7dea381055fa1427e27af09e3a8b543d", + "https://deno.land/x/robo_arkiver@v0.4.9/src/arkiver/types.ts": "1f4fe3df2f75e215ac57c1ac7dfbbc58609660d7c3c655d180b72855a2201242", + "https://deno.land/x/robo_arkiver@v0.4.9/src/chains.ts": "f1b022804d9382a23f3ccfb5dfc3bf8df2d64787bc1049431446000e73581c73", + "https://deno.land/x/robo_arkiver@v0.4.9/src/deps.ts": "b5ac990562b63f7ed31e35507b7d41e3e1ee5a6d4af57b6771ee5f4d2d41b25c", + "https://deno.land/x/robo_arkiver@v0.4.9/src/graphql/builder.ts": "16c60af2ecf8bb59928dfd3793aca3a30e1fc472d43a572fa5fd0d1e3860d2b0", + "https://deno.land/x/robo_arkiver@v0.4.9/src/graphql/entity.ts": "2ffe65f4f5c2e84ce12c65389f406f691ac197dc96fa72eda715238c8be58cc5", + "https://deno.land/x/robo_arkiver@v0.4.9/src/logger.ts": "55777c14947494a7e5fbfae5d759ff9b6727eb0d4a3e2841ace284b3126f4d12", + "https://deno.land/x/robo_arkiver@v0.4.9/src/utils.ts": "9cdbb1e71c2d7fbc4583f40ecce999e4e8af28b36cf63bbef1873fe4d549e1dc", "https://deno.land/x/tty@0.1.4/ansi_regex.ts": "1d3b0c7289164f93c9ebafe3bbd05a723568a250cc5c29c0cc922ff55af9a238", "https://deno.land/x/tty@0.1.4/combining.ts": "a615e9479d8bc901e3a727e5cae83c0aa1d4ca1e75fa040861d9905d16b30ffc", "https://deno.land/x/tty@0.1.4/is_interactive.ts": "37080d92399827215e60a57d97013aefbdbc038e7a5d2346abd298a7010525e6", @@ -458,13 +473,13 @@ }, "npm": { "specifiers": { - "abitype": "abitype@0.8.3_typescript@5.0.4", + "abitype": "abitype@0.8.4_typescript@5.0.4", "graphql-compose": "graphql-compose@9.0.10", "graphql-compose-mongoose": "graphql-compose-mongoose@9.8.0_graphql-compose@9.0.10_mongoose@7.0.3", "graphql-yoga": "graphql-yoga@3.9.1_graphql@16.6.0_@envelop+core@3.0.6", "lru-cache": "lru-cache@9.1.1", - "mongoose": "mongoose@7.1.1", - "viem": "viem@0.3.26_ws@8.12.0" + "mongoose": "mongoose@7.1.2", + "viem": "viem@0.3.30_ws@8.12.0" }, "packages": { "@adraffy/ens-normalize@1.9.0": { @@ -746,6 +761,12 @@ "typescript": "typescript@5.0.4" } }, + "abitype@0.8.4_typescript@5.0.4": { + "integrity": "sha512-W6Yxm7Ln1n0H/ghI/Yror0P45/+UCQohCCtSzj7/H5Htj48jJmX9KBym/+OiFl58TvuD9y9plRTsbxdCBdBAog==", + "dependencies": { + "typescript": "typescript@5.0.4" + } + }, "asn1js@3.0.5": { "integrity": "sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==", "dependencies": { @@ -993,6 +1014,18 @@ "sift": "sift@16.0.1" } }, + "mongoose@7.1.2": { + "integrity": "sha512-89+rFzYphsOCdIDam03ryECeOy4bFKvZqnu4NDdUduoOt2ip0/otIqVBBrjQ1Owz1xza6zy4VTifxBG/jNaJNQ==", + "dependencies": { + "bson": "bson@5.2.0", + "kareem": "kareem@2.5.1", + "mongodb": "mongodb@5.3.0", + "mpath": "mpath@0.9.0", + "mquery": "mquery@5.0.0", + "ms": "ms@2.1.3", + "sift": "sift@16.0.1" + } + }, "mpath@0.9.0": { "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", "dependencies": {} @@ -1182,6 +1215,20 @@ "ws": "ws@8.12.0" } }, + "viem@0.3.30_ws@8.12.0": { + "integrity": "sha512-4jokEVR2vtDl6zSpZiPUaHviK2dzW6uxCAVUArlh0Jhrc4ms0dkhn5E4iwk1CWMto8+YeLFEgY4gr9P10ryoEQ==", + "dependencies": { + "@adraffy/ens-normalize": "@adraffy/ens-normalize@1.9.0", + "@noble/curves": "@noble/curves@1.0.0", + "@noble/hashes": "@noble/hashes@1.3.0", + "@scure/bip32": "@scure/bip32@1.3.0", + "@scure/bip39": "@scure/bip39@1.2.0", + "@wagmi/chains": "@wagmi/chains@0.2.16", + "abitype": "abitype@0.8.2_typescript@5.0.4", + "isomorphic-ws": "isomorphic-ws@5.0.0_ws@8.12.0", + "ws": "ws@8.12.0" + } + }, "web-streams-polyfill@3.2.1": { "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", "dependencies": {} diff --git a/src/arkiver/arkiver.ts b/src/arkiver/arkiver.ts index 26041a1..6dcb3d8 100644 --- a/src/arkiver/arkiver.ts +++ b/src/arkiver/arkiver.ts @@ -8,6 +8,7 @@ export class Arkiver extends EventTarget { private readonly manifest: ArkiveManifest private arkiveData: Arkive private sources: DataSource[] = [] + private syncedCount = 0 private mongoConnection?: string private rpcUrls: Record @@ -73,6 +74,17 @@ export class Arkiver extends EventTarget { noDb: this.mongoConnection === undefined, arkiveMinorVersion: this.arkiveData.deployment.minor_version, }) + + dataSource.addEventListener('synced', () => { + this.syncedCount++ + if (this.syncedCount === Object.entries(dataSources).length) { + logger('arkiver').info( + `Arkiver synced - ${this.arkiveData.name}`, + ) + this.dispatchEvent(new Event('synced')) + } + }) + await dataSource.run() this.sources.push(dataSource) } diff --git a/src/arkiver/data-source.ts b/src/arkiver/data-source.ts index 6d2a635..a461522 100644 --- a/src/arkiver/data-source.ts +++ b/src/arkiver/data-source.ts @@ -40,7 +40,7 @@ interface NormalizedContracts { signatureTopics: string[] } -export class DataSource { +export class DataSource extends EventTarget { private readonly chain: keyof typeof supportedChains private readonly rpcUrl: string private readonly client: PublicClient @@ -100,7 +100,7 @@ export class DataSource { fetcher: true, processor: true, } - private maxQueueSize = 10 + private maxQueueSize = 3 private liveDelay = 2000 private queueDelay = 500 private fetchInterval = 500 @@ -124,6 +124,7 @@ export class DataSource { noDb: boolean }, ) { + super() this.chain = params.chain this.rpcUrl = params.rpcUrl this.blockRange = params.blockRange @@ -208,6 +209,7 @@ export class DataSource { if (toBlock === this.liveBlockHeight && !this.isLive) { this.isLive = true + this.dispatchEvent(new Event('synced')) logger(this.chain).info( `Start live arkiving for ${this.chain} at ${this.liveBlockHeight}`, )