In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
We can see the list of parameters when the chain code is called. The parameters of the three base64 codes are: setPrivate, name and bob.
If we have a relationship with data privacy, this may be problematic. On the one hand, the data is stored in a private dataset, so that only limited institutional nodes can be saved. On the other hand, the chain code input of this part of private data is publicly visible and permanently stored in the block chain of all peer nodes. If this is not what you expect, then we also need to hide the input data. This is why transient data input is used.
6. Scenario 3 demonstration: using private data and transient data input
If you want to ensure that the data input is not saved on the chain, then scenario 3 is the recommended way. In this scenario, transient data input is used and the data is stored in the private data set of Org1. We use the setPrivateTransient and getPrivate methods to access the chain code:
In our chain code, we implement the function to encode the transient data into a specific JSON format {"key": "some key", "value": "some value"} (chain code 134137 lines). We also require that the transient data contain a keyvalue key (chain code 149lines). In order to use transient data in command line invocation, we need to encode it with base64 first.
Export KEYVALUE=$ (echo-n "{\" key\ ":\" name\ " \ "value\":\ "charlie\"} "| base64 | tr-d\\ n) docker exec cli peer chaincode invoke-o orderer.example.com:7050-- tls\-- cafile / opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem\-- peerAddresses peer0.org1.example.com:7051\-- tlsRootCertFiles / opt/gopath/src/github. Com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt\-peerAddresses peer0.org2.example.com:9051\-tlsRootCertFiles / opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt\-C mychannel-n mycc-c'{"Args": ["setPrivateTransient"]}'\ -- transient "{\" keyvalue\ ":\" $KEYVALUE\ "}" docker exec cli peer chaincode query-C mychannel-n mycc-c'{"Args": ["getPrivate" "name"]}'
The results are as follows:
Again, let's first look at the state of the world. This is similar to what we saw in scenario 2. The actual data is saved only in peer0.org1.example.com, while the hash is saved in both peer nodes. Note that the value of the revised version is currently 2, while the value of the first revision in scenario 2 is 1. It is the chain code call that facilitates the revision of the data.
Similar to scenario 2, in the transaction on the blockchain, we can see that there is no Write Set.
We can also see a list of parameters that do not call the chain code. The only parameter is the chain code function name, setPrivateTransient. The specific call data {"key": "name", "value": "charlie"} does not appear on the block chain.
We see that the combination of private data and private data provides some degree of data privacy.
7. Scenario 4 demonstration: does not apply to private data, using transient data input
Finally, let's take a look at the demonstration of the imaginary scene. In scenario 3, the transient data is used as data and then saved in the open state of the ledger. We use setTransient and get to access the chain code:
Export KEYVALUE=$ (echo-n "{\" key\ ":\" name\ " \ "value\":\ "david\"} "| base64 | tr-d\\ n) docker exec cli peer chaincode invoke-o orderer.example.com:7050-- tls\-- cafile / opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem\-- peerAddresses peer0.org1.example.com:7051\-- tlsRootCertFiles / opt/gopath/src/github. Com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt\-peerAddresses peer0.org2.example.com:9051\-tlsRootCertFiles / opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt\-C mychannel-n mycc-c'{"Args": ["setTransient"]}'\ -- transient "{\" keyvalue\ ":\" $KEYVALUE\ "}" docker exec cli peer chaincode query-C mychannel-n mycc-c'{"Args": ["get" "name"]}'
The results are as follows:
You can see that the public status has been updated, and both nodes currently have the same data. Note that the revised version is updated to 2.
We see that the key / value pairs in Write Set are name and david,base64 codes.
We don't see the input data in the parameters, just the name of the method called setTransient.
This is the end of this article on "sample Analysis of the use of fabric Transient Data and Private Data". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.