diff --git a/CHANGELOG.md b/CHANGELOG.md index 4abd5d8..4d1ef14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,32 @@ 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 - * Fixed #78 - load_state does not await bootstrap +## Verson 2.2.1 (2020-05-02) + +### Enhancements + * update tests without unittest only pytest (#62) + * added additional docs to `Node` to reduce confusion noted in #73 + +### Bug Fixes + * Fixed unexpected type conversion in buckets (#77) + * Fixed issue with load_state not awaiting bootstrap (#78) + * Fixed `KBucket.replacement_nodes` is never pruned (#79) + +## Verson 2.2 (2019-02-04) +minor version update to handle long_description_content_type for pypi + +## Verson 2.1 (2019-02-04) + +### Bug Fixes + * `KBucket.remove_node` removes nodes in replacement_nodes. (#66) + * Improve `KBucket.split` (#65) + * refacto(storage): use '@abstractmethod' instead of 'raise NotImplementedError' in Storage Interface (#61) + * Asynchronous Server listening (#58) (#60) + +## Version 2.0 (2019-01-09) + +### Bug Fixes + * Removed unused imports + +### Deprecations + * Removed all camelcase naming diff --git a/README.md b/README.md index 63aabe8..e60c152 100644 --- a/README.md +++ b/README.md @@ -24,23 +24,24 @@ Assuming you want to connect to an existing network: import asyncio from kademlia.network import Server -loop = asyncio.get_event_loop() +async def run(): + # Create a node and start listening on port 5678 + node = Server() + await node.listen(5678) -# Create a node and start listening on port 5678 -node = Server() -loop.run_until_complete(node.listen(5678)) + # Bootstrap the node by connecting to other known nodes, in this case + # replace 123.123.123.123 with the IP of another node and optionally + # give as many ip/port combos as you can for other nodes. + await node.bootstrap([("123.123.123.123", 5678)]) -# Bootstrap the node by connecting to other known nodes, in this case -# replace 123.123.123.123 with the IP of another node and optionally -# give as many ip/port combos as you can for other nodes. -loop.run_until_complete(node.bootstrap([("123.123.123.123", 5678)])) + # set a value for the key "my-key" on the network + await node.set("my-key", "my awesome value") -# set a value for the key "my-key" on the network -loop.run_until_complete(node.set("my-key", "my awesome value")) + # get the value associated with "my-key" from the network + result = await node.get("my-key") + print(result) -# get the value associated with "my-key" from the network -result = loop.run_until_complete(node.get("my-key")) -print(result) +asyncio.run(run()) ``` ## Initializing a Network @@ -64,7 +65,7 @@ To run tests: ``` pip install -r dev-requirements.txt -python -m unittest +pytest ``` ## Reporting Issues diff --git a/dev-requirements.txt b/dev-requirements.txt index 5a03bfd..dbb3efc 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,8 +1,6 @@ -pycodestyle>=2.4.0 -pylint>=2.2.2 -sphinx>=1.6.5 -sphinxcontrib-napoleon>=0.6.1 -sphinxcontrib-zopeext>=0.2.1 -pytest>=4.1.0 -pytest-asyncio>=0.10.0 -pytest-cov>=2.6.1 +pycodestyle>=2.5.0 +pylint>=2.5.0 +sphinx>=3.0.3 +pytest>=5.4.1 +pytest-asyncio>=0.11.0 +pytest-cov>=2.8.1 diff --git a/docs/_static/.gitkeep b/docs/_static/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/conf.py b/docs/conf.py index 6092ae7..776dde6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -32,8 +32,7 @@ extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.viewcode', - 'sphinxcontrib.napoleon', - 'sphinxcontrib.zopeext.autointerface' + 'sphinx.ext.napoleon' ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs/intro.rst b/docs/intro.rst index 07110a4..72fec08 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -26,12 +26,9 @@ Running Tests To run tests:: $ pip install -r dev-requirements.txt - $ python -m unittest + $ pytest Fidelity to Original Paper ========================== The current implementation should be an accurate implementation of all aspects of the paper except one - in Section 2.3 there is the requirement that the original publisher of a key/value republish it every 24 hours. This library does not do this (though you can easily do this manually). - - -.. _Twisted: https://twistedmatrix.com diff --git a/examples/get.py b/examples/get.py index ef6f56f..9e1e72d 100644 --- a/examples/get.py +++ b/examples/get.py @@ -15,15 +15,14 @@ log = logging.getLogger('kademlia') log.addHandler(handler) log.setLevel(logging.DEBUG) -loop = asyncio.get_event_loop() -loop.set_debug(True) +async def run(): + server = Server() + await server.listen(8469) + bootstrap_node = (sys.argv[1], int(sys.argv[2])) + await server.bootstrap([bootstrap_node]) -server = Server() -loop.run_until_complete(server.listen(8469)) -bootstrap_node = (sys.argv[1], int(sys.argv[2])) -loop.run_until_complete(server.bootstrap([bootstrap_node])) -result = loop.run_until_complete(server.get(sys.argv[3])) -server.stop() -loop.close() + result = await server.get(sys.argv[3]) + print("Get result:", result) + server.stop() -print("Get result:", result) +asyncio.run(run()) diff --git a/examples/set.py b/examples/set.py index 22160fb..56336ae 100644 --- a/examples/set.py +++ b/examples/set.py @@ -15,13 +15,12 @@ log = logging.getLogger('kademlia') log.addHandler(handler) log.setLevel(logging.DEBUG) -loop = asyncio.get_event_loop() -loop.set_debug(True) +async def run(): + server = Server() + await server.listen(8469) + bootstrap_node = (sys.argv[1], int(sys.argv[2])) + await server.bootstrap([bootstrap_node]) + await server.set(sys.argv[3], sys.argv[4]) + server.stop() -server = Server() -loop.run_until_complete(server.listen(8469)) -bootstrap_node = (sys.argv[1], int(sys.argv[2])) -loop.run_until_complete(server.bootstrap([bootstrap_node])) -loop.run_until_complete(server.set(sys.argv[3], sys.argv[4])) -server.stop() -loop.close() +asyncio.run(run()) diff --git a/kademlia/__init__.py b/kademlia/__init__.py index c0fd4b4..9d7a451 100644 --- a/kademlia/__init__.py +++ b/kademlia/__init__.py @@ -2,4 +2,4 @@ Kademlia is a Python implementation of the Kademlia protocol which utilizes the asyncio library. """ -__version__ = "2.2" +__version__ = "2.2.1" diff --git a/kademlia/network.py b/kademlia/network.py index debd946..12eb5dc 100644 --- a/kademlia/network.py +++ b/kademlia/network.py @@ -33,8 +33,8 @@ class Server: ksize (int): The k parameter from the paper alpha (int): The alpha parameter from the paper node_id: The id for this node on the network. - storage: An instance that implements - :interface:`~kademlia.storage.IStorage` + storage: An instance that implements the interface + :class:`~kademlia.storage.IStorage` """ self.ksize = ksize self.alpha = alpha diff --git a/requirements.txt b/requirements.txt index 4da0595..3893bdb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -rpcudp>=4.0.0 +rpcudp>=4.0.1