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: data CID is root CID of aggregate, not content CID #720

Merged
merged 2 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = ({ body }) => {
status: 'active',
pieceCid: 'baga',
dataCid: 'bafybeifnfkzjeohjf2dch2iqqpef3bfjylwxlcjws2msvdfyze5bvdprfm',
batchRootCid: 'bafybeidymjmzqihaz7oeiod3zyolzgcxwbum4b4nvo4aublm6quh6zb3ae',
dataModelSelector: 'Links/0/Links',
dealActivation: '<iso timestamp>',
created: '2021-07-14T19:27:14.934572Z',
Expand All @@ -23,6 +24,7 @@ module.exports = ({ body }) => {
status: 'terminated',
pieceCid: 'baga',
dataCid: 'bafybeifnfkzjeohjf2dch2iqqpef3bfjylwxlcjws2msvdfyze5bvdprfm',
batchRootCid: 'bafybeidymjmzqihaz7oeiod3zyolzgcxwbum4b4nvo4aublm6quh6zb4ae',
dataModelSelector: 'Links/0/Links',
dealActivation: '<iso timestamp>',
created: '2021-07-14T19:27:14.934572Z',
Expand All @@ -34,6 +36,7 @@ module.exports = ({ body }) => {
status: 'queued',
pieceCid: 'baga',
dataCid: 'bafybeica6klnrhlrbx6z24icefykpbwyypouglnypvnwb5esdm6yzcie3q',
batchRootCid: 'bafybeidymjmzqihaz7oeiod3zyolzgcxwbum4b4nvo4aublm6quh6zb5ae',
dataModelSelector: 'Links/0/Links'
}]
}
Expand Down
4 changes: 2 additions & 2 deletions packages/api/test/status.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('GET /status/:cid', () => {
storageProvider: 'f99',
status: 'Active',
pieceCid: 'baga',
dataCid: 'bafybeifnfkzjeohjf2dch2iqqpef3bfjylwxlcjws2msvdfyze5bvdprfm',
dataCid: 'bafybeidymjmzqihaz7oeiod3zyolzgcxwbum4b4nvo4aublm6quh6zb3ae',
dataModelSelector: 'Links/0/Links',
activation: '<iso timestamp>',
created: '2021-07-14T19:27:14.934572Z',
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('GET /status/:cid', () => {
deals: [{
status: 'Queued',
pieceCid: 'baga',
dataCid: 'bafybeica6klnrhlrbx6z24icefykpbwyypouglnypvnwb5esdm6yzcie3q',
dataCid: 'bafybeidymjmzqihaz7oeiod3zyolzgcxwbum4b4nvo4aublm6quh6zb5ae',
dataModelSelector: 'Links/0/Links'
}]
})
Expand Down
3 changes: 2 additions & 1 deletion packages/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,8 @@ export class DBClient {

const result = {}
for (const d of normalizeDeals(data)) {
const cid = d.dataCid
const cid = d.contentCid
delete d.contentCid
if (!Array.isArray(result[cid])) {
result[cid] = [d]
} else {
Expand Down
5 changes: 4 additions & 1 deletion packages/db/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ export function normalizeDeals (deals) {
dealId: deal.dealId,
storageProvider: deal.storageProvider,
status: deal.status[0].toUpperCase() + deal.status.slice(1),
// FIXME: should be returned from SQL as contentCid (aggregate.cid_v1)
contentCid: deal.dataCid,
pieceCid: deal.pieceCid,
dataCid: deal.dataCid,
// FIXME: should be returned from SQL as dataCid (aggregate.aggregate_cid)
dataCid: deal.batchRootCid,
dataModelSelector: deal.dataModelSelector,
activation: deal.dealActivation,
expiration: deal.dealExpiration,
Expand Down