Subotai

Subotai is a Kademlia based distributed hash table. It's designed to be easy to use, safe and quick. Here are some of the ideas that differentiate it from other DHTs:

Docs

How to use

Let's say we have this code running on a machine:

```rust fn main() { let node = node::Node::new().unwrap();

// We join the network through the address of any live node. let seed = net::SocketAddr::from_str("192.168.1.100:50000").unwrap(); node.bootstrap(&seed);

// We store a key->data pair. let mykey = hash::SubotaiHash::sha1("examplekey"); let mydata = vec![0u8,1,2,3,4,5]; node.store(mykey, node::StorageEntry::Blob(my_data)); } ```

As long as there is a minimum amount of nodes in the network (a configurable amount, deemed sufficient for the network to be considered alive), we have successfully stored data in the table.

Now, on a machine very, very far away...

``` rust fn main() { let node = node::Node::new().unwrap();

// We join the same network (can be on a different node). let seed = net::SocketAddr::from_str("192.168.1.230:40000").unwrap(); node.bootstrap(&seed);

// We retrieve all entries for the same key. let mykey = hash::SubotaiHash::sha1("examplekey"); let retrievedentries = node.retrieve(&mykey).unwrap();

// We get what we stored. In O(log n) number of steps, of course! asserteq!(retrievedentries.len(), 1); let expecteddata = vec![0u8,1,2,3,4,5]; asserteq!(*retrievedentries.first().unwrap(), node::StorageEntry::Blob(expecteddata)); } ```

State of the Project

Subotai is feature complete, but in early stages of testing. I focused on making the API as stable as possible (partly by handling all configuration through a factory, to prevent new configuration options from becoming breaking changes) and providing a baseline of features for practical applications to be built on top of it.

Even though every feature is unit tested, the network hasn't yet been tested in real world conditions. I'd really appreciate any experiments! Just make sure not to use it for anything critical just yet :).

Note on Testing

Subotai's unit test suite is somewhat fiddly, since the library uses timeouts pervasively in order to make decisions. This means that, unless you're running a very powerful machine, you should run cargo test with RUST_TEST_THREADS=1. Otherwise, an excessive number of tests in parallel may create timeouts all over the place, causing the network to mistake nodes as dead.