summaryrefslogtreecommitdiff
path: root/lib/KeyDB.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/KeyDB.hs')
-rw-r--r--lib/KeyDB.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/KeyDB.hs b/lib/KeyDB.hs
index fc20b91..f785f8e 100644
--- a/lib/KeyDB.hs
+++ b/lib/KeyDB.hs
@@ -76,11 +76,18 @@ fingerprintGrip (Fingerprint bs) =
76 -- -- The above was removed because Int is encoded as 8 bytes even when we are 76 -- -- The above was removed because Int is encoded as 8 bytes even when we are
77 -- -- using 32-bit GHC. 77 -- -- using 32-bit GHC.
78 -- Presumably, the extra 4 bytes will be truncated. 78 -- Presumably, the extra 4 bytes will be truncated.
79 case decode $ L.fromStrict $ S.drop (S.length bs - 8) bs of 79 case S.length bs of
80 i -> KeyInt i 80 -- v5 from the front
81 32 -> case decode $ L.fromStrict bs of
82 i -> KeyInt i
83 -- v4 from the back
84 l -> case decode $ L.fromStrict $ S.drop (l - 8) bs of
85 i -> KeyInt i
81 86
82smallprGrip :: String -> Maybe KeyGrip 87smallprGrip :: String -> Maybe KeyGrip
83smallprGrip pr = KeyInt <$> readMaybe ("0x" ++ drop (length pr - 2 * sizeOf (0::Int)) pr) 88smallprGrip pr = case length pr of
89 64 -> KeyInt <$> readMaybe ("0x" ++ take (2 * sizeOf (0::Int)) pr)
90 l -> KeyInt <$> readMaybe ("0x" ++ drop (l - 2 * sizeOf (0::Int)) pr)
84 91
85data KeyDB = KeyDB 92data KeyDB = KeyDB
86 { byKeyKey :: Map.Map KeyKey KeyData 93 { byKeyKey :: Map.Map KeyKey KeyData