viff

changeset 600:9b04a55123de

Standardize on the name "peer_id" instead of just "id".
author Martin Geisler <mg@daimi.au.dk>
date Mon, 24 Mar 2008 13:14:17 +0100
parents 46bd23052806
children 1ad9f7991c7c
files viff/runtime.py
diffstat 1 files changed, 18 insertions(+), 18 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Mon Mar 24 01:04:29 2008 +0100
     1.2 +++ b/viff/runtime.py	Mon Mar 24 13:14:17 2008 +0100
     1.3 @@ -554,7 +554,7 @@
     1.4              # We have already received the data from the other side.
     1.5              deferred.callback(data)
     1.6  
     1.7 -    def _exchange_shares(self, id, field_element):
     1.8 +    def _exchange_shares(self, peer_id, field_element):
     1.9          """Exchange shares with another player.
    1.10  
    1.11          We send the player our share and record a Deferred which will
    1.12 @@ -562,11 +562,11 @@
    1.13          """
    1.14          assert isinstance(field_element, FieldElement)
    1.15  
    1.16 -        if id == self.id:
    1.17 +        if peer_id == self.id:
    1.18              return Share(self, field_element.field, field_element)
    1.19          else:
    1.20 -            share = self._expect_share(id, field_element.field)
    1.21 -            self.protocols[id].sendShare(field_element)
    1.22 +            share = self._expect_share(peer_id, field_element.field)
    1.23 +            self.protocols[peer_id].sendShare(field_element)
    1.24              return share
    1.25  
    1.26      def _expect_share(self, peer_id, field):
    1.27 @@ -638,18 +638,18 @@
    1.28  
    1.29          def exchange(share):
    1.30              # Send share to all receivers.
    1.31 -            for id in receivers:
    1.32 -                if id != self.id:
    1.33 -                    self.protocols[id].sendShare(share)
    1.34 +            for peer_id in receivers:
    1.35 +                if peer_id != self.id:
    1.36 +                    self.protocols[peer_id].sendShare(share)
    1.37              # Receive and recombine shares if this player is a receiver.
    1.38              if self.id in receivers:
    1.39                  deferreds = []
    1.40 -                for id in self.players:
    1.41 -                    if id == self.id:
    1.42 -                        d = Share(self, share.field, (share.field(id), share))
    1.43 +                for peer_id in self.players:
    1.44 +                    if peer_id == self.id:
    1.45 +                        d = Share(self, share.field, (share.field(peer_id), share))
    1.46                      else:
    1.47 -                        d = self._expect_share(id, share.field)
    1.48 -                        self.schedule_callback(d, lambda s, id: (s.field(id), s), id)
    1.49 +                        d = self._expect_share(peer_id, share.field)
    1.50 +                        self.schedule_callback(d, lambda s, peer_id: (s.field(peer_id), s), peer_id)
    1.51                      deferreds.append(d)
    1.52                  # TODO: This list ought to trigger as soon as more than
    1.53                  # threshold shares has been received.
    1.54 @@ -787,9 +787,9 @@
    1.55              correction = element - shared
    1.56              # if this player is inputter then broadcast correction value
    1.57              # TODO: more efficient broadcast?
    1.58 -            for id in self.players:
    1.59 -                if self.id != id:
    1.60 -                    self.protocols[id].sendShare(correction)
    1.61 +            for peer_id in self.players:
    1.62 +                if self.id != peer_id:
    1.63 +                    self.protocols[peer_id].sendShare(correction)
    1.64  
    1.65          # Receive correction value from inputters and compute share.
    1.66          result = []
    1.67 @@ -858,9 +858,9 @@
    1.68          #println("Shares of %s: %s", number, shares)
    1.69  
    1.70          result = []
    1.71 -        for other_id, share in shares:
    1.72 -            d = self._exchange_shares(other_id.value, share)
    1.73 -            d.addCallback(lambda share, id: (id, share), other_id)
    1.74 +        for peer_id, share in shares:
    1.75 +            d = self._exchange_shares(peer_id.value, share)
    1.76 +            d.addCallback(lambda share, peer_id: (peer_id, share), peer_id)
    1.77              result.append(d)
    1.78  
    1.79          return result