mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
Update February 28th
This commit is contained in:
parent
67e44ce293
commit
7f9350659e
2 changed files with 27 additions and 7 deletions
|
|
@ -39,8 +39,8 @@ type Data struct {
|
|||
ProjectName string `json:"ProjectName"`
|
||||
ContentHash string `json:"ContentHash"`
|
||||
Comment string `json:"Comment"`
|
||||
APIUserID string `json:"APIUserID"`
|
||||
Date string `json:"Date"`
|
||||
Submitter string `json:Submitter`
|
||||
JsonContent map[string]interface{}
|
||||
}
|
||||
|
||||
|
|
@ -378,7 +378,7 @@ 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,
|
||||
OrgName string, ProjectName string, Comment string, Date string, Submitter string, JsonFileContent string, SchemaID string) error {
|
||||
OrgName string, ProjectName string, Comment string, Date string, APIUserID string, JsonFileContent string, SchemaID string) error {
|
||||
|
||||
SchemaExists, err := s.SchemaExists(ctx, SchemaID)
|
||||
|
||||
|
|
@ -417,14 +417,13 @@ func (s *SmartContract) CreateDataSample(ctx contractapi.TransactionContextInter
|
|||
ContentHash: ContentHash,
|
||||
Comment: Comment,
|
||||
Date: Date,
|
||||
Submitter: Submitter,
|
||||
APIUserID: APIUserID,
|
||||
JsonContent: jsonFileContent,
|
||||
}
|
||||
|
||||
assetJSON, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
return ctx.GetStub().PutState(ContentHash, assetJSON)
|
||||
}
|
||||
|
|
@ -920,6 +919,12 @@ func (s *SmartContract) ReadSchemaFromPDC(ctx contractapi.TransactionContextInte
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get MSPID: %v", err)
|
||||
}
|
||||
|
||||
err = verifyClientOrgMatchesPeerOrg(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("CreateSchema cannot be performed: Error %v", err)
|
||||
}
|
||||
|
||||
PDC := "_implicit_org_" + MSP
|
||||
log.Printf("ReadSchemaFromPDC: collection %v, ID %v", PDC, SchemaID)
|
||||
assetJSON, err := ctx.GetStub().GetPrivateData(PDC, SchemaID) //get the asset from chaincode state
|
||||
|
|
|
|||
|
|
@ -226,7 +226,6 @@ echo "========= Setting Up Network with PDC and SmartContract ==========="
|
|||
|
||||
cd /Users/fernando/Projects/OSC-IS/fabric-samples/test-network
|
||||
./network.sh down
|
||||
export PATH=$PATH:/usr/local/go/bin
|
||||
./network.sh up createChannel -ca -s couchdb
|
||||
./network.sh deployCC -ccn private -ccp ../asset-transfer-private-data/chaincode-go/ -ccl go -ccep "OR('Org1MSP.peer','Org2MSP.peer')" -cccg ../asset-transfer-private-data/chaincode-go/collections_config.json
|
||||
|
||||
|
|
@ -275,8 +274,24 @@ peer chaincode query -C mychannel -n private -c '{"function":"ReadSchemaFromPDC"
|
|||
|
||||
echo "========= CC Invoke: Reading all Schemas in PDC ==========="
|
||||
|
||||
peer chaincode query -C mychannel -n private -c '{"function":"GetAllPDCSchemas","Args":[""]}'
|
||||
peer chaincode query -C mychannel -n private -c '{"function":"GetAllPDCSchemas","Args":["1"]}'
|
||||
|
||||
echo "========= CC Invoke: Creation of DataSample ==========="
|
||||
|
||||
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 private --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":["CIA Org", "Project 1", "Comment: Proof of life presence in Mars", "13/13/13", "jhon@email.com", "{ \"number\": 1603, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\"}", ,"Project1.Schema1"]}'
|
||||
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 private --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" -c '{"function":"CreateDataSample","Args":["CIA Org", "Project 1", "Comment: Proof of live in Mars", "13/13/13", "john@email.org", "{ \"number\": 1603, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\"}", "Project1.Schema1"]}'
|
||||
|
||||
|
||||
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 private --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":["CIA Org", "Project 1", "Comment: Proof of live in Mars", "13/13/13", "john@email.org", "{ \"number\": 1603, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\"}"]}'
|
||||
|
||||
|
||||
|
||||
|
||||
peer chaincode query -C mychannel -n private -c '{"Args":["GetAllAssets"]}'
|
||||
|
||||
|
||||
"Comment: Proof of live in Mars"
|
||||
|
||||
peer chaincode query -C mychannel -n private -c '{"function":"ReadAsset","Args":["5c278e2809530799b010946e4686fbcf661b18cd2b0d12fd66ec17e5bea80f0c"]}'
|
||||
|
||||
|
||||
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 private --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":"Hash","Args":["{ \"number\": 1603, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\"}"]}'
|
||||
Loading…
Reference in a new issue