Nov 11/2022 Update

This commit is contained in:
Fernando Garzon 2022-11-11 11:00:38 -08:00
parent ed74286f4d
commit 5e3e50fd37
2 changed files with 99 additions and 71 deletions

View file

@ -7,10 +7,9 @@ import (
"github.com/hyperledger/fabric-contract-api-go/contractapi"
"github.com/xeipuuv/gojsonschema"
"log"
"crypto/sha256"
"encoding/hex"
"reflect"
"encoding/hex"
"log"
)
// SmartContract provides functions for managing an Asset
@ -46,19 +45,19 @@ type SmartContract struct {
// Insert struct field in alphabetic order => to achieve determinism across languages
// golang keeps the order when marshal to json but doesn't order automatically
var lastSchemaHash string
var lastSchemaHash string
type Data struct {
Contributor string `json:"Contributor"`
ContributorId string `json:"ContributorId"`
ContentHash string `json:"ContentHash"`
Id string `json:"Id"`
Owners []string `json:"Owners"`
Contributor string `json:"Contributor"`
ContributorId string `json:"ContributorId"`
ContentHash string `json:"ContentHash"`
Id string `json:"Id"`
Owner string `json:"Owners"`
JsonFileContent map[string]interface{}
}
type Schema struct {
Version int `json:"Version"`
Version int `json:"Version"`
Hash string `json:"Hash"`
JsonSchemaContent map[string]interface{}
}
@ -76,7 +75,7 @@ func (s *SmartContract) InitLedger(ctx contractapi.TransactionContextInterface,
} else if error_file != nil {
return fmt.Errorf("failed to read 1st json files: %v", error_file)
} else {
firstJsonFileHash, initDataHashError := s.Hash(ctx, InitData)
schemaJsonFileHash, schemaHashError := s.Hash(ctx, InitSchema)
lastSchemaHash = schemaJsonFileHash
@ -84,14 +83,14 @@ func (s *SmartContract) InitLedger(ctx contractapi.TransactionContextInterface,
return fmt.Errorf("failed to calculate 1st json file hash: %v", initDataHashError)
} else if schemaHashError != nil {
return fmt.Errorf("failed to calculate schema hash: %v", schemaHashError)
} else{
} else {
data := Data{
Contributor: "pepitoperes@email.com",
ContributorId: "ABC123",
ContentHash: firstJsonFileHash,
Id: "00000",
Owners: []string{"CIA", "DEA", "FBI"},
JsonFileContent: firstJsonFileContent,
Contributor: "pepitoperes@email.com",
ContributorId: "ABC123",
ContentHash: firstJsonFileHash,
Id: "00000",
Owner: "CIA",
JsonFileContent: firstJsonFileContent,
}
assetJSON, err := json.Marshal(data)
@ -102,16 +101,18 @@ func (s *SmartContract) InitLedger(ctx contractapi.TransactionContextInterface,
err = ctx.GetStub().PutState(data.ContentHash, assetJSON)
if err != nil {
return fmt.Errorf("failed to put to world state. %v", err)
} else {
fmt.Print("A new Data Struct has been created with the hash %v", firstJsonFileHash)
}
//This is the definition of the Schema that we should use for validate all the JSON files from now on.
initSchema := Schema{
Version: 1,
Hash: schemaJsonFileHash,
Version: 1,
Hash: schemaJsonFileHash,
JsonSchemaContent: schemaJsonFileContent,
}
assetJSON, err = json.Marshal(initSchema)
if err != nil {
return err
@ -120,34 +121,35 @@ func (s *SmartContract) InitLedger(ctx contractapi.TransactionContextInterface,
err = ctx.GetStub().PutState(initSchema.Hash, assetJSON)
if err != nil {
return fmt.Errorf("failed to put to world state. %v", err)
} else {
fmt.Print("A new Schema has been created with the hash %v", schemaJsonFileHash)
}
}
}
return nil
}
func (s *SmartContract) LastSchemaHash(ctx contractapi.TransactionContextInterface) (string) {
func (s *SmartContract) LastSchemaHash(ctx contractapi.TransactionContextInterface) string {
return lastSchemaHash
}
func (s *SmartContract) Hash(ctx contractapi.TransactionContextInterface, doc string) (string, error) {
var v interface{}
err := json.Unmarshal([]byte(doc), &v)
if err != nil{
if err != nil {
return "HASH CRASH", fmt.Errorf("Unable to unmarshal Json String passed as parameter. No hash calculation can be completed: %v", err)
} else {
cdoc, err := json.Marshal(v)
if err != nil{
if err != nil {
return "HASH CRASH", fmt.Errorf("Unable to re-marshal interface into json format. No hash calculation can be completed: %v", err)
} else{
} else {
sum := sha256.Sum256(cdoc)
return hex.EncodeToString(sum[0:]), nil
}
}
}
func (s *SmartContract) JsonReader(ctx contractapi.TransactionContextInterface, content string) (map[string]interface{}, error) {
var payload map[string]interface{}
@ -157,11 +159,11 @@ func (s *SmartContract) JsonReader(ctx contractapi.TransactionContextInterface,
log.Fatal("Error during Unmarshal() of string into type Interface: ", err)
}
return payload, nil
}
// GetAllAssets returns all assets found in world state
func (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface) ([]*Data, error) {
/*func (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface) ([]*Data, error) {
// range query with empty string for startKey and endKey does an
// open-ended query of all assets in the chaincode namespace.
resultsIterator, err := ctx.GetStub().GetStateByRange("", "")
@ -183,20 +185,21 @@ func (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface
if panicInfo := recover(); panicInfo != nil {
fmt.Printf("%v, %s", panicInfo, string(debug.Stack()))
}
}()
}()
err = json.Unmarshal(queryResponse.Value, &data)
}
if err != nil {
log.Fatal("Error during Unmarshal() of string into type Data: ", err)
return nil, err
}
dataSamples = append(dataSamples, &data)
}
return dataSamples, nil
}
*/
func (s *SmartContract) SchemaExists(ctx contractapi.TransactionContextInterface, Hash string) (bool, error) {
assetJSON, err := ctx.GetStub().GetState(Hash)
@ -226,7 +229,7 @@ func (s *SmartContract) CreateNewSchema(ctx contractapi.TransactionContextInterf
// Verify that an schema with exact same structure doesn't exist yet.
hashContent, _ := s.Hash(ctx, newSchemaContent)
exists, err := s.SchemaExists(ctx, hashContent)
if exists{
if exists {
return fmt.Errorf("Schema already exists: %v", err)
} else {
lastSchemaHash = hashContent
@ -246,39 +249,38 @@ func (s *SmartContract) CreateNewSchema(ctx contractapi.TransactionContextInterf
return fmt.Errorf("failed to put to world state. %v", err)
}
}
return nil
}
}
return nil
}
}
// GetAllSchemas returns all schemas found in world state
//func (s *SmartContract) GetAllSchemas(ctx contractapi.TransactionContextInterface) ([]Schema, error) {
// range query with empty string for startKey and endKey does an
// open-ended query of all schemas in the chaincode namespace.
//resultsIterator, err := ctx.GetStub().GetStateByRange("", "")
//if err != nil {
// return nil, err
//}
//defer resultsIterator.Close()
// range query with empty string for startKey and endKey does an
// open-ended query of all schemas in the chaincode namespace.
//resultsIterator, err := ctx.GetStub().GetStateByRange("", "")
//if err != nil {
// return nil, err
//}
//defer resultsIterator.Close()
//var schemaSamples []*Schema
//for resultsIterator.HasNext() {
// queryResponse, err := resultsIterator.Next()
// if err != nil {
// return nil, err
// }
//var schemaSamples []*Schema
//for resultsIterator.HasNext() {
// queryResponse, err := resultsIterator.Next()
// if err != nil {
// return nil, err
// }
// var schm Schema
// err = json.Unmarshal(queryResponse.Value, &schm)
// if err != nil {
// return nil, err
// }
// schemaSamples = append(schemaSamples, &schm)
//}
// var schm Schema
// err = json.Unmarshal(queryResponse.Value, &schm)
// if err != nil {
// return nil, err
// }
// schemaSamples = append(schemaSamples, &schm)
//}
//return schemas, nil
//return schemas, nil
//}
// AssetExists returns true when asset with given ID exists in world state
@ -330,15 +332,15 @@ func (s *SmartContract) ValidJson(ctx contractapi.TransactionContextInterface, J
// CreateDataSample issues a new Data Sample to the world state with given details.
func (s *SmartContract) CreateDataSample(ctx contractapi.TransactionContextInterface,
Contributor string, ContributorId string, Id string, JsonFileContent string) error {
Contributor string, ContributorId string, Id string, Owner string, JsonFileContent string) error {
ContentHash, err := s.Hash(ctx, JsonFileContent)
exists, err := s.AssetExists(ctx, ContentHash)
if err != nil {
return err
}
if exists {
return fmt.Errorf("the asset %s already exists", Id)
return fmt.Errorf("the asset %s already exists", ContentHash)
}
valid, err := s.ValidJson(ctx, JsonFileContent)
@ -357,7 +359,7 @@ func (s *SmartContract) CreateDataSample(ctx contractapi.TransactionContextInter
ContributorId: ContributorId,
ContentHash: ContentHash,
Id: Id,
Owners: []string{"DOE", "DOS", "DOJ"},
Owner: Owner,
JsonFileContent: jsonFileContent,
}
@ -367,10 +369,11 @@ func (s *SmartContract) CreateDataSample(ctx contractapi.TransactionContextInter
}
return ctx.GetStub().PutState(ContentHash, assetJSON)
}
}
}
}
// UpdateAsset updates an existing asset in the world state with provided parameters.
func (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface,
Contributor string, ContributorId string, ContentHash string, Id string) error {

View file

@ -48,7 +48,6 @@ echo "========= Approving ChainCode ORG2 ==========="
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name basic --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
echo "========= Approving ChainCode ORG1 ==========="
export CORE_PEER_LOCALMSPID="Org1MSP"
@ -68,21 +67,47 @@ peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride o
peer lifecycle chaincode querycommitted --channelID mychannel --name basic --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
echo "========= CC Test of jsonRead Function ==========="
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"JsonReader","Args":["/home/chaincode/schema.json"]}'
echo "========= CC Invoke: Inizialitation ==========="
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"InitLedger","Args":[]}'
#peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"InitLedger","Args":[]}'
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"InitLedger","Args":["/home/chaincode/schema.json", "/home/chaincode/firstJson.json"]}'
echo "========= CC Query: Get all DataSamples ==========="
peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
echo "========= CC Query: Get all Schemas ==========="
peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllSchemas"]}'
echo "========= Check if sample with id = '00000' Exists ==========="
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"AssetExists","Args":["00000"]}'
echo "========= Check creation of a new sample wit id = '00001' ==========="
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"CreateDataSample","Args":["docTypeTest2","00001","TestTitle2","Desc2","Neuroscience","TestDOI","www.ncis.edu","TestManifest","TestFootPrint", "Neuroscience, brain", "None", "None", "None","None","None","None","None", "None"]}'
# peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"CreateDataSample","Args":["docTypeTest2","00001","TestTitle2","Desc2","Neuroscience","TestDOI","www.ncis.edu","TestManifest","TestFootPrint", "Neuroscience, brain", "None", "None", "None","None","None","None","None", "None"]}'
#peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"CreateDataSample","Args":["UCSD-SDSC", "Contributor123", "PhonyHash!@#$$%#@", "00001", ["DOE FER"]]}'
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"CreateDataSample","Args":["UCSD-SDSC", "Contributor123", "PhonyHash!@#$$%#@", "00001", "/home/chaincode/testFileNewSample.json"]}'
#peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile \
echo "========= Check creation of a new Schema ==========="
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"CreateNewSchema","Args":["UCSD-SDSC", "Contributor123", "PhonyHash!@#$$%#@", "00001", "/home/chaincode/NewSchema.json"]}'
echo "========= Check creation of a new sample wit id = '00002' based on New Schema ==========="
# peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"CreateDataSample","Args":["docTypeTest2","00001","TestTitle2","Desc2","Neuroscience","TestDOI","www.ncis.edu","TestManifest","TestFootPrint", "Neuroscience, brain", "None", "None", "None","None","None","None","None", "None"]}'
#peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"CreateDataSample","Args":["UCSD-SDSC", "Contributor123", "PhonyHash!@#$$%#@", "00001", ["DOE FER"]]}'
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"CreateDataSample","Args":["UCSD-SDSC", "Contributor123", "PhonyHash!@#$$%#@", "00002", "/home/chaincode/testFileNewSample.json"]}'
echo "========= The code below will upgrade an existing ChainCode ==========="
@ -108,7 +133,7 @@ var2=$(echo $var | tail -n 1 | cut -f 3 -d ' ')
export NEW_CC_PACKAGE_ID=$(echo $var2 | sed 's/.$//')
echo $NEW_CC_PACKAGE_ID
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name basic --version 3.0 --package-id $NEW_CC_PACKAGE_ID --sequence 3 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name basic --version 3.0 --package-id $NEW_CC_PACKAGE_ID --sequence 2 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
@ -117,11 +142,11 @@ export CORE_PEER_ADDRESS=localhost:9051
peer lifecycle chaincode install basic_3.tar.gz
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name basic --version 3.0 --package-id $NEW_CC_PACKAGE_ID --sequence 3 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name basic --version 3.0 --package-id $NEW_CC_PACKAGE_ID --sequence 2 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 3.0 --sequence 3 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --output json
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 3.0 --sequence 2 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --output json
peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name basic --version 3.0 --sequence 3 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name basic --version 3.0 --sequence 2 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
echo "========= Update of Sample 00001 ==========="