-
Notifications
You must be signed in to change notification settings - Fork 21
Adds endpoint for proposing a storage deal #68
Adds endpoint for proposing a storage deal #68
Conversation
8ea3833
to
365df8b
Compare
"Signature":"c2lnbmF0dXJycmVlZQ==" | ||
} | ||
*/ | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I got back locally when I ran it. This somewhat differs from what I expected, honestly, but I represented what is currently returning from go-filecoin
.
API.md
Outdated
const storageDealProposal = await fc.client.proposeStorageDeal(miner, cid, askId, time, { allowDuplicates: true }) | ||
|
||
// with allow duplicates flag and options, order important | ||
const storageDealProposal = await fc.client.proposeStorageDeal(miner, cid, askId, time, { allowDuplicates: true }, { signal: "some signal to abort" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my proposal for how to handle all the arguments and also options on our end. If you use the go-filecoin
command line, it ends up being and optional flag like so: --allow-duplicates
. If you'd like a different interface, let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In existing endpoints both options are bundled together e.g. { allowDuplicates, signal }
. I think this is best for simplicity (and consistency) and we'll deal with a collision if/when it happens.
@alanshaw This is the propose storage deal one, let me know if you have questions. |
API.md
Outdated
| cid | `String` | CID of the data to be stored | | ||
| id | `String` | ID of ask for which to propose a deal | | ||
| time | `String` | Time in blocks (about 30 seconds per block) to store data. For example, storing for 1 day (2 blocks/min * 60 min/hr * 24 hr/day) = 2880 blocks. | | ||
| allowDuplicates | `Boolean` | Allows duplicate proposals to be created. Unless this flag is set, you will not be able to make more than one deal per piece per miner. This protection exists to prevent erroneous duplicate deals. This parameter is not required. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be options.allowDuplicates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks for the clarifying.
API.md
Outdated
const storageDealProposal = await fc.client.proposeStorageDeal(miner, cid, askId, time, { allowDuplicates: true }) | ||
|
||
// with allow duplicates flag and options, order important | ||
const storageDealProposal = await fc.client.proposeStorageDeal(miner, cid, askId, time, { allowDuplicates: true }, { signal: "some signal to abort" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In existing endpoints both options are bundled together e.g. { allowDuplicates, signal }
. I think this is best for simplicity (and consistency) and we'll deal with a collision if/when it happens.
}, | ||
"ProofInfo":null, | ||
"Signature":"c2lnbmF0dXJycmVlZQ==" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use toCamel
utility on this response to be more idiomatic for JS users.
|
||
const duplicatesParam = allowDuplicates ? `&allow-duplicates=${encodeURIComponent(allowDuplicates)}` : "" | ||
|
||
const url = `${toUri(config.apiAddr)}/api/client/proposeStorageDeal?arg=${miner}&arg=${cid}&arg${askId}&arg${time}${duplicatesParam}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the querystring
module to stringify an object when multiple params. Please check other endpoints for examples.
* /api/client/propose-storage-deal Propose a storage deal with a storage miner Arguments * arg [string]: Address of miner to send storage proposal Required: yes. * arg [string]: CID of the data to be stored Required: yes. * arg [string]: ID of ask for which to propose a deal Required: yes. * arg [string]: Time in blocks (about 30 seconds per block) to store data Required: yes. * allow-duplicates [bool]: Allows duplicate proposals to be created. Unless this flag is set, you will not be able to make more than one deal per piece per miner. This protection exists to prevent erroneous duplicate deals. Required: no. Response On success, the call to this endpoint will return with 200 and the following body: { "State":7, "Message":"", "ProposalCid": { "/":"zDPWYqFD8CNXu7Mo9qPSUANbTK2vi9vJBnvavF9S1pVGPHafVHpT" }, "ProofInfo": { "SectorID":1, "CommitmentMessage": { "/":"zDPWYqFCtHkWNkE2p6t6TeV1sPP5kbnKc5ajUhMVV8xvrw1u5F1R" }, "PieceInclusionProof":"EiAbbOy4pChsCYqFYA6qJaUJYStlnwYMdQPHZX7YBkVXDD6vgmGTPnWrcdA9M0oAXQCzOq735YKySLUoTI6pAw==" }, "Signature":"c2lnbmF0dXJycmVlZQ==" }
b60479e
to
e69f5d8
Compare
* The thought here being this is more idiomatic for JS users * Updates params with querystring
bb3fd7b
to
6628693
Compare
Updated! Let me know if there's anything else. |
Adds the ability to propose a storage deal
Issue #15
Endpoint
/api/client/propose-storage-deal
Description
Propose a storage deal with a storage miner
Arguments
Response
On success, the call to this endpoint will return with 200 and the following body:
resolves #15