#network #peer-to-peer

tentacle

Minimal implementation for a multiplexed p2p network framework

9 releases

✓ Uses Rust 2018 edition

0.2.3 Jul 12, 2019
0.2.2 Jun 27, 2019
0.2.0 May 23, 2019
0.2.0-alpha.6 Apr 27, 2019
0.1.0 Feb 27, 2019

#325 in Network programming

Download history 293/week @ 2019-04-28 414/week @ 2019-05-05 718/week @ 2019-05-12 446/week @ 2019-05-19 254/week @ 2019-05-26 626/week @ 2019-06-02 777/week @ 2019-06-09 758/week @ 2019-06-16 760/week @ 2019-06-23 733/week @ 2019-06-30 557/week @ 2019-07-07 778/week @ 2019-07-14 503/week @ 2019-07-21 360/week @ 2019-07-28 892/week @ 2019-08-04

2,182 downloads per month
Used in 3 crates

MIT license

433KB
11K SLoC

P2P

Build Status image

Overview

This is a minimal implementation for a multiplexed p2p network based on yamux that supports mounting custom protocols.

Architecture

  1. Data stream transmission
+----+      +----------------+      +-----------+      +-------------+      +----------+      +------+
|user| <--> | custom streams | <--> |Yamux frame| <--> |Secure stream| <--> |TCP stream| <--> |remote|
+----+      +----------------+      +-----------+      +-------------+      +----------+      +------+
  1. Code implementation

All data is passed through the futures channel, yamux splits the actual tcp stream into multiple substreams, and the service layer wraps the yamux substream into a protocol stream.

At the same time, support for other protocol(such as websocket) is also planned, but will delay a lot.

Detailed introduction: 中文/English

Note: It is not compatible with libp2p.

Status

The API of this project is basically usable. However we still need more tests. PR is welcome.

Usage

From cargo

[dependencies]
tentacle = "0.2"

Example

  1. Clone
$ git clone https://github.com/nervosnetwork/p2p.git
  1. On one terminal:

Listen on 127.0.0.1:1337

$ RUST_LOG=simple=info,tentacle=debug cargo run --example simple -- server
  1. On another terminal:
$ RUST_LOG=simple=info,tentacle=debug cargo run --example simple
  1. Now you can see some data interaction information on the terminal.

You can see more detailed example in these two repos: ckb/cita.

Why?

Because when I use rust-libp2p, I have encountered some difficult problems, and it is difficult to locate whether it is my problem or the library itself, it is better to implement one myself.

Dependencies

~13MB
~300K SLoC