How to store only node specific off-ledger custom data in corda?

扶醉桌前 提交于 2019-12-11 10:55:15

问题


I created custom table in corda using QueryableState. e.g. IOUStates table. I can able to see the custom information getting stored in this kind of table. but i observed that if party A and Party B is doing the transaction then this custom information gets stored at both the places , e.g. IOUStates table getting created at nodeA ledger as well as nodeB's ledger. and custom information is stored in partyA's and PartyB's ledger.

My Question is :-

If some Transaction is getting processed from PartyA's node , then I want to store part of the transaction's data i.e. custom data ONLY at partyA's Ledger.* level . i.e. off-Ledger of partA only.

It should not be shared with partyB.

In simple case , how to store Only node specific off ledger custom data ?

Awaiting for some reply...

Thanks.


回答1:


There's a number of ways to achieve this:

  1. Don't use Corda at all! If the data is truly off-ledger then why are you using Corda? Instead, store it in a separate database. Of course you can "JOIN" it with on-ledger data if required, as the on-ledger data is stored in a SQL database.
  2. Similar to point one except you can use the jdbcSession() functionality of the ServiceHub to create a custom table in the node's database. This table can easily be accessed from within your flows.
  3. Create a ContractState object that only has one participant: the node that wants to store the data. I call this a "unilateral" state, i.e. a state that only one party ever stores.

Most importantly, if you don't want to share some data with a counter-party then it should never be disclosed inside a corda state object or attachment that another party might see. Instead:

  • inside your flows, you can use the data encapsulated within the shared state object (e.g. the IOU) to derive the private data
  • alternatively if the data is supplied when the flow begins then store the private data locally using one of the methods above


来源:https://stackoverflow.com/questions/46031924/how-to-store-only-node-specific-off-ledger-custom-data-in-corda

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!