Taking #329 to its logical extreme, we're able to simplify the codebase (mostly codec.ts and its interaction with DefaultMultiaddr).
Precalculate a MultiaddrParts when constructing a DefaultMultiaddr.
MultiaddrParts is essentially an object containing all data which is stored in a DefaultMultiaddr.
This makes all DefaultMultiaddr methods cheap, at the expense of always storing the string, bytes, tuples, stringTuples, and path of the multiaddr.
The two important functions to review are stringToMultiaddrParts and bytesToMultiaddrParts, which convert untrusted string and bytes into MultiaddrParts.
Taking #329 to its logical extreme, we're able to simplify the codebase (mostly
codec.ts
and its interaction withDefaultMultiaddr
).Precalculate a
MultiaddrParts
when constructing aDefaultMultiaddr
.MultiaddrParts
is essentially an object containing all data which is stored in aDefaultMultiaddr
.This makes all
DefaultMultiaddr
methods cheap, at the expense of always storing the string, bytes, tuples, stringTuples, and path of the multiaddr.The two important functions to review are
stringToMultiaddrParts
andbytesToMultiaddrParts
, which convert untrusted string and bytes intoMultiaddrParts
.cc @tuyennhv