-
Notifications
You must be signed in to change notification settings - Fork 984
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
Deprecate NetworkBehaviour listener
callback methods
#3040
Comments
I think |
libp2p has certainly changed a lot since I made the PR adding those. However even with your changes it's not clear why there should be a
First of it doesn't require a
|
In that case, that abstraction should be built on top of whatever polls the swarm.
They don't represent the same set of events. |
well, it's annoying to have to piece together information from different sources. They overlap a lot in functionality. I'd suggest making them equivalent. Then there is stuff in NetworkBehaviourAction's that can't be done without calling a method on the swarm. Why can't I ban a peer from a network behaviour? Seems like an arbitrary restriction. |
usually what ends up happening when using libp2p is this:
|
That is a fair point. Pluggable connection management is tracked here: #2824 Extending this with bans is definitely worth considering.
In my experience, things tend to come out cleaner when you try and implement as much networking logic in a However, this is only really possible if the network protocols are designed to operate somewhat autonomously. |
You seem to be agreeing with me that reducing the reliance on swarm events seems to be a good idea? Is there a reason we can't remove swarm events and all the swarm methods and just make the FromSwarm and NetworkBehaviourAction handle these cases? |
Eventually we might get there yes. One situation I don't know how to resolve is managing listen addresses. The component that constructs the In general though, I do agree with you. I see |
This argument isn't any good actually. A If we all |
We are actually going to go the other way, see #3291. |
Summary
As per the discussion started on #3011 (comment):
Most of the callbacks were added on #2011 to be able to be used by
ipfs-embed
but according to @thomaseizinger:canonical place and not in multiple places. What makes the Peers behaviour privileged to collect stats on the number of listeners compared to any other behaviour?
Proposed Solution
Remove the callbacks and thus get of the problem of errors that can only be passed around by reference. Callbacks:
inject_new_listener
inject_new_listen_addr
inject_expired_listen_addr
inject_expired_external_addr
inject_listener_error
inject_listener_closed
these callbacks will be renamed to
on_
after #3011 lands, see #2832 for more info on itAre you planning to do it yourself in a pull request?
Maybe.
@thomaseizinger ptal and feel free to edit any mistake I made.
CC @rkuhn @dvc94ch
The text was updated successfully, but these errors were encountered: