Skip to content

Commit 51d60fb

Browse files
committed
don't delete rewards on rollback, fix insertBulkOffChainVoteData
1 parent de74a96 commit 51d60fb

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ module Cardano.DbSync.Era.Universal.Insert.Grouped (
1414
insertBlockGroupedData,
1515
insertReverseIndex,
1616
resolveTxInputs,
17-
resolveTxInputsBulk,
1817
resolveScriptHash,
1918
mkmaTxOuts,
2019
) where
2120

2221
import qualified Data.List as List
23-
import qualified Data.Map.Strict as Map
2422
import qualified Data.Text as Text
2523

2624
import Cardano.BM.Trace (logWarning)

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ insertOffChainVoteResults trce resultQueue = do
200200
)
201201
metadata
202202
-- Insert and get IDs
203-
ids <-
204-
DB.runSession DB.mkDbCallStack $
205-
HsqlSes.statement deduplicatedMetadata DB.insertBulkOffChainVoteDataStmt
203+
ids <- DB.insertBulkOffChainVoteData deduplicatedMetadata
206204

207205
-- Return original data with IDs (note: length mismatch possible if duplicates were removed)
208206
pure $ zipWith (\(md, acc) id -> (md, acc, id)) metadataWithAccessors ids

cardano-db/src/Cardano/Db/Statement/Base.hs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -795,18 +795,15 @@ deleteUsingEpochNo trce epochN = do
795795
liftIO $ updateProgress (Just trce) progressRef 3 "Counting PoolStat records..."
796796
psc <- runSession mkDbCallStack $ HsqlSes.statement epochN (parameterisedCountWhere @SC.PoolStat "epoch_no" "> $1" epochEncoder)
797797

798-
liftIO $ updateProgress (Just trce) progressRef 4 "Counting Reward records..."
799-
rc <- runSession mkDbCallStack $ HsqlSes.statement epochN (parameterisedCountWhere @SC.Reward "spendable_epoch" "> $1" epochEncoder)
798+
liftIO $ updateProgress (Just trce) progressRef 4 "Count completed"
799+
pure (ec, dc, rrc, psc)
800800

801-
liftIO $ updateProgress (Just trce) progressRef 5 "Count completed"
802-
pure (ec, dc, rrc, psc, rc)
803-
804-
let (epochCount, drepCount, rewardRestCount, poolStatCount, rewardCount) = totalCounts
805-
totalRecords = epochCount + drepCount + rewardRestCount + poolStatCount + rewardCount
801+
let (epochCount, drepCount, rewardRestCount, poolStatCount) = totalCounts
802+
totalRecords = epochCount + drepCount + rewardRestCount + poolStatCount
806803
liftIO $ logInfo trce $ "Deleting " <> textShow totalRecords <> " records across 5 tables..."
807804

808805
-- Execute deletes with progress logging
809-
(epochDeletedCount, drepDeletedCount, rewardRestDeletedCount, poolStatDeletedCount, rewardDeletedCount) <-
806+
(epochDeletedCount, drepDeletedCount, rewardRestDeletedCount, poolStatDeletedCount) <-
810807
withProgress (Just trce) 5 "Deleting epoch records..." $ \progressRef -> do
811808
liftIO $ updateProgress (Just trce) progressRef 1 $ "Deleting " <> textShow epochCount <> " Epochs..."
812809
epochDeletedCount <- runSession mkDbCallStack $ HsqlSes.statement epochN (deleteWhereCount @SC.Epoch "no" "=" epochEncoder)
@@ -820,10 +817,7 @@ deleteUsingEpochNo trce epochN = do
820817
liftIO $ updateProgress (Just trce) progressRef 4 $ "Deleting " <> textShow poolStatCount <> " PoolStat records..."
821818
poolStatDeletedCount <- runSession mkDbCallStack $ HsqlSes.statement epochN (deleteWhereCount @SC.PoolStat "epoch_no" ">" epochEncoder)
822819

823-
liftIO $ updateProgress (Just trce) progressRef 5 $ "Deleting " <> textShow rewardCount <> " Rewards..."
824-
rewardDeletedCount <- runSession mkDbCallStack $ HsqlSes.statement epochN (deleteWhereCount @SC.Reward "spendable_epoch" ">" epochEncoder)
825-
826-
pure (epochDeletedCount, drepDeletedCount, rewardRestDeletedCount, poolStatDeletedCount, rewardDeletedCount)
820+
pure (epochDeletedCount, drepDeletedCount, rewardRestDeletedCount, poolStatDeletedCount)
827821

828822
liftIO $ logInfo trce "Setting null values for governance actions..."
829823
-- Null operations
@@ -838,11 +832,10 @@ deleteUsingEpochNo trce epochN = do
838832
, ("DrepDistr", drepDeletedCount)
839833
, ("RewardRest", rewardRestDeletedCount)
840834
, ("PoolStat", poolStatDeletedCount)
841-
, ("Reward", rewardDeletedCount)
842835
]
843836
nullLogs = [("GovActionProposal Nulled", nullTotal)]
844837

845-
liftIO $ logInfo trce $ "Rollback epoch deletion completed - actual deleted: " <> textShow (epochDeletedCount + drepDeletedCount + rewardRestDeletedCount + poolStatDeletedCount + rewardDeletedCount)
838+
liftIO $ logInfo trce $ "Rollback epoch deletion completed - actual deleted: " <> textShow (epochDeletedCount + drepDeletedCount + rewardRestDeletedCount + poolStatDeletedCount)
846839
pure $ countLogs <> nullLogs
847840

848841
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)