问题
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:
- 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.
- Similar to point one except you can use the
jdbcSession()
functionality of theServiceHub
to create a custom table in the node's database. This table can easily be accessed from within your flows. - 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