|
@@ -104,6 +104,9 @@ class DirAuth(network.Server):
|
|
|
|
|
|
# We simulate the act of computing the consensus by keeping a
|
|
|
# class-static dict that's accessible to all of the dirauths
|
|
|
+ # This dict is indexed by epoch, and the value is itself a dict
|
|
|
+ # indexed by the stringified descriptor, with value of the number of
|
|
|
+ # dirauths that saw that descriptor.
|
|
|
uploadeddescs = dict()
|
|
|
|
|
|
def __init__(self, me, tot):
|
|
@@ -133,13 +136,17 @@ class DirAuth(network.Server):
|
|
|
def received(self, client, msg):
|
|
|
if isinstance(msg, DirAuthUploadDescMsg):
|
|
|
# Check the uploaded descriptor for sanity
|
|
|
- if msg.desc.descdict['epoch'] != network.thenetwork.getepoch() + 1:
|
|
|
+ epoch = msg.desc.descdict['epoch']
|
|
|
+ if epoch != network.thenetwork.getepoch() + 1:
|
|
|
return
|
|
|
+ # Store it in the class-static dict
|
|
|
+ if epoch not in DirAuth.uploadeddescs:
|
|
|
+ DirAuth.uploadeddescs[epoch] = dict()
|
|
|
descstr = str(msg.desc)
|
|
|
- if descstr not in DirAuth.uploadeddescs:
|
|
|
- DirAuth.uploadeddescs[descstr] = 1
|
|
|
+ if descstr not in DirAuth.uploadeddescs[epoch]:
|
|
|
+ DirAuth.uploadeddescs[epoch][descstr] = 1
|
|
|
else:
|
|
|
- DirAuth.uploadeddescs[descstr] += 1
|
|
|
+ DirAuth.uploadeddescs[epoch][descstr] += 1
|
|
|
elif isinstance(msg, DirAuthGetConsensusMsg):
|
|
|
client.sendmsg(DirAuthConsensusMsg(self.consensus))
|
|
|
elif isinstance(msg, DirAuthGetENDIVEMsg):
|