-
Notifications
You must be signed in to change notification settings - Fork 20k
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
Conversation
Updated: Tue Sep 13 12:01:43 UTC 2016 |
Thank you for your contribution! Your commits seem to not adhere to the repository coding standards
Please check the contribution guidelines for more details. This message was auto-generated by https://gitcop.com |
@fjl I implemented pretty much everything you suggested and more
|
Thank you for your contribution! Your commits seem to not adhere to the repository coding standards
Please check the contribution guidelines for more details. This message was auto-generated by https://gitcop.com |
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)
Thank you for your contribution! Your commits seem to not adhere to the repository coding standards
Please check the contribution guidelines for more details. This message was auto-generated by https://gitcop.com |
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.
see the possibly obsolete #2254 for the peer management/connectivity related aspect)
The PR includes
p2p/testing
subpackage that provides a powerful framework to testfairly complex subprotocol message exchanges in a multipeer session
The test for
p2p/protocols
demonstrates how to use this subpackage.