- There is no
Multiaddrinterface 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) == 0rather thans == nil. - Components do not implement
Multiaddras there is noMultiaddrto implement. Multiaddrcan 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
*Componentto aMultiaddr, prefer theMultiaddr.AppendComponentmethod as it will perform a nil pointer check on the*Componentbefore appending. If you know a*Componentis not nil, you may useappendnormally. - the
Multiaddrtype is simply a[]Component.- You can use
appendwhen you have aComponent. - You can use
for rangeloops.
- You can use
- If your use case supports it, prefer
appendorAppendComponentto append a Component to a Multiaddr rather than usingEncapsulateorJoin. It's much faster as it does not do a defensive copy.- Likewise, to join two Multiaddrs,
appendwill perform better thanEncapsulateorJoin.
- Likewise, to join two Multiaddrs,