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
PeerSubscribers now specify what messages they are interested in #1137
PeerSubscribers now specify what messages they are interested in #1137
Conversation
@gsalgado I still want to make some changes to the API so hold off on reviewing for now. Sorry for the pre-mature request. |
2ce6ef8
to
edcb4d2
Compare
ok, ready for review, however, some brief testing shows this needs a bit more attention. |
4a6cf77
to
355227d
Compare
Two things
Will investigate further tomorrow but wanted to make note of it here. |
command which is not in this set will not be passed to this subscriber. | ||
|
||
The base command class `p2p.protocol.Command` can be used to enable | ||
**all** command types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth mentioning that only sub-proto messages are delivered this way -- the base protocol ones are handled exclusively at the peer level
p2p/peer.py
Outdated
peer, cmd, _ = msg | ||
|
||
if not self.is_subscription_command(type(cmd)): | ||
if hasattr(self, 'logger'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which subscribers don't provide a logger? Should we change them so they do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually for the tests. The PeerSubscriber
itself doesn't provide a logger. I'll remove this and change the ones in the test to have loggers.
What was wrong?
fixes #1055
How was it fixed?
All
PeerSubscriber
classes must now implement asubscription_msg_types
which defines which types of messages it will add to it's queue. Any message not the specified types is discarded. Including the basep2p.protocol.Command
in the list results in all messages being included in the queue.Cute Animal Picture