Fixed #77 - Unexpected type conversion in buckets
This commit is contained in:
parent
ad87e3c148
commit
0be8cd2169
7
CHANGELOG.md
Normal file
7
CHANGELOG.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
* Fixed #77 - Unexpected type conversion in buckets
|
@ -23,7 +23,7 @@ class KBucket:
|
||||
return list(self.nodes.values())
|
||||
|
||||
def split(self):
|
||||
midpoint = (self.range[0] + self.range[1]) / 2
|
||||
midpoint = (self.range[0] + self.range[1]) // 2
|
||||
one = KBucket(self.range[0], midpoint, self.ksize)
|
||||
two = KBucket(midpoint + 1, self.range[1], self.ksize)
|
||||
nodes = chain(self.nodes.values(), self.replacement_nodes.values())
|
||||
|
@ -13,6 +13,10 @@ class TestKBucket:
|
||||
assert len(two) == 1
|
||||
assert two.range == (6, 10)
|
||||
|
||||
def test_split_no_overlap(self): # pylint: disable=no-self-use
|
||||
left, right = KBucket(0, 2 ** 160, 20).split()
|
||||
assert (right.range[0] - left.range[1]) == 1
|
||||
|
||||
def test_add_node(self, mknode): # pylint: disable=no-self-use
|
||||
# when full, return false
|
||||
bucket = KBucket(0, 10, 2)
|
||||
|
Loading…
Reference in New Issue
Block a user