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(identify): use function call to validate Multiaddr #5898

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

LVivona
Copy link

@LVivona LVivona commented Feb 28, 2025

Description

Going through the protocols within libp2p to understand the repo. I found that incorporating a function call in this instance enhanced the readability and flow of the code.

Notes & open questions

  • This commit is a subjective opinion.
  • If this is something to check if it's a valid tcp, udp/quic or other, then I would be happy to apply it within libp2p-core as some sort of utility function.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@LVivona LVivona changed the title refactor(identify): use function call is_valid_connection to validate Multiaddr refactor(identify): use function call is_valid_connection for addr validation Feb 28, 2025
@LVivona LVivona changed the title refactor(identify): use function call is_valid_connection for addr validation refactor(identify): use function call to validate Multiaddr Feb 28, 2025
@elenaf9
Copy link
Contributor

elenaf9 commented Mar 1, 2025

Thank you for the PR @LVivona, but I am not sure if extracting that logic into a separate function is really an improvement here. Especially when it's only used in a single place.

@LVivona
Copy link
Author

LVivona commented Mar 1, 2025

Thank you for the reply @elenaf9, I do agree there is little to no logical benefit especially since it's used once as you mentioned, it is mainly a more subjective one when I was going though the protocol code, it just simplified the contract of the if statement, though I may be alone in thinking that way. :)

feel free to close the pull request if you feel like my reason is in-sufficient.

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.

2 participants