Skip to content

Commit

Permalink
fix value size
Browse files Browse the repository at this point in the history
  • Loading branch information
polinavino committed Jan 14, 2021
1 parent 8b90959 commit b7334f2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions shelley-ma/impl/src/Cardano/Ledger/Mary/Value.hs
Expand Up @@ -184,14 +184,14 @@ instance CC.Crypto crypto => Val (Value crypto) where
| otherwise =
fromIntegral $ wordLength * (adaWords + noMAs) + repSize
where
repSize = wordLength * quanSize * totalNoAssets + noPIDs * (index * wordLength + pidLength)
repSize = wordLength * quanSize * totalNoAssets + totalNoAssets * (index * wordLength) + pidLength * noPIDs
+ totalNoAssets * (index * wordLength) + assetNamesLength
where
noPIDs = length $ Map.keys v
allAssets :: [AssetName]
allAssets = (Map.foldr (\a b -> (Map.keys a) ++ b) [] v)
totalNoAssets = length allAssets
assetNames = LS.nub allAssets
assetNames = LS.nub $ LS.sort allAssets
noAssetNames = length assetNames
assetNamesLength = LS.foldr (\(AssetName a) b -> (BS.length a) + b) 0 assetNames

Expand All @@ -206,17 +206,17 @@ adaWords = 2

-- number of words used to represent quantity
quanSize :: Int
quanSize = 2
quanSize = 1

-- number of words bytes to represent index
-- number of bytes to represent index
index :: Int
index = 4
index = 2

-- number of words used to store number of MAs in a value
noMAs :: Int
noMAs = 2
noMAs = 1

-- number of words used to store a PID
-- length of PID in bytes
pidLength :: Int
pidLength = 28

Expand Down

0 comments on commit b7334f2

Please sign in to comment.