fixed default storage culling bug, linted, bumped version to 0.4

This commit is contained in:
Brian Muller 2015-01-04 14:40:52 -05:00
parent c6f1062082
commit ae7a90926b
6 changed files with 8 additions and 9 deletions

View File

@ -3,5 +3,5 @@ Kademlia is a Python implementation of the Kademlia protocol for U{Twisted <http
@author: Brian Muller U{bamuller@gmail.com}
"""
version_info = (0, 3)
version_info = (0, 4)
version = '.'.join(map(str, version_info))

View File

@ -187,7 +187,7 @@ class Server(object):
"""
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'])
@ -199,7 +199,7 @@ class Server(object):
"""
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

@ -60,7 +60,7 @@ class NodeHeap(object):
return
nheap = []
for distance, node in self.heap:
if not node.id in peerIDs:
if node.id not in peerIDs:
heapq.heappush(nheap, (distance, node))
self.heap = nheap
@ -105,4 +105,4 @@ class NodeHeap(object):
return iter(map(itemgetter(1), nodes))
def getUncontacted(self):
return [n for n in self if not n.id in self.contacted]
return [n for n in self if n.id not in self.contacted]

View File

@ -30,7 +30,7 @@ class KBucket(object):
return (one, two)
def removeNode(self, node):
if not node.id in self.nodes:
if node.id not in self.nodes:
return
# delete node, and see if we can add a replacement

View File

@ -58,7 +58,7 @@ class ForgetfulStorage(object):
def cull(self):
for k, v in self.iteritemsOlderThan(self.ttl):
self.data.popitem(first=True)
self.data.popitem(last=False)
def get(self, key, default=None):
self.cull()

View File

@ -1,7 +1,6 @@
from twisted.trial import unittest
from kademlia.routing import KBucket, RoutingTable
from kademlia.protocol import KademliaProtocol
from kademlia.routing import KBucket
from kademlia.tests.utils import mknode, FakeProtocol