@@ -9,7 +9,7 @@ of organizations.
9
9
The information in this tutorial assumes knowledge of private data
10
10
stores and their use cases. For more information, check out :doc: `private-data/private-data `.
11
11
12
- The tutorial will take you through the following steps for practice defining,
12
+ The tutorial will take you through the following steps to practice defining,
13
13
configuring and using private data with Fabric:
14
14
15
15
#. :ref: `pd-build-json `
@@ -80,7 +80,7 @@ have the private data in their private database.
80
80
For more information on building a policy definition refer to the :doc: `endorsement-policies `
81
81
topic.
82
82
83
- .. code-block :: JSON
83
+ .. code :: json
84
84
85
85
// collections_config.json
86
86
@@ -137,7 +137,7 @@ be accessed.
137
137
Price int `json:"price"`
138
138
}
139
139
140
- Specifically access to the private data will be restricted as follows:
140
+ Specifically access to the private data will be restricted as follows:
141
141
142
142
- ``name, color, size, and owner `` will be visible to all members of the channel (Org1 and Org2)
143
143
- ``price `` only visible to members of Org1
@@ -432,61 +432,61 @@ database. As an authorized peer in Org1, we will query both sets of private data
432
432
The first ``query `` command calls the ``readMarble `` function which passes
433
433
``collectionMarbles `` as an argument.
434
434
435
- .. code :: GO
435
+ .. code-block :: GO
436
436
437
437
// ===============================================
438
438
// readMarble - read a marble from chaincode state
439
439
// ===============================================
440
440
441
441
func (t *SimpleChaincode) readMarble(stub shim.ChaincodeStubInterface, args []string) pb.Response {
442
- var name, jsonResp string
443
- var err error
444
- if len(args) != 1 {
445
- return shim.Error("Incorrect number of arguments. Expecting name of the marble to query")
446
- }
447
-
448
- name = args[0]
449
- valAsbytes, err := stub.GetPrivateData("collectionMarbles", name) //get the marble from chaincode state
450
-
451
- if err != nil {
452
- jsonResp = "{\"Error\":\"Failed to get state for " + name + "\"}"
453
- return shim.Error(jsonResp)
454
- } else if valAsbytes == nil {
455
- jsonResp = "{\"Error\":\"Marble does not exist: " + name + "\"}"
456
- return shim.Error(jsonResp)
457
- }
458
-
459
- return shim.Success(valAsbytes)
442
+ var name, jsonResp string
443
+ var err error
444
+ if len(args) != 1 {
445
+ return shim.Error("Incorrect number of arguments. Expecting name of the marble to query")
446
+ }
447
+
448
+ name = args[0]
449
+ valAsbytes, err := stub.GetPrivateData("collectionMarbles", name) //get the marble from chaincode state
450
+
451
+ if err != nil {
452
+ jsonResp = "{\"Error\":\"Failed to get state for " + name + "\"}"
453
+ return shim.Error(jsonResp)
454
+ } else if valAsbytes == nil {
455
+ jsonResp = "{\"Error\":\"Marble does not exist: " + name + "\"}"
456
+ return shim.Error(jsonResp)
457
+ }
458
+
459
+ return shim.Success(valAsbytes)
460
460
}
461
461
462
- The second ``query `` command calls the ``readMarblereadMarblePrivateDetails ``
462
+ The second ``query `` command calls the ``readMarblePrivateDetails ``
463
463
function which passes ``collectionMarblePrivateDetails `` as an argument.
464
464
465
- .. code :: GO
465
+ .. code-block :: GO
466
466
467
467
// ===============================================
468
- // readMarblereadMarblePrivateDetails - read a marble private details from chaincode state
468
+ // readMarblePrivateDetails - read a marble private details from chaincode state
469
469
// ===============================================
470
470
471
471
func (t *SimpleChaincode) readMarblePrivateDetails(stub shim.ChaincodeStubInterface, args []string) pb.Response {
472
- var name, jsonResp string
473
- var err error
474
-
475
- if len(args) != 1 {
476
- return shim.Error("Incorrect number of arguments. Expecting name of the marble to query")
477
- }
478
-
479
- name = args[0]
480
- valAsbytes, err := stub.GetPrivateData("collectionMarblePrivateDetails", name) //get the marble private details from chaincode state
481
-
482
- if err != nil {
483
- jsonResp = "{\"Error\":\"Failed to get private details for " + name + ": " + err.Error() + "\"}"
484
- return shim.Error(jsonResp)
485
- } else if valAsbytes == nil {
486
- jsonResp = "{\"Error\":\"Marble private details does not exist: " + name + "\"}"
487
- return shim.Error(jsonResp)
488
- }
489
- return shim.Success(valAsbytes)
472
+ var name, jsonResp string
473
+ var err error
474
+
475
+ if len(args) != 1 {
476
+ return shim.Error("Incorrect number of arguments. Expecting name of the marble to query")
477
+ }
478
+
479
+ name = args[0]
480
+ valAsbytes, err := stub.GetPrivateData("collectionMarblePrivateDetails", name) //get the marble private details from chaincode state
481
+
482
+ if err != nil {
483
+ jsonResp = "{\"Error\":\"Failed to get private details for " + name + ": " + err.Error() + "\"}"
484
+ return shim.Error(jsonResp)
485
+ } else if valAsbytes == nil {
486
+ jsonResp = "{\"Error\":\"Marble private details does not exist: " + name + "\"}"
487
+ return shim.Error(jsonResp)
488
+ }
489
+ return shim.Success(valAsbytes)
490
490
}
491
491
492
492
Now :guilabel: `Try it yourself `
@@ -664,7 +664,7 @@ price private data is purged.
664
664
665
665
{" docType" :" marblePrivateDetails" ," name" :" marble1" ," price" :99}
666
666
667
- The ``price `` data is still on the private data ledger.
667
+ The ``price `` data is still in the private data ledger.
668
668
669
669
Create a new **marble2 ** by issuing the following command. This transaction
670
670
creates a new block on the chain.
0 commit comments