store review records without publishing them #36
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: ipfs/js-ipfs#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