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

feat: return Claim from ContentClaimsLocator#locate #12

Closed
wants to merge 4 commits into from

Conversation

travis
Copy link
Member

@travis travis commented Oct 1, 2024

Return underlying Claim with Location - I made Claim mandatory and it didn't seem to break anything, but I'm not sure if there are cases where we might want to return Locations without including a Claim - open to making this optional!

Add another caching `Map` in `ContentClaimsLocator`. This one caches the fetched content claims and gives callers a way to access the claims that were used as the basis for the `Location` returned by `locate`.

I'm not totally convinced this is the right way to handle this, but it does give downstream users the ability to get the raw content claims associated with a CID.
@alanshaw
Copy link
Member

alanshaw commented Oct 1, 2024

I'd return the claims involved as part of return value of locate. A global cache of claims is great but at some point I imagine we'll want to use this not in a worker and limit it's size, but since you've established the convention of accessing any claim from any past call to locate you'll potentially break consumers. If you return the claims this library can manage the cache how it likes and the consumer can cache (or not) the claims it is interested in.

@travis
Copy link
Member Author

travis commented Oct 2, 2024

ok great - even easier! updated the PR. Any idea what the test failure might be? it's a very odd one...

@travis
Copy link
Member Author

travis commented Oct 2, 2024

update: figured out the test failure! upgrading the pnpm action fixed it

@travis travis changed the title feat: cache fetched content claims in Locator feat: return Claim from ContentClaimsLocator#locate Oct 2, 2024
@@ -82,7 +82,8 @@ export class ContentClaimsLocator {
site: [{
location: claim.location.map(l => new URL(l)),
range: { offset: claim.range.offset, length: claim.range.length }
}]
}],
claim
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in a loop - multiple claims can contribute to this "location". I think it needs to be a DigestMap<Claim> or Claim[]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh jeez good call - will update!

@alanshaw
Copy link
Member

alanshaw commented Oct 2, 2024

Can you add a test/assertion(s)? 🙏

@travis
Copy link
Member Author

travis commented Oct 7, 2024

I'm going to put a pause on this, pending @Peeja's RFC referenced here: storacha/project-tracking#138 (comment)

edit: that said I did work up a test for this! have pushed it but probably worth expanding if we go this route.

…or#locate

we may want to add more assertions here, but I'm putting this on pause for now anyway - can follow up once we have more clarity
@Peeja
Copy link
Member

Peeja commented Dec 2, 2024

Pretty sure this is now moot, but we can restore it if we need to.

@Peeja Peeja closed this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants