-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: precalculate multiaddr parts (#330)
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`. --------- Co-authored-by: Tuyen Nguyen <vutuyen2636@gmail.com>
- Loading branch information
1 parent
76fa6f5
commit cf7e9c6
Showing
3 changed files
with
135 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.