Skip to content

Commit

Permalink
Fix double handling of start after pre-registration
Browse files Browse the repository at this point in the history
Revert fixed change
  • Loading branch information
JonoPrest committed Oct 25, 2024
1 parent 4932a66 commit 1b22c88
Showing 1 changed file with 47 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -652,50 +652,57 @@ let actionReducer = (state: t, action: action) => {
],
)
| StartIndexingAfterPreRegister =>
Logging.info("Starting indexing after pre-registration")
let {config, chainManager, loadLayer} = state
let chainFetchers = chainManager.chainFetchers->ChainMap.map(cf => {
let {
chainConfig,
logger,
fetchState: {startBlock, endBlock, maxAddrInPartition},
dynamicContractPreRegistration,
} = cf

ChainFetcher.make(
~dynamicContractRegistrations=dynamicContractPreRegistration->Option.mapWithDefault(
[],
Js.Dict.values,
),
~chainConfig,
~lastBlockScannedHashes=ReorgDetection.LastBlockScannedHashes.empty(
~confirmedBlockThreshold=chainConfig.confirmedBlockThreshold,
),
~staticContracts=chainConfig->ChainFetcher.getStaticContracts,
~startBlock,
~endBlock,
~dbFirstEventBlockNumber=None,
~latestProcessedBlock=None,
~logger,
~timestampCaughtUpToHeadOrEndblock=None,
~numEventsProcessed=0,
~numBatchesFetched=0,
~processingFilters=None,
~maxAddrInPartition,
~dynamicContractPreRegistration=None,
)
})

let chainManager: ChainManager.t = {
chainFetchers,
arbitraryEventQueue: [],
isInReorgThreshold: false,
isUnorderedMultichainMode: chainManager.isUnorderedMultichainMode,
}
//Protect against handling this action twice. It should only be handled once
//when the pre registration is done
if ChainManager.isPreRegisteringDynamicContracts(chainManager) {
Logging.info("Starting indexing after pre-registration")
let chainFetchers = chainManager.chainFetchers->ChainMap.map(cf => {
let {
chainConfig,
logger,
fetchState: {startBlock, endBlock, maxAddrInPartition},
dynamicContractPreRegistration,
} = cf

ChainFetcher.make(
~dynamicContractRegistrations=dynamicContractPreRegistration->Option.mapWithDefault(
[],
Js.Dict.values,
),
~chainConfig,
~lastBlockScannedHashes=ReorgDetection.LastBlockScannedHashes.empty(
~confirmedBlockThreshold=chainConfig.confirmedBlockThreshold,
),
~staticContracts=chainConfig->ChainFetcher.getStaticContracts,
~startBlock,
~endBlock,
~dbFirstEventBlockNumber=None,
~latestProcessedBlock=None,
~logger,
~timestampCaughtUpToHeadOrEndblock=None,
~numEventsProcessed=0,
~numBatchesFetched=0,
~processingFilters=None,
~maxAddrInPartition,
~dynamicContractPreRegistration=None,
)
})

let chainManager: ChainManager.t = {
chainFetchers,
arbitraryEventQueue: [],
isInReorgThreshold: false,
isUnorderedMultichainMode: chainManager.isUnorderedMultichainMode,
}

let freshState = make(~config, ~chainManager, ~loadLayer)
let freshState = make(~config, ~chainManager, ~loadLayer)

(freshState, [NextQuery(CheckAllChains)])
(freshState, [NextQuery(CheckAllChains)])
} else {
(state, [])
}
| SuccessExit => {
Logging.info("exiting with success")
NodeJsLocal.process->NodeJsLocal.exitWithCode(Success)
Expand Down

0 comments on commit 1b22c88

Please sign in to comment.