summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-10-27 11:19:15 +0000
committerMark Haines <mark.haines@matrix.org>2014-10-27 11:19:15 +0000
commit5e2236f9ffe3a66bbe0ff37b1793e8fa59a1c475 (patch)
treed1b2661f80d38cdf2b29c18fe064b03204761376 /synapse
parentMerge branch 'develop' into event_signing (diff)
downloadsynapse-5e2236f9ffe3a66bbe0ff37b1793e8fa59a1c475.tar.xz
fix pyflakes warnings
Diffstat (limited to 'synapse')
-rw-r--r--synapse/crypto/event_signing.py8
-rw-r--r--synapse/federation/units.py2
-rw-r--r--synapse/storage/signatures.py2
3 files changed, 6 insertions, 6 deletions
diff --git a/synapse/crypto/event_signing.py b/synapse/crypto/event_signing.py
index d3b501c6e7..61edd2c6f9 100644
--- a/synapse/crypto/event_signing.py
+++ b/synapse/crypto/event_signing.py
@@ -35,12 +35,12 @@ def add_event_pdu_content_hash(pdu, hash_algorithm=hashlib.sha256):
 
 def check_event_pdu_content_hash(pdu, hash_algorithm=hashlib.sha256):
     """Check whether the hash for this PDU matches the contents"""
-    computed_hash = _compute_content_hash(pdu, hash_algortithm)
+    computed_hash = _compute_content_hash(pdu, hash_algorithm)
     if computed_hash.name not in pdu.hashes:
         raise Exception("Algorithm %s not in hashes %s" % (
             computed_hash.name, list(pdu.hashes)
         ))
-    message_hash_base64 = hashes[computed_hash.name]
+    message_hash_base64 = pdu.hashes[computed_hash.name]
     try:
         message_hash_bytes = decode_base64(message_hash_base64)
     except:
@@ -54,7 +54,7 @@ def _compute_content_hash(pdu, hash_algorithm):
     pdu_json.pop("age_ts", None)
     pdu_json.pop("unsigned", None)
     pdu_json.pop("signatures", None)
-    hashes = pdu_json.pop("hashes", {})
+    pdu_json.pop("hashes", None)
     pdu_json_bytes = encode_canonical_json(pdu_json)
     return hash_algorithm(pdu_json_bytes)
 
@@ -73,7 +73,7 @@ def sign_event_pdu(pdu, signature_name, signing_key):
     tmp_pdu = Pdu(**pdu.get_dict())
     tmp_pdu = prune_pdu(tmp_pdu)
     pdu_json = tmp_pdu.get_dict()
-    pdu_jdon = sign_json(pdu_json, signature_name, signing_key)
+    pdu_json = sign_json(pdu_json, signature_name, signing_key)
     pdu.signatures = pdu_json["signatures"]
     return pdu
 
diff --git a/synapse/federation/units.py b/synapse/federation/units.py
index b779d259bd..adc3385644 100644
--- a/synapse/federation/units.py
+++ b/synapse/federation/units.py
@@ -155,6 +155,8 @@ class Pdu(JsonEncodedObject):
 
             return Pdu(
                 prev_pdus=prev_pdus,
+                hashes=hashes,
+                signatures=signatures,
                 **args
             )
         else:
diff --git a/synapse/storage/signatures.py b/synapse/storage/signatures.py
index 85eec7ffbe..82be946d3f 100644
--- a/synapse/storage/signatures.py
+++ b/synapse/storage/signatures.py
@@ -15,8 +15,6 @@
 
 from _base import SQLBaseStore
 
-from twisted.internet import defer
-
 
 class SignatureStore(SQLBaseStore):
     """Persistence for PDU signatures and hashes"""