This PR contains the ground work for making #24 work:
storeReviewRecord has a new publish boolean option that is true by default but when set to false it stores the review record in IPFS without doing the following steps (actually advertising/publishing the review)
Originally we wanted to use IPFS to calculate the resulting multihash without writing the content to IPFS but it looks like this might not be possible using js-ipfs yet. I opened an issue about this: https://github.com/ipfs/js-ipfs/issues/1205 We will be able to quickly revisit this part when there is a way to do that
Another new option to storeReviewRecord is expectedMultihash. If this is provided, then the library will halt publishing if the storeReviewRecord operation results in a multihash different than expected. This is a failsafe measure to avoid accidentally publishing the wrong review after having written its multihash to the blockchain
So to complete the job we just need to update chlu-demo to making reviews using this process:
calling storeReviewRecord with publish: false. This will error out if there are any problems in the review record and returns the multihash if there aren't
creating the blockchain transaction with the multihash just provided
calling storeReviewRecord with expectedMultihash so that this time it gets published. This will error out if something changed and the review record multihash is different now
Internally, stuff about publishing has been taken out to a different function making storeReviewRecord a shorter method. There are also new tests for all the new use cases
This PR contains the ground work for making #24 work:
storeReviewRecord
has a newpublish
boolean option that is true by default but when set to false it stores the review record in IPFS without doing the following steps (actually advertising/publishing the review)Originally we wanted to use IPFS to calculate the resulting multihash without writing the content to IPFS but it looks like this might not be possible using js-ipfs yet. I opened an issue about this: https://github.com/ipfs/js-ipfs/issues/1205 We will be able to quickly revisit this part when there is a way to do that
Another new option to
storeReviewRecord
isexpectedMultihash
. If this is provided, then the library will halt publishing if the storeReviewRecord operation results in a multihash different than expected. This is a failsafe measure to avoid accidentally publishing the wrong review after having written its multihash to the blockchainSo to complete the job we just need to update chlu-demo to making reviews using this process:
storeReviewRecord
withpublish: false
. This will error out if there are any problems in the review record and returns the multihash if there aren'tstoreReviewRecord
withexpectedMultihash
so that this time it gets published. This will error out if something changed and the review record multihash is different nowInternally, stuff about publishing has been taken out to a different function making storeReviewRecord a shorter method. There are also new tests for all the new use cases
@kulpreet if this is ok I'll update the chlu-demo