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: Backwards compatible Encapsulate/Decapsulate/Join #272

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

Conversation

MarcoPolo
Copy link
Contributor

This changes Multiaddr.Encapsulate and Multiaddr.Decapsulate to be able to accept either a Multiaddr or Component as before. This reduces the amount of breaking changes in v0.15. The downside is more complexity and introducing another Component pointer in NewComponent so that it just works with Encapsulate/Decapsulate/Join.

We may also be able to get rid of the .Empty check and have folks check against nil as before. Note that this should avoid the original problems in v0.14 as we aren't behind an interface. It does however make it possible to hit a nil pointer panic where you couldn't before as you didn't have a pointer to begin with.

This would obviate the need for these changes:

@MarcoPolo MarcoPolo requested a review from sukunrt February 22, 2025 00:30
@@ -26,11 +26,11 @@ func (c *Component) AsMultiaddr() Multiaddr {
return []Component{*c}
}

func (c *Component) Encapsulate(o Multiaddr) Multiaddr {
func (c *Component) Encapsulate(o asMultiaddr) Multiaddr {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exported method with a private type. Should we export AsMultiaddr?

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