Git Product home page Git Product logo

kademlia's Introduction

Documentation Status Build Status Linux Build status Windows Coverage Status

Description

C++11 distributed hash table library

This software is experimental and under active development.

Development

Bug and feature requests

Supported targets

OSCompiler
OSXclang
NIXgcc
Windows 7+MSVC

Project structure

kademlia/
    |
    |-- include             API public headers files.
    |-- src                 Implementation sources and headers files.
    |-- test/unit_tests     Unit tests.
    |-- docs                User and development documentation.
    |-- specs               Kademlia protocol papers

kademlia's People

Contributors

davidkeller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kademlia's Issues

Routing Table maintenance

I have some questions related the routing table:

  1. There's a lot of messages exchanged on initial peer connection to the bootstrap, and multiple entries for the peer are inserted in the routing table. Is this necessary or is one entry per peer enough?

  2. Since every peer generates a new ID for itself on every run, when a peer with different ID but the same IP:PORT as an existing routing table entry (ie. a restarted peer) shows up, shouldn't the previous entry for that IP:PORT be purged? Otherwise, the table will grow infinitely.

  3. Stale peers should obviously be purged at some point. Since this is UDP, the only time we know a peer exists is when it broadcasts a new entry. Is a peer required/expected to ping all peers at certain interval to prevent its purging from the routing tables of its peers?

Thanks!

Incompatible Protocol

Hi, I happened to try your codes(both library and example), but it seems to be incompatible with the Mainline DHT network of BitTorrent, is that true?

error during make: ‘io_service’ is not a member of ‘boost::asio’

[ 53%] Building CXX object test/unit_tests/CMakeFiles/test_helpers.dir/network.cpp.o
In file included from /home/redim/code/kademlia/test/unit_tests/network.cpp:26:0:
/home/redim/code/kademlia/test/unit_tests/network.hpp: In function ‘boost::system::error_code 
kademlia::test::create_socket(const string&, uint16_t)’:
/home/redim/code/kademlia/test/unit_tests/network.hpp:46:18: error: ‘io_service’ is not a member of ‘boost::asio’
 boost::asio::io_service io_service;
                  ^~~~~~~~~~

it seems that #include<boost/asio.hpp> is missing from network.hpp

Getting started? Example?

Hello!

I have found your library and wanna give a try (i am looking for dht libraries).
Despite the README saying that it is still experimental, i liked the code style and saw that it has many tests.

So, are there some example or anything to help get started?
Besides the code fragments on README?
Also, are there some DHT networking running it, to help bootstrap nodes?
Or anything compatible?

Thanks!

There was an error when I ran the example.

Hello!

There was an error when I ran two of these programs. Another program modifies the IP and port.

Compiling environment:QT5.12
widget.h:

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include<kademlia/session.hpp>
#include<future>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void on_searchButton_clicked();

    void on_saveButton_clicked();

private:
    Ui::Widget *ui;
kademlia::session *s;
std::future<std::error_code> *main_loop_result;
};
#endif // WIDGET_H

widget.cpp:

#include "widget.h"
#include "ui_widget.h"
#include<kademlia/session.hpp>
#include<future>
#include<QDebug>
#include<iostream>
#include<kademlia/error.hpp>
#include<QHostInfo>
#include<QFile>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    kademlia::endpoint const initial_peer{"192.168.1.4",34567};
    s = new kademlia::session {initial_peer};
    main_loop_result = new std::future<std::error_code>(std::async(std::launch::async,
                                       &kademlia::session::run,s));

    //qDebug()<<"type: "<<typeid (main_loop_result).name();
    ui->setupUi(this);
}

Widget::~Widget()
{
    s->abort();
    auto failure = main_loop_result->get();
    if(failure!=kademlia::RUN_ABORTED)
        qDebug()<<QString::fromStdString(failure.message());
    delete s;
    s=0;
    delete ui;
}


void Widget::on_searchButton_clicked()
{
    QByteArray bytes("key");
    std::vector<uint8_t> key(bytes.begin(),bytes.end());
    auto on_load = [](std::error_code const& failure
            ,kademlia::session::data_type const& data)
    {
        qDebug()<<"data: "<<data.data();
        if(failure)
            qDebug()<<QString::fromStdString(failure.message());
        else

            std::copy(data.begin(),data.end()
                      ,std::ostream_iterator<std::uint32_t>{std::cout," "});
    };

    s->async_load(key,on_load);
}

void Widget::on_saveButton_clicked()
{
    QFile file("D:/qt_code/222.txt");
    if(!file.open(QFile::ReadOnly)){
        qDebug()<<"open file error!";
        return;
    }
    QByteArray block;
    block = file.readAll();
    file.close();
    std::vector<uint8_t> txt(block.begin(),block.end());

    kademlia::session::data_type const data{txt.begin(),txt.end()};

    auto on_save = [](std::error_code const& failure){
        if(failure)
            qDebug()<<QString::fromStdString(failure.message());
    };
    QByteArray bytes("key");
    std::vector<uint8_t> key(bytes.begin(),bytes.end());
    s->async_save(key,data,on_save);
}

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.