@@ -29,11 +29,11 @@ interface TimestampedError {
29
29
function discoverExistingCoordinators ( stateDirectory : string ) : string [ ] {
30
30
try {
31
31
const files = readdirSync ( stateDirectory )
32
- const coordinatorFiles = files . filter ( file =>
33
- file . startsWith ( 'coordinator-db-' ) && file . endsWith ( '.json' )
32
+ const coordinatorFiles = files . filter (
33
+ ( file ) => file . startsWith ( 'coordinator-db-' ) && file . endsWith ( '.json' )
34
34
)
35
-
36
- return coordinatorFiles . map ( file => {
35
+
36
+ return coordinatorFiles . map ( ( file ) => {
37
37
// Extract program ID from filename: coordinator-db-{programId}.json
38
38
const programId = file . slice ( 'coordinator-db-' . length , - '.json' . length )
39
39
return programId
@@ -166,11 +166,14 @@ export function startIndexingMultipleCoordinators(
166
166
miningPool : ServiceConfig
167
167
) : {
168
168
cancel : ( ) => void
169
- coordinators : Map < string , {
170
- stopped : Promise < void >
171
- dataStore : CoordinatorDataStore
172
- errors : TimestampedError [ ]
173
- } >
169
+ coordinators : Map <
170
+ string ,
171
+ {
172
+ stopped : Promise < void >
173
+ dataStore : CoordinatorDataStore
174
+ errors : TimestampedError [ ]
175
+ }
176
+ >
174
177
miningPool : {
175
178
stopped : Promise < void >
176
179
dataStore : MiningPoolDataStore
@@ -185,45 +188,58 @@ export function startIndexingMultipleCoordinators(
185
188
console . log ( 'Discovered existing coordinators:' , existingProgramIds )
186
189
187
190
// Start indexing the primary coordinator (current one from env)
188
- const primaryResult = startIndexingChainToDataStores ( primaryCoordinator , miningPool )
189
-
190
- const coordinators = new Map < string , {
191
- stopped : Promise < void >
192
- dataStore : CoordinatorDataStore
193
- errors : TimestampedError [ ]
194
- } > ( )
191
+ const primaryResult = startIndexingChainToDataStores (
192
+ primaryCoordinator ,
193
+ miningPool
194
+ )
195
+
196
+ const coordinators = new Map <
197
+ string ,
198
+ {
199
+ stopped : Promise < void >
200
+ dataStore : CoordinatorDataStore
201
+ errors : TimestampedError [ ]
202
+ }
203
+ > ( )
195
204
196
205
// Add primary coordinator to map
197
- const primaryProgramId = primaryCoordinator . addressOverride || coordinatorIdl . address
206
+ const primaryProgramId =
207
+ primaryCoordinator . addressOverride || coordinatorIdl . address
198
208
coordinators . set ( primaryProgramId , primaryResult . coordinator )
199
209
200
210
// Create data stores for existing coordinators (read-only mode)
201
211
for ( const programId of existingProgramIds ) {
202
212
if ( programId !== primaryProgramId ) {
203
213
console . log ( `Loading existing coordinator database: ${ programId } ` )
204
-
214
+
205
215
try {
206
216
const publicKey = new PublicKey ( programId )
207
- const dataStore = new FlatFileCoordinatorDataStore ( stateDirectory , publicKey )
208
-
217
+ const dataStore = new FlatFileCoordinatorDataStore (
218
+ stateDirectory ,
219
+ publicKey
220
+ )
221
+
209
222
// Create a resolved promise since we're only reading existing data
210
223
const stopped = Promise . resolve ( )
211
224
const errors : TimestampedError [ ] = [ ]
212
-
225
+
213
226
coordinators . set ( programId , {
214
227
stopped,
215
228
dataStore,
216
- errors
229
+ errors,
217
230
} )
218
231
} catch ( error ) {
219
- console . error ( `Failed to load coordinator database for ${ programId } :` , error )
232
+ console . error (
233
+ `Failed to load coordinator database for ${ programId } :` ,
234
+ error
235
+ )
220
236
}
221
237
}
222
238
}
223
239
224
240
return {
225
241
coordinators,
226
242
miningPool : primaryResult . miningPool ,
227
- cancel : primaryResult . cancel
243
+ cancel : primaryResult . cancel ,
228
244
}
229
245
}
0 commit comments