11import 'reflect-metadata' ;
22import { dbService , eventService , metadataService , operationWs , queue } from './indexerServices' ;
33import {
4- createChainSyncClient ,
4+ createChainSynchronizationClient ,
55 createInteractionContext ,
66 InteractionContext
77} from '@cardano-ogmios/client' ;
8- import { Block , TipOrOrigin , Point , PointOrOrigin , BlockAlonzo , BlockBabbage } from '@cardano-ogmios/schema' ;
8+ import { Block , TipOrOrigin , Point , PointOrOrigin , BlockPraos } from '@cardano-ogmios/schema' ;
99import { logError , logInfo } from './logger' ;
1010import { BaseIndexer } from './indexers/BaseIndexer' ;
11- import { ChainSyncClient } from '@cardano-ogmios/client/dist/ChainSync' ;
1211import { AmmDexTransactionIndexer } from './indexers/AmmDexTransactionIndexer' ;
1312import { BaseCacheStorage } from './storage/BaseCacheStorage' ;
1413import { MinswapAnalyzer } from './dex/MinswapAnalyzer' ;
@@ -29,14 +28,15 @@ import { CacheStorage } from './storage/CacheStorage';
2928import { HybridDexTransactionIndexer } from './indexers/HybridDexTransactionIndexer' ;
3029import { AxoAnalyzer } from './dex/AxoAnalyzer' ;
3130import { VyFiAnalyzer } from './dex/VyFiAnalyzer' ;
31+ import { ChainSynchronization } from '@cardano-ogmios/client' ;
3232// import { SundaeSwapV3Analyzer } from './dex/SundaeSwapV3Analyzer';
3333
3434export class IndexerApplication {
3535
3636 private readonly _cache : BaseCacheStorage ;
3737
3838 private _eventListeners : BaseEventListener [ ] = [ ] ;
39- private chainSyncClient : ChainSyncClient | undefined = undefined ;
39+ private chainSyncClient : ChainSynchronization . ChainSynchronizationClient | undefined = undefined ;
4040
4141 /**
4242 * Indexers to make aware of new blocks & rollbacks.
@@ -150,7 +150,7 @@ export class IndexerApplication {
150150 process . exit ( 0 ) ;
151151 } ) ;
152152
153- this . chainSyncClient = await createChainSyncClient (
153+ this . chainSyncClient = await createChainSynchronizationClient (
154154 context ,
155155 {
156156 rollForward : this . rollForward . bind ( this ) ,
@@ -178,8 +178,8 @@ export class IndexerApplication {
178178 * GeniusYield - 110315300, d7281a52d68eef89a7472860fdece323ecc39d3054cdd1fa0825afe56b942a86
179179 */
180180 return lastSync
181- ? this . chainSyncClient . startSync ( [ { slot : lastSync . slot , hash : lastSync . blockHash } ] )
182- : this . chainSyncClient . startSync ( [ { slot : FIRST_SYNC_SLOT , hash : FIRST_SYNC_BLOCK_HASH } ] ) ;
181+ ? this . chainSyncClient ?. resume ( [ { slot : lastSync . slot , id : lastSync . blockHash } ] )
182+ : this . chainSyncClient ?. resume ( [ { slot : FIRST_SYNC_SLOT , id : FIRST_SYNC_BLOCK_HASH } ] ) ;
183183 }
184184
185185 /**
@@ -188,19 +188,13 @@ export class IndexerApplication {
188188 * @param requestNext - Callback to request next block.
189189 */
190190 private async rollForward ( update : { block : Block , tip : TipOrOrigin } , requestNext : ( ) => void ) : Promise < void > {
191- let block : BlockAlonzo | BlockBabbage | undefined = undefined ;
191+ if ( update . block . type === 'praos' ) {
192+ const block : BlockPraos = update . block ;
192193
193- if ( 'babbage' in update . block ) {
194- block = update . block . babbage ;
195- } else if ( 'alonzo' in update . block ) {
196- block = update . block . alonzo ;
197- }
198-
199- if ( block ) {
200- logInfo ( `====== Analyzing block at slot ${ block . header . slot } ======` ) ;
194+ logInfo ( `====== Analyzing block at slot ${ block . slot } ======` ) ;
201195
202196 await Promise . all (
203- this . _indexers . map ( ( indexer : BaseIndexer ) => indexer . onRollForward ( block as BlockAlonzo | BlockBabbage ) ) ,
197+ this . _indexers . map ( ( indexer : BaseIndexer ) => indexer . onRollForward ( block ) ) ,
204198 ) ;
205199
206200 if ( queue . size > 0 ) {
@@ -209,7 +203,7 @@ export class IndexerApplication {
209203 logInfo ( '[Queue] Finished jobs' ) ;
210204 }
211205
212- logInfo ( `====== Finished with block at slot ${ block . header . slot } ======` ) ;
206+ logInfo ( `====== Finished with block at slot ${ block . slot } ======` ) ;
213207 }
214208
215209 requestNext ( ) ;
@@ -227,7 +221,7 @@ export class IndexerApplication {
227221 const point : Point = update . point ;
228222
229223 await Promise . all (
230- this . _indexers . map ( ( indexer : BaseIndexer ) => indexer . onRollBackward ( point . hash , point . slot ) ) ,
224+ this . _indexers . map ( ( indexer : BaseIndexer ) => indexer . onRollBackward ( point . id , point . slot ) ) ,
231225 ) ;
232226 }
233227
0 commit comments