Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
fix: offer to use collection instead of tenant (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos authored Sep 18, 2023
1 parent d1d3e8a commit d65fa26
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ interface Offer {
aggregate: PieceCID
// CID of all the segments part of the aggregate
pieces: PieceCID[]
// identifier of the tenant for the storefront `did:web:web3.storage`
// spade relies on tenant naming, so we map it here to tenant
tenant: string
// identifier of the collection for the tenant `did:web:web3.storage`
// spade relies on collections to identify different replication constraints.
collection: string
// enables ordering of offers to handle.
// Being it the number of ms since epoch, also means offers that fail and are retried will have "priority"
// It can also have lower numbers to prioritize certain actors in the future
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/data/offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const encode = {
const value = {
aggregate: dealRecord.aggregate.toString(),
pieces: dealRecord.pieces.map(p => p.toString()),
tenant: dealRecord.storefront,
collection: dealRecord.storefront,
orderID: dealRecord.insertedAt || Date.now()
} satisfies Offer

Expand Down Expand Up @@ -53,7 +53,7 @@ export const decode = {
return {
aggregate: parseLink(record.aggregate),
pieces: record.pieces.map(p => parseLink(p)),
storefront: record.tenant,
storefront: record.collection,
insertedAt: record.orderID
}
},
Expand All @@ -74,6 +74,6 @@ export type EncodedRecord = {
export type Offer = {
aggregate: string
pieces: string[]
tenant: string
collection: string
orderID: number
}
2 changes: 1 addition & 1 deletion test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ test('POST /', async t => {
const encodedOffer = JSON.parse(toString(bucketItem))

t.is(encodedOffer.aggregate, aggregate.link.link().toString())
t.is(encodedOffer.tenant, invocationConfig.with)
t.is(encodedOffer.collection, invocationConfig.with)
t.truthy(encodedOffer.orderID)
t.deepEqual(encodedOffer.pieces, offer.map(o => o.toString()))
})

0 comments on commit d65fa26

Please sign in to comment.