summaryrefslogtreecommitdiffhomepage
path: root/Types/Cost.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-08-17 14:28:33 -0400
committerJoey Hess <joeyh@joeyh.name>2016-08-17 14:28:33 -0400
commitf60ac335e4e827fd242ab22539adb49f26e2c319 (patch)
tree255e16e03210b9ccb6faf72b4afd29b7262f42d9 /Types/Cost.hs
parentb474ab87ae45ed77f42eb41f658a55262bd92217 (diff)
downloadkeysafe-f60ac335e4e827fd242ab22539adb49f26e2c319.tar.gz
add progress bars to restore
also, restore actually works!
Diffstat (limited to 'Types/Cost.hs')
-rw-r--r--Types/Cost.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Types/Cost.hs b/Types/Cost.hs
index 2f181a2..2aa6ee7 100644
--- a/Types/Cost.hs
+++ b/Types/Cost.hs
@@ -34,11 +34,24 @@ instance Monoid (Cost t) where
mapCost :: (Integer -> Integer) -> Cost op -> Cost op
mapCost f (CPUCost (Seconds n)) = CPUCost (Seconds (f n))
+showCostMinutes :: Cost op -> String
+showCostMinutes (CPUCost (Seconds n))
+ | n < 61 = "1 minute"
+ | otherwise = show (n `div` 60) ++ " minutes"
+
-- | Operations whose cost can be measured.
data DecryptionOp
data CreationOp
data BruteForceOp
+-- | Things that track their creation cost.
+class HasCreationCost t where
+ getCreationCost :: t -> Cost CreationOp
+
+-- | Things that track their decryption cost.
+class HasDecryptionCost t where
+ getDecryptionCost :: t -> Cost DecryptionOp
+
-- | Calculation of a cost that depends on some amount of entropy.
type CostCalc op t = Entropy t -> Cost op