Skip to content

Commit 45c4489

Browse files
committed
Fix an issue with hardcoded value
1 parent e79cb0b commit 45c4489

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

cardano-db-sync/src/Cardano/DbSync/Default.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ applyAndInsertBlockMaybe syncEnv cblk = do
8282
, ". Time to restore consistency."
8383
]
8484
rollbackFromBlockNo syncEnv (blockNo cblk)
85-
liftIO $ putStrLn ("block" :: Text)
8685
insertBlock syncEnv cblk applyRes True tookSnapshot
8786
liftIO $ setConsistentLevel syncEnv Consistent
8887
Right blockId | Just (adaPots, slotNo, epochNo) <- getAdaPots applyRes -> do

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ insertShelleyBlock syncEnv shouldLog withinTwoMins withinHalfHour blk details is
114114
}
115115

116116
let zippedTx = zip [0 ..] (Generic.blkTxs blk)
117-
let txInserter = insertTx tracer cache (getInsertOptions syncEnv) (getNetwork syncEnv) isMember blkId (sdEpochNo details) (Generic.blkSlotNo blk)
117+
let txInserter = insertTx syncEnv isMember blkId (sdEpochNo details) (Generic.blkSlotNo blk)
118118
grouped <- foldM (\grouped (idx, tx) -> txInserter idx tx grouped) mempty zippedTx
119119
minIds <- insertBlockGroupedData syncEnv grouped
120120
when withinHalfHour $
@@ -211,10 +211,7 @@ insertOnNewEpoch tracer blkId slotNo epochNo newEpoch = do
211211

212212
insertTx ::
213213
(MonadBaseControl IO m, MonadIO m) =>
214-
Trace IO Text ->
215-
Cache ->
216-
InsertOptions ->
217-
Ledger.Network ->
214+
SyncEnv ->
218215
IsPoolMember ->
219216
DB.BlockId ->
220217
EpochNo ->
@@ -223,10 +220,11 @@ insertTx ::
223220
Generic.Tx ->
224221
BlockGroupedData ->
225222
ExceptT SyncNodeError (ReaderT SqlBackend m) BlockGroupedData
226-
insertTx tracer cache iopts network isMember blkId epochNo slotNo blockIndex tx grouped = do
223+
insertTx syncEnv isMember blkId epochNo slotNo blockIndex tx grouped = do
224+
hasConsumed <- liftIO $ getHasConsumed syncEnv
227225
let !outSum = fromIntegral $ unCoin $ Generic.txOutSum tx
228226
!withdrawalSum = fromIntegral $ unCoin $ Generic.txWithdrawalSum tx
229-
!resolvedInputs <- mapM (resolveTxInputs (fst <$> groupedTxOut grouped)) (Generic.txInputs tx)
227+
!resolvedInputs <- mapM (resolveTxInputs hasConsumed (fst <$> groupedTxOut grouped)) (Generic.txInputs tx)
230228
let !inSum = sum $ map (unDbLovelace . forth4) resolvedInputs
231229
let diffSum = if inSum >= outSum then inSum - outSum else 0
232230
let !fees = maybe diffSum (fromIntegral . unCoin) (Generic.txFees tx)
@@ -295,6 +293,12 @@ insertTx tracer cache iopts network isMember blkId epochNo slotNo blockIndex tx
295293

296294
let !txIns = map (prepareTxIn txId redeemers) resolvedInputs
297295
pure $ grouped <> BlockGroupedData txIns txOutsGrouped txMetadata maTxMint
296+
where
297+
tracer = getTrace syncEnv
298+
cache = envCache syncEnv
299+
iopts = getInsertOptions syncEnv
300+
network = getNetwork syncEnv
301+
298302

299303
prepareTxOut ::
300304
(MonadBaseControl IO m, MonadIO m) =>

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert/Grouped.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,14 @@ insertReverseIndex blockId minIds =
136136
-- In this case we also cannot find yet the 'TxOutId', so we return 'Nothing' for now
137137
resolveTxInputs ::
138138
MonadIO m =>
139+
Bool ->
139140
[ExtendedTxOut] ->
140141
Generic.TxIn ->
141142
ExceptT SyncNodeError (ReaderT SqlBackend m) (Generic.TxIn, DB.TxId, Either Generic.TxIn DB.TxOutId, DbLovelace)
142-
resolveTxInputs groupedOutputs txIn =
143+
resolveTxInputs hasConsumed groupedOutputs txIn =
143144
liftLookupFail ("resolveTxInputs " <> textShow txIn <> " ") $ do
144145
qres <-
145-
if True
146+
if not hasConsumed
146147
then fmap convertnotFound <$> queryResolveInput txIn
147148
else fmap convertFound <$> queryResolveInput2 txIn
148149
case qres of

0 commit comments

Comments
 (0)