Skip to content

Conversation

@2-towns
Copy link
Contributor

@2-towns 2-towns commented Oct 17, 2025

A small method that checks if a CID exists in the local store. Useful for integration with status-go and can be exposed in the Go wrapper.

@github-actions github-actions bot added the feat label Oct 17, 2025
@2-towns 2-towns requested a review from emizzle October 17, 2025 13:12
@2-towns 2-towns marked this pull request as ready for review October 17, 2025 13:14
Copy link
Contributor

@emizzle emizzle left a comment

Choose a reason for hiding this comment

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

Awesome, thank you for doing that Arnaud!

Copy link
Contributor

@marcinczenko marcinczenko left a comment

Choose a reason for hiding this comment

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

Thanks!

for blk in blocks:
check not (await blk.cid in localStore)

test "Should returns true when a cid is already in the local store":
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
test "Should returns true when a cid is already in the local store":
test "Should return true when a cid is already in the local store":

Copy link
Contributor

@marcinczenko marcinczenko Oct 20, 2025

Choose a reason for hiding this comment

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

To use this method in my current CodexClient - the hasLocalBlock needs to be exposed via API - Maybe you can already use in the lib, it would be good to have it available via API as well....

I am using this in codex/rest/api.nim:

  router.api(MethodGet, "/api/codex/v1/data/{cid}/has") do(
    cid: Cid, resp: HttpResponseRef
  ) -> RestApiResponse:
    ## Only test if the give CID is available in the local store
    ##
    var headers = buildCorsHeaders("GET", allowedOrigin)

    if cid.isErr:
      return RestApiResponse.error(Http400, $cid.error(), headers = headers)


    let cid = cid.get()
    
    let hasCid = await node.hasLocalBlock(cid)

    let json = %*{$cid: hasCid}

    return RestApiResponse.response($json, contentType = "application/json")

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd definitely say let's add this in a commit @marcinczenko. Ok for you @2-towns?

Copy link
Contributor Author

@2-towns 2-towns Oct 21, 2025

Choose a reason for hiding this comment

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

I'd definitely say let's add this in a commit @marcinczenko. Ok for you @2-towns?

I am already on it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay so sorry I was already working on it before your message @emizzle.

I pushed with the tests and updated the openapi description.

Don't hesitate next time @marcinczenko to commit / push.

Copy link
Contributor

Choose a reason for hiding this comment

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

My preference would be to name the endpoint /api/codex/v1/data/{cid}/exists instead of has, but definitely not a blocker for me.

Copy link
Contributor

Choose a reason for hiding this comment

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

exists sounds indeed more pro, but is harder to type ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

I have updated CodexClient to use exists API - if everything sounds ok, it should be ok to merge - or maybe we better wait a little bit till I adjust archive downloader?

Copy link
Contributor

@marcinczenko marcinczenko left a comment

Choose a reason for hiding this comment

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

I think we have all - but as I said, if it is not blocking other things, I would suggest to wait with merging - I am now changing archive downloader to use first only trigger the downloads, then to poll using "exists" API to finally locally fetch.

@2-towns 2-towns added this pull request to the merge queue Oct 30, 2025
@2-towns 2-towns removed this pull request from the merge queue due to a manual request Oct 30, 2025
@2-towns 2-towns force-pushed the feat/has-local-block branch from b2b29fa to cbe93c5 Compare October 30, 2025 05:05
@2-towns 2-towns enabled auto-merge October 30, 2025 05:05
@2-towns 2-towns added this pull request to the merge queue Oct 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 30, 2025
@2-towns 2-towns enabled auto-merge October 30, 2025 09:14
@2-towns 2-towns added this pull request to the merge queue Oct 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 30, 2025
@2-towns 2-towns added this pull request to the merge queue Oct 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 30, 2025
@emizzle emizzle added this pull request to the merge queue Oct 31, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 31, 2025
@emizzle emizzle added this pull request to the merge queue Nov 1, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Nov 1, 2025
@emizzle emizzle added this pull request to the merge queue Nov 2, 2025
Merged via the queue into master with commit db8f866 Nov 2, 2025
24 checks passed
@emizzle emizzle deleted the feat/has-local-block branch November 2, 2025 04:57
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.

4 participants