Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove EncapsulateC
  • Loading branch information
MarcoPolo committed Feb 22, 2025
commit 0f95b11264313ad7120764a572616302ed00dd14
10 changes: 0 additions & 10 deletions multiaddr.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,6 @@ func (m Multiaddr) Encapsulate(other asMultiaddr) Multiaddr {
return Join(m, other)
}

func (m Multiaddr) EncapsulateC(c *Component) Multiaddr {
if c.Empty() {
return m
}
out := make([]Component, 0, len(m)+1)
out = append(out, m...)
out = append(out, *c)
return out
}

// Decapsulate unwraps Multiaddr up until the given Multiaddr is found.
func (m Multiaddr) Decapsulate(rightPartsAny asMultiaddr) Multiaddr {
if rightPartsAny == nil {
Expand Down
2 changes: 1 addition & 1 deletion multiaddr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ func TestUseNilComponent(t *testing.T) {
_ = foo.String()

var m Multiaddr = nil
m.EncapsulateC(foo)
m.Encapsulate(foo)
}

func TestFilterAddrs(t *testing.T) {
Expand Down
6 changes: 4 additions & 2 deletions v015-MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- There is no `Multiaddr` interface type.
- Multiaddr is now a concrete type. Not an interface.
- Empty Multiaddrs/ should be checked with `.Empty()`, not `== nil`. This is similar to how slices should be checked with `len(s) == 0` rather than `s == nil`.
- Empty Multiaddrs/Component should generally be checked with `.Empty()`, not `== nil`. This is similar to how slices should be checked with `len(s) == 0` rather than `s == nil`.
- Components do not implement `Multiaddr` as there is no `Multiaddr` to implement.
- `Multiaddr` can no longer be a key in a Map. If you want unique Multiaddrs, use `Multiaddr.String()` as the key, otherwise you can use the pointer value `*Multiaddr`.

Expand All @@ -12,4 +12,6 @@

## Migration tips for v0.15

- If trying to encapsulate a Component to a Multiaddr, use `m.encapsulateC(c)`, instead of the old form of `m.Encapsulate(c)`. `Encapsulate` now only accepts a `Multiaddr`. `EncapsulateC` accepts a `Component`.
- If your use case supports it, prefer `append` to append a Component to a
Multiaddr rather than using `Encapsulate`. It's much faster as it does not do
a defensive copy.