Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Closes: #947
  • Loading branch information
erikd committed Nov 15, 2021
1 parent 7215cee commit 8998f36
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
10 changes: 5 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ source-repository-package

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: 4347e54b2827090e898702ccfb93cc731b4a1909
--sha256: 057c7ci1sd2fb76z3ly447j5y8695yifyml2h2b879qfa7xpwkxd
location: https://github.com/input-output-hk/cardano-ledger
tag: 70cfbf9be79533a6d1b2ff446567f5b78bf945aa
--sha256: 03jnfz1zgd1r64va60nx2q6q7v7sdc2c7vhy5lm7kcjgakci27x1
subdir:
eras/alonzo/impl
-- eras/alonzo/test-suite
Expand All @@ -146,8 +146,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-node
tag: 7500d03fd58d07ed3427a6b8da10f5977a095d1f
--sha256: 0ags8qsfwdyif96mbk47qay78bybpd6jrs7snh6d9mnscy74xfnp
tag: dcf41b744957bba1aa0c140b5ba191798547b499
--sha256: 0xdfkk79dwm2hznl5iczr8v4c7j3l2vmg220bmvv4nb7wdr6951m
subdir:
cardano-api
cardano-node
Expand Down
9 changes: 4 additions & 5 deletions cardano-db-tool/src/Cardano/Db/Tool/Validate/Balance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Cardano.Chain.Common (CompactAddress, Lovelace, decodeAddressBa
import qualified Cardano.Chain.UTxO as Byron

import Cardano.Ledger.Address (BootstrapAddress (..))
import Cardano.Ledger.Alonzo (AlonzoEra)
import qualified Cardano.Ledger.Alonzo.TxBody as Alonzo
import qualified Cardano.Ledger.Core as Ledger
import Cardano.Ledger.Era (Crypto)
Expand Down Expand Up @@ -77,15 +78,13 @@ getShelleyBalance addrText utxo = do
then Just $ coin (fromCompact v)
else Nothing

getAlonzoBalance
:: forall era. (Crypto era ~ StandardCrypto, Ledger.TxOut era ~ Alonzo.TxOut era)
=> Compactible (Ledger.Value era) => Val (Ledger.Value era)
=> Text -> Shelley.UTxO era -> Either Text Word64
getAlonzoBalance :: Text -> Shelley.UTxO (AlonzoEra StandardCrypto) -> Either Text Word64
getAlonzoBalance addrText utxo = do
caddr <- covertToCompactAddress addrText
Right . fromIntegral . sum $ unCoin <$> mapMaybe (compactTxOutValue caddr) (Map.elems $ Shelley.unUTxO utxo)
where
compactTxOutValue :: CompactAddr (Crypto era) -> Ledger.TxOut era -> Maybe Coin
compactTxOutValue
:: CompactAddr (Crypto (AlonzoEra StandardCrypto)) -> Alonzo.TxOut (AlonzoEra StandardCrypto) -> Maybe Coin
compactTxOutValue caddr txOut =
let (scaddr, val) = case txOut of
Alonzo.TxOutCompact a v -> (a, v)
Expand Down
1 change: 1 addition & 0 deletions cardano-sync/cardano-sync.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ library
, cardano-protocol-tpraos
, cardano-slotting
, cborg
, compact-map
, containers
, contra-tracer
, directory
Expand Down
13 changes: 11 additions & 2 deletions cardano-sync/src/Cardano/Sync/Era/Shelley/Generic/StakeDist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import Cardano.Crypto.Hash (hashToBytes)

import qualified Cardano.Ledger.BaseTypes as Ledger
import Cardano.Ledger.Coin (Coin (..))
import qualified Cardano.Ledger.Compactible as Ledger
import Cardano.Ledger.Credential (Credential)
import Cardano.Ledger.Era (Crypto)
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..))
import qualified Cardano.Ledger.Shelley.EpochBoundary as Shelley
Expand All @@ -25,6 +27,7 @@ import Cardano.Sync.Era.Shelley.Generic.StakeCred
import Cardano.Sync.Era.Shelley.Generic.StakePoolKeyHash
import Cardano.Sync.Types

import qualified Data.Compact.VMap as VMap
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set

Expand Down Expand Up @@ -69,10 +72,16 @@ genericStakeDist network epoch lstate =
stakeMap = Map.intersectionWith (,) stakeCoinMap stakePoolMap

stakeCoinMap :: Map StakeCred Coin
stakeCoinMap = Map.mapKeys (toStakeCred network) . Shelley.unStake $ Shelley._stake stakeSet
stakeCoinMap = mapBimap (toStakeCred network) Ledger.fromCompact stMap

stMap :: Map (Credential 'Staking (Crypto era)) (Ledger.CompactForm Coin)
stMap = VMap.toMap . Shelley.unStake $ Shelley._stake stakeSet

stakePoolMap :: Map StakeCred StakePoolKeyHash
stakePoolMap = mapBimap (toStakeCred network) convertStakePoolkeyHash $ Shelley._delegations stakeSet
stakePoolMap = mapBimap (toStakeCred network) convertStakePoolkeyHash delMap

delMap :: Map (Credential 'Staking (Crypto era)) (KeyHash 'StakePool (Crypto era))
delMap = VMap.toMap $ Shelley._delegations stakeSet

-- We use '_pstakeSet' here instead of '_pstateMark' because the stake addresses for the
-- later may not have been added to the database yet. That means that when these values
Expand Down

0 comments on commit 8998f36

Please sign in to comment.