-
Notifications
You must be signed in to change notification settings - Fork 47
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
Provide an efficient API to check whether a CID has IDENTITY
multihash code
#133
Closed
2 tasks done
Labels
need/triage
Needs initial labeling and prioritization
Comments
This comment has been minimized.
This comment has been minimized.
masih
added a commit
that referenced
this issue
Sep 24, 2021
Implement a fail-fast function that checks whether the code of a CID is `multihash.IDENTITY` or not. Add benchmarks that compare three ways of checking for `multihash.IDENTITY` code: 1. `Cid.Prefix().MhType` 2. Decode of `Cid.Has()` 3. The new `Cid.IsIdentity()` API Fixes #133
As shown by benchmarks in #134 the gains in comparison with using the existing This means that users who wish to check for |
masih
added a commit
that referenced
this issue
Sep 27, 2021
Add benchmarks that compare two ways of checking for `multihash.IDENTITY` code: 1. `Cid.Prefix().MhType` 2. Decode of `Cid.Has()` Relates to #133
To document the efficiency of existing APIs for |
masih
added a commit
that referenced
this issue
Sep 27, 2021
Add benchmarks that compare two ways of checking for `multihash.IDENTITY` code: 1. `Cid.Prefix().MhType` 2. Decode of `Cid.Hash()` Relates to #133
masih
added a commit
that referenced
this issue
Sep 27, 2021
Add benchmarks that compare two ways of checking for `multihash.IDENTITY` code: 1. `Cid.Prefix().MhType` 2. Decode of `Cid.Hash()` Relates to #133
masih
added a commit
that referenced
this issue
Nov 8, 2021
Add benchmarks that compare two ways of checking for `multihash.IDENTITY` code: 1. `Cid.Prefix().MhType` 2. Decode of `Cid.Hash()` This benchmark illustrates that using Cid.Prefix is efficient than `multihash.Decode`. Users wishing to perform such a check should use `Cid.Prefix`. Consider that `Cid.Prefix` is already efficient enough and gains are likely small if a dedicated API for performing this check to be introduced. Relates to #133
masih
added a commit
that referenced
this issue
Nov 8, 2021
Add benchmarks that compare two ways of checking for `multihash.IDENTITY` code: 1. `Cid.Prefix().MhType` 2. Decode of `Cid.Hash()` This benchmark illustrates that using Cid.Prefix is efficient than `multihash.Decode`. Users wishing to perform such a check should use `Cid.Prefix`. Consider that `Cid.Prefix` is already efficient enough and gains are likely small if a dedicated API for performing this check to be introduced. Relates to #133
masih
added a commit
that referenced
this issue
Nov 8, 2021
Add benchmarks that compare two ways of checking for `multihash.IDENTITY` code: 1. `Cid.Prefix().MhType` 2. Decode of `Cid.Hash()` This benchmark illustrates that using Cid.Prefix is efficient than `multihash.Decode`. Users wishing to perform such a check should use `Cid.Prefix`. Consider that `Cid.Prefix` is already efficient enough and gains are likely small if a dedicated API for performing this check to be introduced. Relates to #133
masih
added a commit
that referenced
this issue
Nov 8, 2021
Add benchmarks that compare two ways of checking for `multihash.IDENTITY` code: 1. `Cid.Prefix().MhType` 2. Decode of `Cid.Hash()` This benchmark illustrates that using Cid.Prefix is more efficient than `multihash.Decode`. Users wishing to perform such a check should use `Cid.Prefix`. Consider that `Cid.Prefix` is already efficient enough and introducing a dedicated API for performing this check will likely result in small gains. Relates to #133
masih
added a commit
that referenced
this issue
Nov 8, 2021
Add benchmarks that compare two ways of checking for `multihash.IDENTITY` code: 1. `Cid.Prefix().MhType` 2. Decode of `Cid.Hash()` This benchmark illustrates that using Cid.Prefix is more efficient than `multihash.Decode`. Users wishing to perform such a check should use `Cid.Prefix`. Consider that `Cid.Prefix` is already efficient enough and introducing a dedicated API for performing this check will likely result in small gains. Relates to #133
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CIDs with multihash code
IDENTITY
typically require special handling when encountered in blockstores. This is because, such CIDs contain the data within themselves; the data is simply the multihash digest of that CID, since multihash codeIDENTITY
corresponds tocopy
hash function.To handle them gracefully checks are needed to indicate whether a given CID has
IDENTITY
code or not, and checks would have to run for almost all operations on blockstore API. It is therefore, highly desirable to check as efficiently as possible.The current APIs offered provide two ways to perform the check:
cid.Prefix().MhType
cid.Hash()
viago-multihash
API to extract the codeBlockstore implementations would benefit from an API that checks whether a given CID or digest of a CID has
IDENTITY
code in a "fail-fast" manner. This is where the check would return as fast as possible if a CID is not anIDENTITY
without checking for the validity of the CID first, then decoding digest, then comparing multihash code.The rationale for a "fail-fast" check is:
IDENTITY
multihash code, it doesn't always need to be fully decoded in order for a block to be returned (e.g. when CID is used as key in a map)IDENTITY
therefore we want to pay the price of decoding only when we have to, and certainly not for every call to blockstore.I therefore propose to:
IDENTITY
code.The text was updated successfully, but these errors were encountered: