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

middleware/hooks: preserve prehook response changes #566

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shyba
Copy link
Contributor

@shyba shyba commented Apr 13, 2022

Hi, thanks for this amazing project.

While implementing a prehook middleware, my changes to IPv4Peers were being discarded. This is what I had to do in order to fix it.

(I don't know if it is expected for prehook middleware implementations to modify responses, so feel free to discard the PR as well. The middleware I am working on needs to inject peers and using this hook was the cleanest approach.)

@jzelinskie
Copy link
Member

Hey there!

Yeah, this behavior is definitely up for discussion.
I think it makes sense for the semantics to be append and not replacing all peers from middleware before it.

What say you @mrd0ll4r?

@mrd0ll4r
Copy link
Member

mrd0ll4r commented Apr 14, 2022

Hmm. This kind of disrespects numWant now, because the storage will return numWant peers, which we potentially append to some existing peers. This also has subtle interactions with Complete and Incomplete, I think. Posthooks have those as well, but they can modify the response accordingly, if they want.

What's the reasoning on your end to implement this as a prehook instead of a posthook, @shyba ?

EDIT: Thinking about it some more, the most elegant approach would be to pass a (possibly non-empty) slice of bittorrent.Peer to the storage to fill up to numWant, but we can't do that with the current interfaces. So imho the preferred way to modify responses is via posthooks.

@shyba
Copy link
Contributor Author

shyba commented Apr 17, 2022 via email

@mrd0ll4r
Copy link
Member

mrd0ll4r commented Apr 17, 2022 via email

@shyba
Copy link
Contributor Author

shyba commented Apr 25, 2022

Opened issue #569, enjoy the trip!

mrd0ll4r
mrd0ll4r previously approved these changes Apr 25, 2022
@mrd0ll4r
Copy link
Member

CI is borked, might be fixed via #567, let's wait for that to land.

@mrd0ll4r
Copy link
Member

mrd0ll4r commented Jul 4, 2022

You should be able to rebase this and get the CI to work now :)

@shyba
Copy link
Contributor Author

shyba commented Sep 27, 2022

Sorry, just saw your message. Rebased, lets see :)

@mrd0ll4r
Copy link
Member

mrd0ll4r commented Oct 4, 2022

pretty sure CI is borked again, but due to something else this time :D Sorry... Not your fault, we'll fix it eventually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants