Browse Source

Merklelib's proofs pickle to unreasonably large bytearrays

Extract just the important data as the auth field of SNIPs in
Merkle mode.
Ian Goldberg 4 years ago
parent
commit
08b497f376
2 changed files with 6 additions and 3 deletions
  1. 5 3
      dirauth.py
  2. 1 0
      network.py

+ 5 - 3
dirauth.py

@@ -113,7 +113,9 @@ class SNIP:
                     snip.snipdict["auth"])
         else:
             assert(merklelib.verify_leaf_inclusion(
-                    snip.__str__(False), snip.snipdict["auth"],
+                    snip.__str__(False),
+                    [merklelib.AuditNode(p[0], p[1])
+                        for p in snip.snipdict["auth"]],
                     merklelib.Hasher(), consensus.consdict["merkleroot"]))
 
 
@@ -315,8 +317,8 @@ class RelayPicker:
             # do it now, and store it in the SNIP so that the client
             # will get it.
             if "auth" not in r.snipdict:
-                r.snipdict["auth"] = \
-                        self.merkletree.get_proof(r.__str__(False))
+                r.snipdict["auth"] = [ (p.hash, p.type) for p in \
+                        self.merkletree.get_proof(r.__str__(False))._nodes]
         return r
 
     def pick_weighted_relay(self):

+ 1 - 0
network.py

@@ -320,6 +320,7 @@ class NetMsg:
             sz = sympy.symbols(type(self).__name__)
         else:
             sz = len(pickle.dumps(self))
+            # logging.info("%s size %d", type(self).__name__, sz)
 
         return sz