From 2823b3067271f241c464c7dfe0c07efc9cccbec8 Mon Sep 17 00:00:00 2001 From: Brian Muller Date: Sun, 19 Jan 2014 23:22:40 -0500 Subject: [PATCH] updated some docs --- kademlia/network.py | 11 +++++++++++ kademlia/node.py | 3 +++ 2 files changed, 14 insertions(+) diff --git a/kademlia/network.py b/kademlia/network.py index 77e80b0..8ee402c 100644 --- a/kademlia/network.py +++ b/kademlia/network.py @@ -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. diff --git a/kademlia/node.py b/kademlia/node.py index ddec9d4..4057f1d 100644 --- a/kademlia/node.py +++ b/kademlia/node.py @@ -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):