Skip to content

Commit

Permalink
CAD-2166 node | LedgerQueries: add ledgerDelegMapSize
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire committed Dec 2, 2020
1 parent df847ed commit dde4d61
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cardano-node/src/Cardano/Tracing/Queries.hs
Expand Up @@ -27,10 +27,12 @@ import qualified Ouroboros.Consensus.Cardano.Block as Cardano


class LedgerQueries blk where
ledgerUtxoSize :: LedgerState blk -> Int
ledgerUtxoSize :: LedgerState blk -> Int
ledgerDelegMapSize :: LedgerState blk -> Int

instance LedgerQueries Byron.ByronBlock where
ledgerUtxoSize = Map.size . Byron.unUTxO . Byron.cvsUtxo . Byron.byronLedgerState
ledgerDelegMapSize _ = 0

instance LedgerQueries (Shelley.ShelleyBlock era) where
ledgerUtxoSize =
Expand All @@ -40,14 +42,28 @@ instance LedgerQueries (Shelley.ShelleyBlock era) where
. Shelley.esLState
. Shelley.nesEs
. Shelley.shelleyLedgerState
ledgerDelegMapSize =
Map.size
. Shelley._delegations
. Shelley._dstate
. Shelley._delegationState
. Shelley.esLState
. Shelley.nesEs
. Shelley.shelleyLedgerState

instance (LedgerQueries x, NoHardForks x)
=> LedgerQueries (HardForkBlock '[x]) where
ledgerUtxoSize = ledgerUtxoSize . project
ledgerDelegMapSize = ledgerDelegMapSize . project

instance LedgerQueries (Cardano.CardanoBlock c) where
ledgerUtxoSize = \case
Cardano.LedgerStateByron ledgerByron -> ledgerUtxoSize ledgerByron
Cardano.LedgerStateShelley ledgerShelley -> ledgerUtxoSize ledgerShelley
Cardano.LedgerStateAllegra ledgerAllegra -> ledgerUtxoSize ledgerAllegra
Cardano.LedgerStateMary ledgerMary -> ledgerUtxoSize ledgerMary
ledgerDelegMapSize = \case
Cardano.LedgerStateByron ledgerByron -> ledgerDelegMapSize ledgerByron
Cardano.LedgerStateShelley ledgerShelley -> ledgerDelegMapSize ledgerShelley
Cardano.LedgerStateAllegra ledgerAllegra -> ledgerDelegMapSize ledgerAllegra
Cardano.LedgerStateMary ledgerMary -> ledgerDelegMapSize ledgerMary

0 comments on commit dde4d61

Please sign in to comment.