(startHeight: number)
| 72 | } |
| 73 | |
| 74 | async init(startHeight: number): Promise<void> { |
| 75 | const interval = await this.blockchainSevice.getChainInterval(); |
| 76 | |
| 77 | await Promise.all([this.getFinalizedBlockHead(), this.getBestBlockHead()]); |
| 78 | |
| 79 | const chainLatestHeight = this.latestHeight(); |
| 80 | if (startHeight > chainLatestHeight) { |
| 81 | // This is at init stage, lastProcessedHeight should be always - 1 from the startHeight in this case |
| 82 | // this is reverse calculated from projectService.nextProcessHeight() |
| 83 | // Alternative, we can expose async function getLastProcessedHeight() to ensure accuracy. |
| 84 | if (startHeight - 1 === chainLatestHeight) { |
| 85 | logger.warn( |
| 86 | `Project last processed height is same as current chain height (${chainLatestHeight}). Please ensure the RPC endpoint provider is behaving correctly.` |
| 87 | ); |
| 88 | } else { |
| 89 | throw new Error( |
| 90 | `The startBlock of dataSources in your project manifest (${startHeight}) is higher than the current chain height (${chainLatestHeight}). Please adjust your startBlock to be less that the current chain height.` |
| 91 | ); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | this.schedulerRegistry.addInterval( |
| 96 | 'getFinalizedBlockHead', |
| 97 | setInterval(() => void this.getFinalizedBlockHead(), interval) |
| 98 | ); |
| 99 | this.schedulerRegistry.addInterval( |
| 100 | 'getBestBlockHead', |
| 101 | setInterval(() => void this.getBestBlockHead(), interval) |
| 102 | ); |
| 103 | |
| 104 | await this.dictionaryService.initDictionaries(); |
| 105 | // Update all dictionaries execute before find one usable dictionary |
| 106 | this.updateDictionary(); |
| 107 | // Find one usable dictionary at start |
| 108 | |
| 109 | await this.blockDispatcher.init(this.resetForNewDs.bind(this)); |
| 110 | |
| 111 | void this.startLoop(startHeight); |
| 112 | } |
| 113 | |
| 114 | private updateDictionary(): void { |
| 115 | return this.dictionaryService.buildDictionaryEntryMap(this.projectService.getDataSourcesMap()); |
nothing calls this directly
no test coverage detected