viff

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 diff
     1.1 --- a/viff/hash_broadcast.py	Fri Oct 09 11:39:54 2009 +0200
     1.2 +++ b/viff/hash_broadcast.py	Fri Oct 09 12:21:14 2009 +0200
     1.3 @@ -54,7 +54,7 @@
     1.4              signals[peer_id] = long(signal)
     1.5              # If all signals are received then check if they are OK or INCONSISTENTHASH.
     1.6              if num_receivers == len(signals.keys()):
     1.7 -                s = reduce(lambda x, y: OK if OK == y else INCONSISTENTHASH, signals.values())
     1.8 +                s = reduce(lambda x, y: (OK == y and OK) or INCONSISTENTHASH, signals.values())
     1.9                  if OK == s:
    1.10                      # Make the result ready.
    1.11                      result.callback(message[0])
    1.12 @@ -69,7 +69,10 @@
    1.13                  signal = OK
    1.14                  # First we check if the hashes we received are equal to the hash we computed ourselves.
    1.15                  for peer_id in receivers:
    1.16 -                    signal = signal if a_hashes[peer_id] == a_hashes[self.id] else INCONSISTENTHASH
    1.17 +                    if a_hashes[peer_id] == a_hashes[self.id]:
    1.18 +                        signal = signal
    1.19 +                    else:
    1.20 +                        signal = INCONSISTENTHASH
    1.21                  # Then we send the SAME signal to everybody. 
    1.22                  for peer_id in receivers:
    1.23                      self.protocols[peer_id].sendData(unique_pc, SIGNAL, str(signal))