summaryrefslogtreecommitdiffhomepage
path: root/Hash.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-14 10:05:13 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-14 10:11:54 -0400
commitb5d5f86a88c8dbd1cee9e28a659bfe1c26f38eaa (patch)
tree1ea7fd10f9619ee20016190cb255c62d408611d5 /Hash.hs
parent2a271b27c65a286882332b6268e8946851c52f2a (diff)
downloaddebug-me-b5d5f86a88c8dbd1cee9e28a659bfe1c26f38eaa.tar.gz
improve JSON
Most of the time, ByteStrings will be able to be encoded as utf8, so avoid base64 when not needed. Adjusted some of the types in order to generate more usual JSON. In particular, removed StartActivity. The JSON now looks like this (with the signature still not populated): {"signature":{"v":""},"prevActivity":{"hashValue":{"v":"3b1abe614dd43bdb2d9a56777884e2d0f3bac9796e2d25c1ad52bb689c117286"},"hashMethod":"SHA256"},"activity":{"echoData":{"v":""},"enteredData":{"v":"l"}}} 203 bytes to send a single keystroke is not great when there's really only 1+64(hash) bytes of unique data. So, may end up adding a wire encoding on top of this. But, JSON is good to have for storage of the proofs, etc. Also, it does compress well. Two such JSON objects gzip -9 to 219 bytes, and three to 265 bytes. So, 37 bytes per keystroke. This is *exactly* as efficient as gzip -9 of $c$hash formatted data. This commit was sponsored by Jack Hill on Patreon.
Diffstat (limited to 'Hash.hs')
-rw-r--r--Hash.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/Hash.hs b/Hash.hs
index 4174d5f..f2b8d75 100644
--- a/Hash.hs
+++ b/Hash.hs
@@ -26,8 +26,8 @@ instance Hashable [HashPointer] where
hash = hash . B.concat . map (val . hashValue)
instance Hashable a => Hashable (Activity a) where
- hash (Activity a p s) = hash [hash a, p, hash s]
- hash (StartActivity a s) = hash [hash a, hash s]
+ hash (Activity a (Just p) s) = hash [hash a, p, hash s]
+ hash (Activity a Nothing s) = hash [hash a, hash s]
instance Hashable Entered where
hash v = hash [hash (enteredData v), hash (echoData v)]