From 380a3139dd5c822968b8211ce3a18e6dbf6df6b3 Mon Sep 17 00:00:00 2001 From: Kostas Dermentzis Date: Thu, 17 Aug 2023 13:19:25 +0300 Subject: [PATCH] Improve comments --- cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs | 7 ++++--- cardano-db-sync/src/Cardano/DbSync/Fix/PlutusDataBytes.hs | 2 +- cardano-db-sync/src/Cardano/DbSync/Fix/PlutusScripts.hs | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs index 2017e3799..d9422383f 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs @@ -264,6 +264,8 @@ insertTx syncEnv isMember blkId epochNo slotNo depositsMap blockIndex tx grouped let !outSum = fromIntegral $ unCoin $ Generic.txOutSum tx !withdrawalSum = fromIntegral $ unCoin $ Generic.txWithdrawalSum tx hasConsumed <- liftIO $ getHasConsumed syncEnv + -- In some txs and with specific configuration we may be able to find necessary data within the tx body. + -- In these cases we can avoid expensive queries. (resolvedInputs, fees', deposits) <- case (mdeposits, unCoin <$> Generic.txFees tx) of (Just deposits, Just fees) -> do (resolvedInputs, _) <- splitLast <$> mapM (resolveTxInputs hasConsumed False (fst <$> groupedTxOut grouped)) (Generic.txInputs tx) @@ -503,7 +505,7 @@ insertCertificate tracer cache isMember network blkId txId epochNo slotNo redeem Left (ShelleyTxCertMir mir) -> insertMirCert tracer cache network txId idx mir Left (ShelleyTxCertGenesisDeleg _gen) -> liftIO $ logWarning tracer "insertCertificate: Unhandled DCertGenesis certificate" - Right (ConwayTxCertDeleg deleg) -> insertConwayDelegCert tracer cache network txId idx mRedeemerId epochNo slotNo deleg + Right (ConwayTxCertDeleg deleg) -> insertConwayDelegCert cache network txId idx mRedeemerId epochNo slotNo deleg Right (ConwayTxCertPool pool) -> insertPoolCert tracer cache isMember network epochNo blkId txId idx pool Right (ConwayTxCertCommittee c) -> case c of ConwayRegDRep cred coin -> @@ -618,7 +620,6 @@ insertDelegCert _tracer cache network txId idx mRedeemerId epochNo slotNo dCert insertConwayDelegCert :: (MonadBaseControl IO m, MonadIO m) => - Trace IO Text -> Cache -> Ledger.Network -> DB.TxId -> @@ -628,7 +629,7 @@ insertConwayDelegCert :: SlotNo -> ConwayDelegCert StandardCrypto -> ExceptT SyncNodeError (ReaderT SqlBackend m) () -insertConwayDelegCert _tracer cache network txId idx mRedeemerId epochNo slotNo dCert = +insertConwayDelegCert cache network txId idx mRedeemerId epochNo slotNo dCert = case dCert of ConwayRegCert cred _dep -> insertStakeRegistration epochNo txId idx $ Generic.annotateStakingCred network cred ConwayUnRegCert cred _dep -> insertStakeDeregistration cache network epochNo txId idx mRedeemerId cred diff --git a/cardano-db-sync/src/Cardano/DbSync/Fix/PlutusDataBytes.hs b/cardano-db-sync/src/Cardano/DbSync/Fix/PlutusDataBytes.hs index a1710c1af..8d0bcdd69 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Fix/PlutusDataBytes.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Fix/PlutusDataBytes.hs @@ -253,7 +253,7 @@ fixPlutusData tracer cblk fds = do scrapDatumsBlock :: CardanoBlock -> Map ByteString ByteString scrapDatumsBlock cblk = case cblk of - BlockConway _blk -> mempty -- This bug existed in a version that didn't support Conway + BlockConway _blk -> mempty -- This bug existed in a version that didn't support Conway or later eras BlockBabbage blk -> Map.unions $ scrapDatumsTxBabbage . snd <$> getTxs blk BlockAlonzo blk -> Map.unions $ scrapDatumsTxAlonzo . snd <$> getTxs blk BlockByron _ -> error "No Datums in Byron" diff --git a/cardano-db-sync/src/Cardano/DbSync/Fix/PlutusScripts.hs b/cardano-db-sync/src/Cardano/DbSync/Fix/PlutusScripts.hs index a1e57e19f..37f470050 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Fix/PlutusScripts.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Fix/PlutusScripts.hs @@ -147,7 +147,7 @@ scrapScriptBlock cblk = case cblk of BlockShelley _ -> error "No Plutus Scripts in Shelley" BlockAllegra _ -> error "No Plutus Scripts in Allegra" BlockMary _ -> error "No Plutus Scripts in Mary" - _ -> mempty -- This bug existed in a version that didn't support Conway + _ -> mempty -- This bug existed in a version that didn't support Conway or later eras scrapScriptTxBabbage :: Ledger.Tx StandardBabbage -> Map ByteString ByteString scrapScriptTxBabbage tx = Map.union txMap txOutMap