[input-output-hk/cardano-sl] [CO-347] Wallet’s UTXO histogram view (#3402)

paweljakubas commented on this pull request.

> +
+toMap :: [HistogramBar] -> Map Text Word64
+toMap = Map.fromList . map (\(HistogramBarCount key val) -> (key,val))
+
+instance Eq UtxoStatistics where
+ (UtxoStatistics h s) == (UtxoStatistics h’ s’) = s == s’ && toMap h == toMap h’
+
+instance ToJSON UtxoStatistics where
+ toJSON (UtxoStatistics bars allStakes) =
+ let histogramObject = Object . HMS.fromList . map extractBarKey
+ extractBarKey (HistogramBarCount bound stake) = bound .= stake
+ in object [ «histogram» .= histogramObject bars
+ , «allStakes» .= allStakes ]
+
+instance FromJSON UtxoStatistics where
+ parseJSON (Object v) =

refactored as suggested

Добавить комментарий