Skip to content

Commit

Permalink
fix: data CID is root CID of aggregate, not content CID (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw authored Nov 30, 2021
1 parent b865bfb commit 8c67725
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
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

0 comments on commit 8c67725

Please sign in to comment.