Skip to content

Commit 787a3d0

Browse files
committed
handle whitelist resolvetxinput
1 parent 5bb86ac commit 787a3d0

File tree

1 file changed

+12
-7
lines changed
  • cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Cardano.DbSync.Api
2020
import Cardano.DbSync.Api.Types (InsertOptions (..), SyncEnv (..))
2121
import Cardano.DbSync.Cache.Types (Cache (..))
2222

23-
import Cardano.DbSync.Config.Types (MetadataConfig (..), MultiAssetConfig (..), PlutusConfig (..), ShelleyInsertConfig (..), isPlutusModeActive, isShelleyModeActive)
23+
import Cardano.DbSync.Config.Types (MetadataConfig (..), MultiAssetConfig (..), PlutusConfig (..), ShelleyInsertConfig (..), isPlutusModeActive, isShelleyModeActive, isShelleyWhitelistModeActive)
2424
import qualified Cardano.DbSync.Era.Shelley.Generic as Generic
2525
import Cardano.DbSync.Era.Shelley.Generic.Metadata (TxMetadataValue (..), metadataValueToJsonNoSchema)
2626
import Cardano.DbSync.Era.Universal.Insert.Certificate (insertCertificate)
@@ -95,13 +95,18 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
9595
else
9696
let !inSum = sum $ map unDbLovelace $ catMaybes amounts
9797
in pure (resolvedInputs, fees, Just $ fromIntegral (inSum + withdrawalSum) - fromIntegral outSum - fromIntegral fees)
98+
-- Nothing in fees means a phase 2 failure
9899
(_, _, Nothing) -> do
99-
-- Nothing in fees means a phase 2 failure
100-
(resolvedInsFull, amounts) <- splitLast <$> mapM (resolveTxInputs syncEnv hasConsumed True (fst <$> groupedTxOut grouped)) (Generic.txInputs tx)
101-
let !inSum = sum $ map unDbLovelace $ catMaybes amounts
102-
!diffSum = if inSum >= outSum then inSum - outSum else 0
103-
!fees = maybe diffSum (fromIntegral . unCoin) (Generic.txFees tx)
104-
pure (resolvedInsFull, fromIntegral fees, Just 0)
100+
-- If we are in shelley whitelist mode, we don't need to resolve the tx inputs for this case.
101+
if isShelleyWhitelistModeActive $ ioShelley $ getInsertOptions syncEnv
102+
then -- TODO: cmdv -- would this be the right values to return?
103+
pure ([], 0, Just 0)
104+
else do
105+
(resolvedInsFull, amounts) <- splitLast <$> mapM (resolveTxInputs syncEnv hasConsumed True (fst <$> groupedTxOut grouped)) (Generic.txInputs tx)
106+
let !inSum = sum $ map unDbLovelace $ catMaybes amounts
107+
!diffSum = if inSum >= outSum then inSum - outSum else 0
108+
!fees = maybe diffSum (fromIntegral . unCoin) (Generic.txFees tx)
109+
pure (resolvedInsFull, fromIntegral fees, Just 0)
105110
let fees = fromIntegral fees'
106111
-- Insert transaction and get txId from the DB.
107112
!txId <-

0 commit comments

Comments
 (0)