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

refactor!: simplify UtpSocket api #134

Closed
wants to merge 3 commits into from

Conversation

morph-dev
Copy link
Contributor

Remove accept/connect in favor of accept_with_cid/connect_with_cid (which are renamed to accept/connect).

This is needed in order to fix ethereum/trin#1596, which will be done in future PR.

Also simplified tracking of accepted and incoming connections: using HashMapDelay instead of HashMap+HashSetDelay combination.

@morph-dev morph-dev requested a review from carver January 19, 2025 18:30
@morph-dev morph-dev self-assigned this Jan 19, 2025
@KolbyML
Copy link
Member

KolbyML commented Jan 20, 2025

So we are dropping support for using uTP as a standard replacement for TCP? *_with_cid's are non-standard api's and are specific to our usecase. If we are dropping support for standard interfaces for using uTP as a replacement for a TCP socket, I think we should have a statement in the readme about it. To document to people who may want to use the library as we would no longer support the assumed interface, hence our library could probably no longer be used by 3rd party's not building a Portal client. As the whole connect_with_cid thing we do is quite unique to our project ie portal, I feel like at that point our uTP crate is not really usable to others.

I kind of feel against this change, as it is removing pretty base functionality for a uTP library. Yes we don't use the standard connection/accept interfaces, but that is more of a we do a very custom thing. If you are publishing this as a library to crates.io, I think we should support the standard uTP interface and not drop it because we don't use it.

I won't block this of course if others support removing this functionality, but it tastes a little off is all. Publishing a uTP crate with an interface only a Portal client would use, at that point it might make sense to move this crate into the Trin repo and call it trin-utp as only Trin will be able to use it.

If we go down the path of making this library Portal specific/specialized and merge this PR, I think we should also remove support for running this crate over UDP, as with us removing this API the library isn't really usable directly over UDP anymore

@KolbyML
Copy link
Member

KolbyML commented Jan 20, 2025

Also I would argue that this isn't a refactor as it is removing functionality, it is a feat

@KolbyML
Copy link
Member

KolbyML commented Jan 22, 2025

https://github.com/ikatson/rqbit A Rust Bittorrent client is likely to use uTP. I think it would be great if we could collaborate on 1 codebase and make it really good.

If we removed connect/accept as done in this PR projects like rqbit wouldn't be able to use ethereum/utp, and instead be forced to build there own uTP or add this connect/accept api back.

@KolbyML
Copy link
Member

KolbyML commented Jan 22, 2025

Here is an issue on uTP ikatson/rqbit#277 I think we should collaborate with them

@morph-dev
Copy link
Contributor Author

I didn't know initially how to preserve this functionality and fix the bug. But now I think I know a way, so I will give it a try.
Closing this PR.

@morph-dev morph-dev closed this Jan 24, 2025
@morph-dev morph-dev deleted the simplify branch January 27, 2025 11:27
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.

Content that is available in the network "not found" depending on network key / node id
2 participants