Skip to content

Commit 2fad1b5

Browse files
committed
Fix inserting epoch_stake_progress
Fixes #1620
1 parent ca2f559 commit 2fad1b5

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

cardano-db-sync/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Revision history for cardano-db-sync
22

33
## 13.2.0.0
4+
* Added a new table `epoch_stake_progress` which indicates when `epoch_stake` is completed
45
* Uses the cache for the computation of `epoch` table when following
56
* `epoch_stake` is now computed earlier, before the epoch is reached
67
* Exception handling and concurrency improved.

cardano-db/src/Cardano/Db/Insert.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ import Database.Persist.Class (
113113
replaceUnique,
114114
)
115115
import Database.Persist.EntityDef.Internal (entityDB, entityUniques)
116+
import Database.Persist.Postgresql (upsertWhere)
116117
import Database.Persist.Sql (
117118
OnlyOneUniqueKey,
118119
PersistRecordBackend,
@@ -352,7 +353,7 @@ insertEpochStakeProgress =
352353

353354
updateSetComplete :: MonadIO m => Word64 -> ReaderT SqlBackend m ()
354355
updateSetComplete epoch = do
355-
updateWhere [EpochStakeProgressEpochNo Database.Persist.==. epoch] [EpochStakeProgressCompleted Database.Persist.=. True]
356+
upsertWhere (EpochStakeProgress epoch True) [EpochStakeProgressCompleted Database.Persist.=. True] [EpochStakeProgressEpochNo Database.Persist.==. epoch]
356357

357358
updateGovActionEnacted :: MonadIO m => GovActionProposalId -> Word64 -> ReaderT SqlBackend m ()
358359
updateGovActionEnacted gaid eNo =

cardano-db/src/Cardano/Db/Schema.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,11 @@ schemaDocs =
955955
EpochStakeAmount # "The amount (in Lovelace) being staked."
956956
EpochStakeEpochNo # "The epoch number."
957957

958+
EpochStakeProgress --^ do
959+
"A table which shows when the epoch_stake for an epoch is complete"
960+
EpochStakeProgressEpochNo # "The related epoch"
961+
EpochStakeProgressCompleted # "True if completed. If not completed the entry won't exist or more rarely be False."
962+
958963
Treasury --^ do
959964
"A table for payments from the treasury to a StakeAddress. Note: Before protocol version 5.0\
960965
\ (Alonzo) if more than one payment was made to a stake address in a single epoch, only the\

0 commit comments

Comments
 (0)