isaaczafuta / pydht

Python implementation of the Kademlia DHT data store

Home Page:https://isaac.zafuta.com/pydht

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pydht

Python implementation of the Kademlia DHT data store.

Useful for distributing a key-value store in a decentralized manner.

To create a new DHT swarm, just call DHT() with the host and port that you will listen on. To join an existing DHT swarm, also provide bootstrap host and port numbers of any existing node. The nodes will discover the rest of the swarm as appropriate during usage.

Example - A two-node DHT:

>>> from pydht import DHT
>>> host1, port1 = 'localhost', 3000
>>> dht1 = DHT(host1, port1)
>>>
>>> host2, port2 = 'localhost', 3001
>>> dht2 = DHT(host2, port2, boot_host=host1, boot_port=port1)
>>>
>>> dht1["my_key"] = [u"My", u"json-serializable", u"Object"]
>>>
>>> print dht2["my_key"]
[u'My', u'json-serializable', u'Object']

About

Python implementation of the Kademlia DHT data store

https://isaac.zafuta.com/pydht

License:Other


Languages

Language:Python 100.0%