Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Cardano.DbSync.Era.Universal.Insert.LedgerEvent (
import Cardano.BM.Trace (logInfo)
import qualified Cardano.Db as DB
import Cardano.DbSync.Api
import Cardano.DbSync.Api.Types (SyncEnv (..))
import Cardano.DbSync.Api.Types (SyncEnv (..), InsertOptions (..))
import Cardano.DbSync.Cache.Types (textShowStats)
import Cardano.DbSync.Era.Cardano.Insert (insertEpochSyncTime)
import qualified Cardano.DbSync.Era.Shelley.Generic as Generic
Expand Down Expand Up @@ -50,6 +50,7 @@ insertNewEpochLedgerEvents syncEnv currentEpochNo@(EpochNo curEpoch) =
tracer = getTrace syncEnv
cache = envCache syncEnv
ntw = getNetwork syncEnv
    iopts = getInsertOptions syncEnv

subFromCurrentEpoch :: Word64 -> EpochNo
subFromCurrentEpoch m =
Expand Down Expand Up @@ -94,20 +95,21 @@ insertNewEpochLedgerEvents syncEnv currentEpochNo@(EpochNo curEpoch) =
lift $ validateEpochRewards tracer ntw (subFromCurrentEpoch 2) currentEpochNo rwd
LedgerAdaPots _ ->
pure () -- These are handled separately by insertBlock
LedgerGovInfo enacted dropped expired uncl -> do
unless (Set.null uncl) $
liftIO $
logInfo tracer $
"Found " <> textShow (Set.size uncl) <> " unclaimed proposal refunds"
updateDropped cache (EpochNo curEpoch) (garGovActionId <$> (dropped <> expired))
let refunded = filter (\e -> Set.notMember (garGovActionId e) uncl) (enacted <> dropped <> expired)
insertProposalRefunds tracer ntw (subFromCurrentEpoch 1) currentEpochNo cache refunded -- TODO: check if they are disjoint to avoid double entries.
forM_ enacted $ \gar -> do
gaId <- resolveGovActionProposal cache (garGovActionId gar)
lift $ void $ DB.updateGovActionEnacted gaId (unEpochNo currentEpochNo)
whenJust (garMTreasury gar) $ \treasuryMap -> do
let rewards = Map.mapKeys Ledger.raCredential $ Map.map (Set.singleton . mkTreasuryReward) treasuryMap
insertRewardRests tracer ntw (subFromCurrentEpoch 1) currentEpochNo cache (Map.toList rewards)
        LedgerGovInfo enacted dropped expired uncl -> do
          when (ioGov iopts) $ do
            unless (Set.null uncl) $
              liftIO $
                logInfo tracer $
                  "Found " <> textShow (Set.size uncl) <> " unclaimed proposal refunds"
            updateDropped cache (EpochNo curEpoch) (garGovActionId <$> (dropped <> expired))
            let refunded = filter (\e -> Set.notMember (garGovActionId e) uncl) (enacted <> dropped <> expired)
            insertProposalRefunds tracer ntw (subFromCurrentEpoch 1) currentEpochNo cache refunded -- TODO: check if they are disjoint to avoid double entries.
            forM_ enacted $ \gar -> do
              gaId <- resolveGovActionProposal cache (garGovActionId gar)
              lift $ void $ DB.updateGovActionEnacted gaId (unEpochNo currentEpochNo)
              whenJust (garMTreasury gar) $ \treasuryMap -> do
                let rewards = Map.mapKeys Ledger.raCredential $ Map.map (Set.singleton . mkTreasuryReward) treasuryMap
                insertRewardRests tracer ntw (subFromCurrentEpoch 1) currentEpochNo cache (Map.toList rewards)
LedgerMirDist rwd -> do
unless (Map.null rwd) $ do
let rewards = Map.toList rwd
Expand Down
Loading