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: listUploads includes parts property with list of links to CARs that contain it #2347

Merged
merged 7 commits into from
Jan 22, 2024

Conversation

gobengo
Copy link
Contributor

@gobengo gobengo commented Jan 9, 2024

Motivation:

Why touch the sql files?

  • the db tests wouldn't run cleanly without these changes. It would try to drop tables but fail due to dependencies on the uuid extension, other cols, etc. I think these changes are safe/good and will help others too but I can remove them if needed

@gobengo gobengo requested a review from a team as a code owner January 9, 2024 01:19
@gobengo
Copy link
Contributor Author

gobengo commented Jan 9, 2024

example upload list item (note partOf):

{
  "_id": "2",
  "type": "Upload",
  "name": "rand-07270196086601688",
  "created": "2024-01-09T01:17:28.22+00:00",
  "updated": "2024-01-09T01:17:28.22+00:00",
  "cid": "QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR",
  "dagSize": 1000,
  "pins": [
    [
      null
    ]
  ],
  "partOf": [
    "ipfs://bagbaiera6xcx7hiicm7sc523axbjf2otuu5nptt6brdzt4a5ulgn6qcfdwea"
  ],
  "deals": []
}

@gobengo gobengo changed the title listUploads includes partOf property with list of links to CARs that contain it feat: listUploads includes partOf property with list of links to CARs that contain it Jan 9, 2024
@@ -218,6 +219,8 @@ export type UploadItemOutput = {
dagSize?: definitions['content']['dag_size']
pins: Array<PinItemOutput>,
deals: Array<Deal>
// array of links to things containing this Upload (e.g. CARs)
partOf: Array<string>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just pluralise as parts? I like that this is similar to a partition content claim.

Copy link
Contributor Author

@gobengo gobengo Jan 9, 2024

Choose a reason for hiding this comment

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

Will do.

Just to check my understanding. Do we ever expect there to be more than one CAR that the Upload is sharded across? In my light testing it looked like only CARs with all blocks included. So I was thinking we could make a slightly different claim than just 'it's spread across these parts' but instead 'it's entirely within this CAR, i.e. it is a subset/partOf these CARs'.

Just now, I did make the change to call it parts as you suggested.

Copy link
Member

Choose a reason for hiding this comment

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

It can be multiple. If they send another CAR with the same root CID it should be added to the list.

packages/db/test/upload.spec.js Outdated Show resolved Hide resolved
packages/db/utils.js Outdated Show resolved Hide resolved
@gobengo gobengo changed the title feat: listUploads includes partOf property with list of links to CARs that contain it feat: listUploads includes parts property with list of links to CARs that contain it Jan 9, 2024
Copy link
Contributor

github-actions bot commented Jan 9, 2024

Website preview 🔗✨

build log

@gobengo
Copy link
Contributor Author

gobengo commented Jan 9, 2024

@alanshaw Thanks for the review. I think I made changes for each of your requests, and now the tests here are green.

I'll work in a branch off of this to add support for the backup table, but would love to test this part in staging++ and see how it goes.

@gobengo
Copy link
Contributor Author

gobengo commented Jan 9, 2024

This patch would add in support for the backup table #2352

packages/api/src/magic.link.js Outdated Show resolved Hide resolved
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
@gobengo gobengo merged commit b870346 into main Jan 22, 2024
22 checks passed
@gobengo gobengo deleted the 1704755248-list-includes-car branch January 22, 2024 18:18
@gobengo
Copy link
Contributor Author

gobengo commented Jan 22, 2024

✅ tested on staging

⚡ npm -s start -w packages/w3 -- list --json | head -n1 | jq .
{
  "_id": "315318962269342672",
  "type": "Car",
  "name": "Upload at 2024-01-22T19:10:44.048Z",
  "created": "2024-01-22T19:10:44.048+00:00",
  "updated": "2024-01-22T19:10:44.048+00:00",
  "cid": "bafybeieevwnu57cbcp5u6jsy6wxpj2waq5gfq5gc4spss4skpzk34vvxyy",
  "dagSize": 8848144,
  "pins": [
    {
      "status": "Pinned",
      "updated": "2024-01-22T19:10:44.048+00:00",
      "peerId": "bafzbeibhqavlasjc7dvbiopygwncnrtvjd2xmryk5laib7zyjor6kf3avm",
      "peerName": "elastic-ipfs",
      "region": null
    }
  ],
  "parts": [
    "bagbaierakuersmo7wndedhwk43e5xwcpzwenuda3dhpcsvkfibewg5gxl7oa"
  ],
  "deals": []
}

that part CID corresponds to https://bafybeieevwnu57cbcp5u6jsy6wxpj2waq5gfq5gc4spss4skpzk34vvxyy.ipfs-staging.w3s.link/

gobengo pushed a commit that referenced this pull request Jan 22, 2024
🤖 I have created a release *beep* *boop*
---


##
[7.24.0](api-v7.23.0...api-v7.24.0)
(2024-01-22)


### Features

* listUploads includes parts property with list of links to CARs that
contain it
([#2347](#2347))
([b870346](b870346))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
gobengo added a commit that referenced this pull request Mar 11, 2024
Motivation:
* add support for backup urls from backup table to
#2347
vasco-santos added a commit to nftstorage/nft.storage that referenced this pull request Jun 13, 2024
Uses same approach and naming (parts) as web3.storage changes:
web3-storage/web3.storage#2347

Closes #2674
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.

2 participants