- There is no
Multiaddr
interface type. - Multiaddr is now a concrete type. Not an interface.
- Empty Multiaddrs/Component should generally be checked with
.Empty()
, not== nil
. This is similar to how slices should be checked withlen(s) == 0
rather thans == nil
. - Components do not implement
Multiaddr
as there is noMultiaddr
to implement. Multiaddr
can no longer be a key in a Map. If you want unique Multiaddrs, useMultiaddr.String()
as the key, otherwise you can use the pointer value*Multiaddr
.
- Multiaddr.Bytes() is a
O(n)
operation for n Components, as opposed to aO(1)
operation.
- If appending a
*Component
to aMultiaddr
, prefer theMultiaddr.AppendComponent
method as it will perform a nil pointer check on the*Component
before appending. If you know a*Component
is not nil, you may useappend
normally. - the
Multiaddr
type is simply a[]Component
.- You can use
append
when you have aComponent
. - You can use
for range
loops.
- You can use
- If your use case supports it, prefer
append
orAppendComponent
to append a Component to a Multiaddr rather than usingEncapsulate
orJoin
. It's much faster as it does not do a defensive copy.- Likewise, to join two Multiaddrs,
append
will perform better thanEncapsulate
orJoin
.
- Likewise, to join two Multiaddrs,