#proto #request #body #pipeline #state #routing-table

bin+lib melnet

Low-level RPC protocol used throughout Themelio for peer-to-peer communciations

44 releases

0.2.27 Jul 6, 2022
0.2.25 Apr 26, 2022
0.2.18 Mar 23, 2022
0.1.12 Sep 23, 2021
0.1.1 Jun 30, 2021
Download history 85/week @ 2023-05-31 33/week @ 2023-06-14 26/week @ 2023-06-21 100/week @ 2023-06-28 92/week @ 2023-07-05 67/week @ 2023-07-12 33/week @ 2023-07-19 24/week @ 2023-07-26 9/week @ 2023-08-02 16/week @ 2023-08-09 60/week @ 2023-08-16 53/week @ 2023-08-23 9/week @ 2023-08-30 111/week @ 2023-09-06 13/week @ 2023-09-13

186 downloads per month
Used in 5 crates (3 directly)

MPL-2.0 license

35KB
821 lines

Melnet serves as Themelio's peer-to-peer network layer, based on a randomized topology and gossip. Peers are divided into servers, which have a publicly reachable address, and clients, which do not. It's based on a simple stdcode request-response protocol, where the only way to "push" a message is to send a request to a server. There is no multiplexing --- the whole thing works like HTTP/1.1. TCP connections are pretty cheap these days.

This also means that clients never receive notifications, and must poll servers.

The general way to use melnet is as follows:

  1. Create a NetState. This holds the routing table, RPC verb handlers, and other "global" data.
  2. If running as a server, register RPC verbs with NetState::register_verb and run NetState::run_server in the background.
  3. Use a Client, like the global one returned by g_client(), to make RPC calls to other servers. Servers are simply identified by a std::net::SocketAddr.

Dependencies

~11–49MB
~771K SLoC