Metadata-Version: 2.1
Name: liaa
Version: 1.1.2
Summary: Liaa is a distributed hash table for decentralized peer-to-peer computer networks.
Home-page: http://github.com/ralston3/liaa
Author: Brian Muller, Rashad Alston
Author-email: bamuller@gmail.com, rashadalston@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
Requires-Dist: u-msgpack-python

# Liaa 

## A Python-based Distributed Hash Table
[!This is a fork of bmuller's original repo!](https://github.com/bmuller/kademlia)

[![Build Status](https://secure.travis-ci.org/ralston3/liaa.png?branch=master)](https://travis-ci.org/ralston3/liaa)
[![Python version](https://img.shields.io/pypi/pyversions/liaa)](https://pypi.org/project/liaa/)
![Codecov branch](https://img.shields.io/codecov/c/github/ralston3/liaa/master?color=purple)
![GitHub issues](https://img.shields.io/github/issues/ralston3/liaa?color=red)
![Repo Size](https://img.shields.io/github/repo-size/ralston3/liaa)
![GitHub commit activity](https://img.shields.io/github/commit-activity/w/ralston3/liaa)
![GitHub](https://img.shields.io/github/license/ralston3/liaa)

This library is an asynchronous Python implementation of the [Kademlia distributed hash table](http://en.wikipedia.org/wiki/Kademlia).  It uses the [asyncio library](https://docs.python.org/3/library/asyncio.html) 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](http://en.wikipedia.org/wiki/Network_address_translation).

This library aims to be as close to a reference implementation of the [Kademlia paper](http://pdos.csail.mit.edu/~petar/papers/maymounkov-kademlia-lncs.pdf) as possible.

## Installation

```
pip install kademlia
```

## Usage
*This assumes you have a working familiarity with [asyncio](https://docs.python.org/3/library/asyncio.html).*

Assuming you want to connect to an existing network:

```python
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](https://docs.python.org/3/library/logging.html).  To see debut output printed to STDOUT, for instance, use:

```python
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](https://github.com/bmuller/kademlia/issues).

## 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).


