Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: precalculate multiaddr parts #330

Merged
merged 4 commits into from
Jul 28, 2023
Merged

fix: precalculate multiaddr parts #330

merged 4 commits into from
Jul 28, 2023

Conversation

wemeetagain
Copy link
Contributor

@wemeetagain wemeetagain commented Jul 14, 2023

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.

cc @tuyennhv

@achingbrain achingbrain changed the title feat: precalculate multiaddr parts fix: precalculate multiaddr parts Jul 28, 2023
@achingbrain achingbrain merged commit cf7e9c6 into master Jul 28, 2023
@achingbrain achingbrain deleted the feat/multiaddr-parts branch July 28, 2023 16:39
github-actions bot pushed a commit that referenced this pull request Jul 28, 2023
## [12.1.4](v12.1.3...v12.1.4) (2023-07-28)

### Bug Fixes

* precalculate multiaddr parts ([#330](#330)) ([cf7e9c6](cf7e9c6)), closes [#329](#329)

### Trivial Changes

* update project config ([#326](#326)) ([76fa6f5](76fa6f5))

### Documentation

* import from @multiformats/multiaddr ([#327](#327)) ([4dedd4b](4dedd4b))

### Dependencies

* bump multiformats from 11.0.2 to 12.0.1 ([#328](#328)) ([07d4f8a](07d4f8a))
* **dev:** bump aegir from 39.0.13 to 40.0.2 ([#333](#333)) ([3480741](3480741))
@github-actions
Copy link

🎉 This PR is included in version 12.1.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants