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

@ -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