fixed default storage culling bug, linted, bumped version to 0.4
This commit is contained in:
parent
c6f1062082
commit
ae7a90926b
@ -3,5 +3,5 @@ Kademlia is a Python implementation of the Kademlia protocol for U{Twisted <http
|
|||||||
|
|
||||||
@author: Brian Muller U{bamuller@gmail.com}
|
@author: Brian Muller U{bamuller@gmail.com}
|
||||||
"""
|
"""
|
||||||
version_info = (0, 3)
|
version_info = (0, 4)
|
||||||
version = '.'.join(map(str, version_info))
|
version = '.'.join(map(str, version_info))
|
||||||
|
@ -60,7 +60,7 @@ class NodeHeap(object):
|
|||||||
return
|
return
|
||||||
nheap = []
|
nheap = []
|
||||||
for distance, node in self.heap:
|
for distance, node in self.heap:
|
||||||
if not node.id in peerIDs:
|
if node.id not in peerIDs:
|
||||||
heapq.heappush(nheap, (distance, node))
|
heapq.heappush(nheap, (distance, node))
|
||||||
self.heap = nheap
|
self.heap = nheap
|
||||||
|
|
||||||
@ -105,4 +105,4 @@ class NodeHeap(object):
|
|||||||
return iter(map(itemgetter(1), nodes))
|
return iter(map(itemgetter(1), nodes))
|
||||||
|
|
||||||
def getUncontacted(self):
|
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]
|
||||||
|
@ -30,7 +30,7 @@ class KBucket(object):
|
|||||||
return (one, two)
|
return (one, two)
|
||||||
|
|
||||||
def removeNode(self, node):
|
def removeNode(self, node):
|
||||||
if not node.id in self.nodes:
|
if node.id not in self.nodes:
|
||||||
return
|
return
|
||||||
|
|
||||||
# delete node, and see if we can add a replacement
|
# delete node, and see if we can add a replacement
|
||||||
|
@ -58,7 +58,7 @@ class ForgetfulStorage(object):
|
|||||||
|
|
||||||
def cull(self):
|
def cull(self):
|
||||||
for k, v in self.iteritemsOlderThan(self.ttl):
|
for k, v in self.iteritemsOlderThan(self.ttl):
|
||||||
self.data.popitem(first=True)
|
self.data.popitem(last=False)
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
self.cull()
|
self.cull()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
|
|
||||||
from kademlia.routing import KBucket, RoutingTable
|
from kademlia.routing import KBucket
|
||||||
from kademlia.protocol import KademliaProtocol
|
|
||||||
from kademlia.tests.utils import mknode, FakeProtocol
|
from kademlia.tests.utils import mknode, FakeProtocol
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user