Skip to main content

Liaa is a distributed hash table for decentralized peer-to-peer computer networks.

Project description


A Python-based Distributed Hash Table

!This is a fork of bmuller's original repo!

Build Status Python version Codecov branch GitHub issues Repo Size GitHub commit activity GitHub

This library is an asynchronous Python implementation of the Kademlia distributed hash table. It uses the asyncio library in Python 3 to provide asynchronous communication. The nodes communicate using RPC over UDP to communiate, meaning that it is capable of working behind a NAT.

This library aims to be as close to a reference implementation of the Kademlia paper as possible.


pip install kademlia


This assumes you have a working familiarity with asyncio.

Assuming you want to connect to an existing network:

import asyncio
from import Server

loop = asyncio.get_event_loop()

# Create a node and start listening on port 5678
node = Server()

# Bootstrap the node by connecting to other known nodes, in this case
# replace 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([("", 5678)]))

# 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 = loop.run_until_complete(node.get("my-key"))

Initializing a Network

If you're starting a new network from scratch, just omit the node.bootstrap call in the example above. Then, bootstrap other nodes by connecting to the first node you started.

See the examples folder for a first node example that other nodes can bootstrap connect to and some code that gets and sets a key/value.


This library uses the standard Python logging library. To see debut output printed to STDOUT, for instance, use:

import logging

log = logging.getLogger('liaa')

Running Tests

To run tests:

pip install -r dev-requirements.txt
python -m unittest

Reporting Issues

Please report all issues on github.

Fidelity to Original Paper

The current implementation should be an accurate implementation of all aspects of the paper save 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).

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for liaa, version 1.1.2
Filename, size File type Python version Upload date Hashes
Filename, size liaa-1.1.2-py3-none-any.whl (36.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size liaa-1.1.2.tar.gz (29.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page