Skip to content

Commit 834f8ba

Browse files
committed
emit sync event
1 parent 006eb60 commit 834f8ba

File tree

5 files changed

+71
-6
lines changed

5 files changed

+71
-6
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v0.4.10
2+
- fix: emit event when arkiver is synced
3+
- - fix: set maxQueueSize to 3
4+
15
# v0.4.9
26
- chore: add environment flag to deploy command
37

cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from './cli/mod.ts'
1515
import 'https://deno.land/std@0.179.0/dotenv/load.ts'
1616

17-
export const version = 'v0.4.9'
17+
export const version = 'v0.4.10'
1818

1919
const command = new Command()
2020
.name('arkiver')

deno.lock

+50-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/arkiver/arkiver.ts

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export class Arkiver extends EventTarget {
88
private readonly manifest: ArkiveManifest
99
private arkiveData: Arkive
1010
private sources: DataSource[] = []
11+
private syncedCount = 0
1112
private mongoConnection?: string
1213
private rpcUrls: Record<string, string>
1314

@@ -73,6 +74,17 @@ export class Arkiver extends EventTarget {
7374
noDb: this.mongoConnection === undefined,
7475
arkiveMinorVersion: this.arkiveData.deployment.minor_version,
7576
})
77+
78+
dataSource.addEventListener('synced', () => {
79+
this.syncedCount++
80+
if (this.syncedCount === Object.entries(dataSources).length) {
81+
logger('arkiver').info(
82+
`Arkiver synced - ${this.arkiveData.name}`,
83+
)
84+
this.dispatchEvent(new Event('synced'))
85+
}
86+
})
87+
7688
await dataSource.run()
7789
this.sources.push(dataSource)
7890
}

src/arkiver/data-source.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface NormalizedContracts {
4040
signatureTopics: string[]
4141
}
4242

43-
export class DataSource {
43+
export class DataSource extends EventTarget {
4444
private readonly chain: keyof typeof supportedChains
4545
private readonly rpcUrl: string
4646
private readonly client: PublicClient<HttpTransport>
@@ -100,7 +100,7 @@ export class DataSource {
100100
fetcher: true,
101101
processor: true,
102102
}
103-
private maxQueueSize = 10
103+
private maxQueueSize = 3
104104
private liveDelay = 2000
105105
private queueDelay = 500
106106
private fetchInterval = 500
@@ -124,6 +124,7 @@ export class DataSource {
124124
noDb: boolean
125125
},
126126
) {
127+
super()
127128
this.chain = params.chain
128129
this.rpcUrl = params.rpcUrl
129130
this.blockRange = params.blockRange
@@ -208,6 +209,7 @@ export class DataSource {
208209

209210
if (toBlock === this.liveBlockHeight && !this.isLive) {
210211
this.isLive = true
212+
this.dispatchEvent(new Event('synced'))
211213
logger(this.chain).info(
212214
`Start live arkiving for ${this.chain} at ${this.liveBlockHeight}`,
213215
)

0 commit comments

Comments
 (0)