updated some docs

This commit is contained in:
Brian Muller 2014-01-19 23:22:40 -05:00
parent 8aab226598
commit 2823b30672
2 changed files with 14 additions and 0 deletions

View File

@ -168,6 +168,10 @@ class Server(object):
return False
def saveState(self, fname):
"""
Save the state of this node (the alpha/ksize/id/immediate neighbors)
to a cache file with the given fname.
"""
data = { 'ksize': self.ksize,
'alpha': self.alpha,
'id': self.node.id,
@ -177,6 +181,10 @@ class Server(object):
@classmethod
def loadState(self, fname):
"""
Load the state of this node (the alpha/ksize/id/immediate neighbors)
from a cache file with the given fname.
"""
with open(fname, 'r') as f:
data = pickle.load(f)
s = Server(data['ksize'], data['alpha'], data['id'])
@ -186,6 +194,9 @@ class Server(object):
def saveStateRegularly(self, fname, frequency=600):
"""
Save the state of node with a given regularity to the given
filename.
@param fname: File to save retularly to
@param frequencey: Frequency in seconds that the state
should be saved. By default, 10 minutes.

View File

@ -13,6 +13,9 @@ class Node:
return self.ip == node.ip and self.port == node.port
def distanceTo(self, node):
"""
Get the distance between this node and another.
"""
return self.long_id ^ node.long_id
def __iter__(self):