ChluNetwork / chlu-ipfs-support

Support libs to talk to IPFS
MIT License
1 stars 1 forks source link

store review records without publishing them #36

Closed fazo96 closed 6 years ago

fazo96 commented 6 years ago

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:

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

@kulpreet if this is ok I'll update the chlu-demo