Updated requirements, examples, README, and CHANGELOG

This commit is contained in:
Brian Muller 2020-05-02 21:36:33 -04:00
parent 9bb45b1c90
commit e925d492d3
No known key found for this signature in database
GPG Key ID: 19A500213CC84E3B
11 changed files with 73 additions and 54 deletions

View File

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

View File

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

View File

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

View File

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1 +1 @@
rpcudp>=4.0.0
rpcudp>=4.0.1