Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p2p/protocols: devp2p protocol abstraction #2959

Closed
wants to merge 2 commits into
base: develop
from

Conversation

Projects
None yet
4 participants
@zelig
Copy link
Contributor

zelig commented Aug 29, 2016

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

The package provides a standard protocol peer object of type protocols.Peer initialised from
a p2p.Peer, a p2p.MsgReadWriter (the arguments passed to p2p.Protocol#Run
and a protocols.CodeMap.

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.

*    registering multiple handler callbacks for incoming messages
*    automate assigments of code indexes to messages
*    automate RLP decoding/encoding based on reflecting
*    provide the forever loop to read incoming messages
*    standardise error handling related to communication
*    TODO: automatic generation of wire protocol specification for peers

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

The PR includes p2p/testing subpackage that provides a powerful framework to test
fairly complex subprotocol message exchanges in a multipeer session
The test for p2p/protocols demonstrates how to use this subpackage.

@robotally

This comment has been minimized.

Copy link

robotally commented Aug 29, 2016

Vote Count Reviewers
👍 0
👎 0

Updated: Tue Sep 13 12:01:43 UTC 2016

@zelig zelig referenced this pull request Aug 29, 2016

Closed

swarm network rewrite #2960

7 of 17 tasks complete

@zelig zelig added in progress and removed pr:review labels Sep 6, 2016

@zelig zelig force-pushed the ethersphere:std_protocol branch Sep 13, 2016

@GitCop

This comment has been minimized.

Copy link

GitCop commented Sep 13, 2016

Thank you for your contribution! Your commits seem to not adhere to the repository coding standards

  • Commit: f29201b7660ad4d6cd1f8b3945987b77b6c95a24
    • Your commit message body contains a line that is longer than 72 characters

Please check the contribution guidelines for more details.


This message was auto-generated by https://gitcop.com

@zelig zelig added pr:review and removed in progress labels Sep 13, 2016

@zelig

This comment has been minimized.

Copy link
Contributor Author

zelig commented Sep 13, 2016

@fjl I implemented pretty much everything you suggested and more

  • does not depend on errs package which can now be removed (noone uses it)
  • std protocol and Node-like service constructor eliminated
  • peerPool eliminated
  • composition-based use via the Peer#Run function
  • CopeMap-based calculation
  • added Handshake call beside Register for much nicer handling of Handshakes
  • major improvement of p2p/testing supporting mulltipeer sessions with parallel messages
  • Disconnect terminates the read loop directly in testing so easy to implement Expect or Disconnect
  • ...

@zelig zelig force-pushed the ethersphere:std_protocol branch Oct 2, 2016

@GitCop

This comment has been minimized.

Copy link

GitCop commented Oct 2, 2016

Thank you for your contribution! Your commits seem to not adhere to the repository coding standards

  • Commit: ed6a4c64aab842f62e02dc3dc9a6341c854a3b39
    • Your commit message body contains a line that is longer than 72 characters

Please check the contribution guidelines for more details.


This message was auto-generated by https://gitcop.com

zelig added some commits Sep 13, 2016

p2p/protocols: devp2p subprotocol abstraction
Package protocols is an extension to p2p. It offers a user friendly simple way to define
devp2p subprotocols by abstracting away code that implementations would typically use.

The package provides a standard protocol peer object of type protocols.Peer initialised from
a p2p.Peer, a p2p.MsgReadWriter (the arguments passed to p2p.Protocol#Run
and a protocols.CodeMap.

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.

*    registering multiple handler callbacks for incoming messages
*    automate assigments of code indexes to messages
*    automate RLP decoding/encoding based on reflecting
*    provide the forever loop to read incoming messages
*    standardise error handling related to communication
*    TODO: automatic generation of wire protocol specification for peers

The test demonstrates the use of protocols/testing package for testing protocols

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

@zelig zelig force-pushed the ethersphere:std_protocol branch to 23973c9 Oct 2, 2016

@GitCop

This comment has been minimized.

Copy link

GitCop commented Oct 2, 2016

Thank you for your contribution! Your commits seem to not adhere to the repository coding standards

  • Commit: 23973c9
    • Your commit message body contains a line that is longer than 72 characters

Please check the contribution guidelines for more details.


This message was auto-generated by https://gitcop.com

@zelig zelig closed this Nov 29, 2016

@zelig zelig deleted the ethersphere:std_protocol branch Nov 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.