#p2p #peer-to-peer #networking

pea2pea

A small library allowing simple and quick creation of custom P2P nodes and networks

45 releases (28 breaking)

new 0.29.0 Nov 25, 2021
0.27.1 Aug 22, 2021
0.21.0 Jul 29, 2021
0.18.1 Feb 19, 2021
0.8.0 Dec 31, 2020

#215 in Network programming

Download history 37/week @ 2021-08-09 133/week @ 2021-08-16 19/week @ 2021-08-23 7/week @ 2021-08-30 2/week @ 2021-09-06 18/week @ 2021-09-13 2/week @ 2021-09-20 45/week @ 2021-09-27 8/week @ 2021-10-04 62/week @ 2021-10-11 3/week @ 2021-10-25 1/week @ 2021-11-01 58/week @ 2021-11-08 64/week @ 2021-11-15 433/week @ 2021-11-22

150 downloads per month

CC0 license

58KB
1K SLoC

pea2pea

crates.io docs.rs files LOC dependencies issues

pea2pea is a P2P library designed with the following use cases in mind:

  • simple and quick creation of custom P2P networks
  • testing/verifying network protocols
  • benchmarking and stress-testing P2P nodes (or other network entities)
  • substituting other, "heavier" nodes in local network tests

goals

  • small, simple codebase: the core library is under 1k LOC and there are few dependencies
  • ease of use: few objects and traits, no "turboeels" or generics/references forcing all parent objects to adapt
  • correctness: no unsafe code; there's more code in tests than in the actual library
  • interoperability: strives to be as versatile as possible without sacrificing simplicity and ease of use
  • good performance: over 10GB/s in favorable scenarios, small memory footprint

non-goals

  • no_std
  • becoming a framework
  • support for multiple async runtimes (it should be simple enough to change it, though)
  • any functionality that can be introduced "on top" (e.g. DHT, advanced topology formation algorithms etc.)

how to use it

  1. define a clonable struct containing a Node and any extra state you'd like to carry
  2. impl Pea2Pea for it
  3. make it implement any/all of the protocols
  4. create that struct (or as many of them as you like)
  5. enable protocols you'd like the node(s) to utilize

That's it!

examples

  • the tests directory contains some examples of simple use
  • examples contain more advanced setups, e.g. using noise encryption
  • try running cargo run --example <example_name> with different RUST_LOG verbosity levels to check out what's going on under the hood

Dependencies

~4.5MB
~81K SLoC

a