# HG changeset patch
# User Sigurd Meldgaard <[EMAIL PROTECTED]>
# Date 1221574030 -7200
# Node ID 11c959556ba30162a738ec851ac671e804922384
# Parent 9f166758d6536eafa20326c840bd5e0278d5e4b1
Added viff.runtime.make_runtime_class
This is a funtion that creates a new runtime class with mixins
diff -r 9f166758d653 -r 11c959556ba3 viff/runtime.py
--- a/viff/runtime.py Tue Sep 16 16:11:10 2008 +0200
+++ b/viff/runtime.py Tue Sep 16 16:07:10 2008 +0200
@@ -354,7 +354,7 @@
def clientConnectionLost(self, connector, reason):
reason.trap(ConnectionDone)
-
+
def increment_pc(method):
"""Make *method* automatically increment the program counter.
@@ -532,7 +532,7 @@
print "done."
sync = self.synchronize()
- sync.addCallback(close_connections)
+ sync.addCallback(close_connections)
sync.addCallback(stop_reactor)
return sync
@@ -832,7 +832,7 @@
@increment_pc
def prss_share(self, inputters, field, element=None):
"""Creates pseudo-random secret sharings.
-
+
This protocol creates a secret sharing for each player in the
subset of players specified in *inputters*. Each inputter
provides an integer. The result is a list of shares, one for
@@ -1079,6 +1079,22 @@
result.addCallback(shamir.recombine)
return result
+def make_runtime_class(runtime_class=Runtime, mixins=None):
+ """Creates a new runtime class with *runtime_class* as a base
+ class mixing in the *mixins*.
+
+ *mixins* must be a list or tuple of mixin-classes.
+ """
+
+ if mixins==None:
+ return runtime_class
+ else:
+ # We must include at least one new-style class in bases. We
+ # include it last to avoid overriding __init__ from the other base
+ # classes.
+ bases = (runtime_class,) + tuple(mixins) + (object,)
+
+ return type("ExtendedRuntime", bases, {})
def create_runtime(id, players, threshold, options=None,
runtime_class=Runtime):
"""Create a :class:`Runtime` and connect to the other players.
_______________________________________________
viff-patches mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-patches-viff.dk