changeset 1266:a1193532c181

Made hashbroadcast.py Python 2.4 compliant.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Fri, 09 Oct 2009 12:21:14 +0200
parents 4045c231587a
children 8d213ad683c2
files viff/hash_broadcast.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/viff/hash_broadcast.py	Fri Oct 09 11:39:54 2009 +0200
+++ b/viff/hash_broadcast.py	Fri Oct 09 12:21:14 2009 +0200
@@ -54,7 +54,7 @@
             signals[peer_id] = long(signal)
             # If all signals are received then check if they are OK or INCONSISTENTHASH.
             if num_receivers == len(signals.keys()):
-                s = reduce(lambda x, y: OK if OK == y else INCONSISTENTHASH, signals.values())
+                s = reduce(lambda x, y: (OK == y and OK) or INCONSISTENTHASH, signals.values())
                 if OK == s:
                     # Make the result ready.
                     result.callback(message[0])
@@ -69,7 +69,10 @@
                 signal = OK
                 # First we check if the hashes we received are equal to the hash we computed ourselves.
                 for peer_id in receivers:
-                    signal = signal if a_hashes[peer_id] == a_hashes[self.id] else INCONSISTENTHASH
+                    if a_hashes[peer_id] == a_hashes[self.id]:
+                        signal = signal
+                    else:
+                        signal = INCONSISTENTHASH
                 # Then we send the SAME signal to everybody. 
                 for peer_id in receivers:
                     self.protocols[peer_id].sendData(unique_pc, SIGNAL, str(signal))