@@ -97,7 +97,6 @@ insertBlockGroupedData ::
9797insertBlockGroupedData syncEnv grouped = do
9898 disInOut <- liftIO $ getDisableInOutState syncEnv
9999
100- -- Parallel preparation of independent data
101100 -- Parallel preparation of independent data
102101 (preparedTxIn, preparedMetadata, preparedMint, txOutChunks) <- liftIO $ do
103102 a1 <- async $ pure $ prepareTxInProcessing syncEnv grouped
@@ -200,7 +199,8 @@ resolveTxInputs syncEnv hasConsumed needsValue groupedOutputs txIn = do
200199 case eTxId of
201200 Right txId -> do
202201 -- Now get the TxOutId separately
203- eTxOutId <- lift $ DB. resolveInputTxOutIdFromTxId txId (Generic. txInIndex txIn)
202+ let txOutVariantType = getTxOutVariantType syncEnv
203+ eTxOutId <- lift $ DB. resolveInputTxOutIdFromTxId txOutVariantType txId (Generic. txInIndex txIn)
204204 case eTxOutId of
205205 Right txOutId -> pure $ Right $ convertFoundTxOutId (txId, txOutId)
206206 Left err -> pure $ Left err
@@ -240,7 +240,6 @@ resolveTxInputs syncEnv hasConsumed needsValue groupedOutputs txIn = do
240240 DB. VCTxOutW cTxOut -> (txIn, VC. txOutCoreTxId cTxOut, Left txIn, Nothing )
241241 DB. VATxOutW vTxOut _ -> (txIn, VA. txOutAddressTxId vTxOut, Left txIn, Nothing )
242242
243-
244243resolveRemainingInputs ::
245244 [ExtendedTxIn ] ->
246245 [(DB. TxOutIdW , ExtendedTxOut )] ->
@@ -387,32 +386,10 @@ processUtxoConsumption syncEnv grouped txOutIds = do
387386 -- Log failures
388387 mapM_ (liftIO . logWarning tracer . (" Failed to find output for " <> ) . Text. pack . show ) failedInputs
389388
390- -- | Helper function to categorize resolved inputs for parallel processing
391- categorizeResolvedInputs :: [ExtendedTxIn ] -> ([DB. BulkConsumedByHash ], [(DB. TxOutIdW , DB. TxId )], [ExtendedTxIn ])
392- categorizeResolvedInputs etis =
393- let (hashBased, idBased, failed) = foldr categorizeOne ([] , [] , [] ) etis
394- in (hashBased, idBased, failed)
395- where
396- categorizeOne ExtendedTxIn {.. } (hAcc, iAcc, fAcc) =
397- case etiTxOutId of
398- Right txOutId ->
399- (hAcc, (txOutId, DB. txInTxInId etiTxIn) : iAcc, fAcc)
400- Left genericTxIn ->
401- let bulkData =
402- DB. BulkConsumedByHash
403- { bchTxHash = unTxHash (Generic. txInTxId genericTxIn)
404- , bchOutputIndex = Generic. txInIndex genericTxIn
405- , bchConsumingTxId = DB. txInTxInId etiTxIn
406- }
407- in (bulkData : hAcc, iAcc, fAcc)
408-
409389-----------------------------------------------------------------------------------------------------------------------------------
410390-- PARALLEL PROCESSING HELPER FUNCTIONS (NO PIPELINES)
411391-----------------------------------------------------------------------------------------------------------------------------------
412392
413- -- Pipelines aren't suitable here due to data dependencies.
414- -- The current approach using async for truly independent operations is optimal.
415-
416393-- | Helper function to create MinIds result
417394makeMinId :: SyncEnv -> [DB. TxInId ] -> [DB. TxOutIdW ] -> [DB. MaTxOutIdW ] -> DB. MinIdsWrapper
418395makeMinId syncEnv txInIds txOutIds maTxOutIds =
@@ -431,3 +408,25 @@ makeMinId syncEnv txInIds txOutIds maTxOutIds =
431408 , minTxOutId = listToMaybe txOutIds
432409 , minMaTxOutId = listToMaybe maTxOutIds
433410 }
411+
412+ -- | Helper function to categorize resolved inputs for parallel processing
413+ -- Note: Inputs with Left (unresolved to TxOutId) are treated as hash-based updates
414+ -- and also tracked as potentially failed for logging purposes.
415+ categorizeResolvedInputs :: [ExtendedTxIn ] -> ([DB. BulkConsumedByHash ], [(DB. TxOutIdW , DB. TxId )], [ExtendedTxIn ])
416+ categorizeResolvedInputs =
417+ foldr categorizeOne ([] , [] , [] )
418+ where
419+ categorizeOne eti@ ExtendedTxIn {.. } (hAcc, iAcc, fAcc) =
420+ case etiTxOutId of
421+ Right txOutId ->
422+ -- Successfully resolved to a TxOutId
423+ (hAcc, (txOutId, DB. txInTxInId etiTxIn) : iAcc, fAcc)
424+ Left genericTxIn ->
425+ -- Try to resolve by hash, but also track as potentially failed
426+ let bulkData =
427+ DB. BulkConsumedByHash
428+ { bchTxHash = unTxHash (Generic. txInTxId genericTxIn)
429+ , bchOutputIndex = Generic. txInIndex genericTxIn
430+ , bchConsumingTxId = DB. txInTxInId etiTxIn
431+ }
432+ in (bulkData : hAcc, iAcc, eti : fAcc)
0 commit comments