go-ethereum/p2p/protocols
nolash b8bf32bce3 swarm/network: pss 0.1
General:
    - Message encapsulation is temporary until integration with whisper

    Incoming message handling:
    - Implements a dispatcher for registering handler functions to pss topics
    - Handlers can be any sort of function, and can send/receive on p2p.MsgReadWriter
    - Actual p2p.Protocol handling now as pluggable convenience function

Sending and routing:
    - Added temporary cache solution based on message hash digest
    - Send and forward split up as separate methods
    - Send is now payload agnostic (p2p.Protocol replies massaged in p2p.MsgWriter)

Tests:
    - TestPssRandom...
	Sends PSS between randomly selected nodes in different population magnitudes
    - TestPssFullLinearEcho
        A->B->C->B->A ping/pong over pss, where A and C are running pss
    - TestPssFullRandom50Pct
        10 nodes where 5 are running pss, 5 sends to/from random nodes
        (messages currently get stuck in kad. routing, discarded by cache block)
    - Protocoltester tests status unknown
2017-05-06 14:25:00 +01:00
..
protocol.go swarm/network: pss 0.1 2017-05-06 14:25:00 +01:00
protocol_test.go all: Fix logging 2017-05-06 14:23:39 +01:00
README.md p2p: network testing framework and protocol abstraction 2017-05-06 14:23:38 +01:00

p2p/protocols: devp2p subprotocol abstraction

The protocols subpackage is an extension to p2p. It offers a simple and user friendly simple way to define devp2p subprotocols by abstracting away code that implementations would typically share.

The package provides a protocol peer object of type protocols.Peer initialised from

  • a p2p.Peer, a p2p.MsgReadWriter (the arguments passed to p2p.Protocol#Run),
  • a protocols.CodeMap, this encodes the msg code and msg type associations
  • messenger interface (with methods SendMsg and ReadMsg) that abstracts out sending and receiving a msg
  • disconnect function

Allowing the p2p.Protocol#Run function to construct this peer allows passing it to arbitrary service instances sitting on peer connections. These service instances can encapsulate vertical slices of business logic without duplicating code related to protocol communication.

Features

  • registering multiple handler callbacks for incoming messages
  • automate RLP decoding/encoding based on reflection
  • provide the forever loop to read incoming messages
  • standardise error handling related to communication
  • with disconnection and messaging abstracted out allows protocols to be used in network simulations with or without serialisation, transport and p2p server
  • TODO: automatic generation of wire protocol specification for peers

see the possibly obsolete #2254 for the peer management/connectivity related aspect)