Skip to main content

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

Project description

Liaa

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.

Installation

pip install kademlia

Usage

This assumes you have a working familiarity with asyncio.

Assuming you want to connect to an existing network:

import asyncio
from liaa.network import Server

loop = asyncio.get_event_loop()

# 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.
loop.run_until_complete(node.bootstrap([("123.123.123.123", 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"))
print(result)

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.

Logging

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

import logging

log = logging.getLogger('liaa')
log.setLevel(logging.DEBUG)
log.addHandler(logging.StreamHandler())

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.

Source Distribution

liaa-1.1.2.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

liaa-1.1.2-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file liaa-1.1.2.tar.gz.

File metadata

  • Download URL: liaa-1.1.2.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.2

File hashes

Hashes for liaa-1.1.2.tar.gz
Algorithm Hash digest
SHA256 6fd8c63d6d12cc82262829a38fb6d444caea197b945bfab9c9d6edd9ead061bd
MD5 4f6fae88a501771f4f90e2be232dde95
BLAKE2b-256 cf188fd3640c4b4eb7a3fcf49feb196a7648ea6bd74169fc9499fb0a0e63fa17

See more details on using hashes here.

File details

Details for the file liaa-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: liaa-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.2

File hashes

Hashes for liaa-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 573233ca4caf67805cc0438a4955d03ae702e2d19379c3b0e4d5c99a0d2d7cfb
MD5 f4381783500f4c7d91b6c186eb1ff3e6
BLAKE2b-256 ed83deb56e2b6760702d45188220b81c347bf47a5a454670006193e09b116734

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page