pea2pea

crates.io docs.rs LOC dependencies actively developed issues

pea2pea is a simple, low-level, and customizable implementation of a TCP P2P node.

The core library only provides the most basic functionalities like starting, ending and maintaining connections; the rest is up to a few low-level, opt-in protocols: - Handshake requires connections to adhere to the given handshake logic before anything else can be done with them - Reading enables the node to receive messages based on the user-supplied Decoder - Writing enables the node to send messages based on the user-supplied Encoder - Disconnect makes the node perform specified actions whenever a connection with a peer is severed - OnConnect makes the node perform specified actions whenever a connection with a peer is fully established (post-handshake)

goals

how to use it

  1. define a clonable struct containing a Node and any extra state you'd like to carry alongside it
  2. implement the trivial Pea2Pea trait 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 the protocols you'd like them to utilize

That's it!

examples

status