Rename GetAsset to ReadAsset

Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
This commit is contained in:
Tiffany Harris 2020-06-10 08:40:34 -04:00 committed by denyeart
parent f1775d7fdc
commit 7b2dcbf2ed
3 changed files with 11 additions and 11 deletions

View file

@ -195,7 +195,7 @@ When successful, the command will return the following result:
We can also query the ledger to see the public ownership record: We can also query the ledger to see the public ownership record:
``` ```
peer chaincode query -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 assets_transfer -c '{"function":"GetAsset","Args":["asset1"]}' peer chaincode query -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 assets_transfer -c '{"function":"ReadAsset","Args":["asset1"]}'
``` ```
The command will return the record that the asset1 is owned by Org1: The command will return the record that the asset1 is owned by Org1:
``` ```
@ -207,7 +207,7 @@ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.exa
``` ```
Query the ledger again to see the updated description: Query the ledger again to see the updated description:
``` ```
peer chaincode query -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 assets_transfer -c '{"function":"GetAsset","Args":["asset1"]}' peer chaincode query -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 assets_transfer -c '{"function":"ReadAsset","Args":["asset1"]}'
``` ```
We can now see that the asset is for sale: We can now see that the asset is for sale:
``` ```
@ -221,7 +221,7 @@ We can now see that the asset is for sale:
If we operate from the Org2 terminal, we can use the smart contract query the public asset data: If we operate from the Org2 terminal, we can use the smart contract query the public asset data:
``` ```
peer chaincode query -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 assets_transfer -c '{"function":"GetAsset","Args":["asset1"]}' peer chaincode query -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 assets_transfer -c '{"function":"ReadAsset","Args":["asset1"]}'
``` ```
From this query, Org2 learns that asset1 is for sale: From this query, Org2 learns that asset1 is for sale:
``` ```
@ -305,7 +305,7 @@ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.exa
You can query the asset ownership record to verify that the transfer was successful. You can query the asset ownership record to verify that the transfer was successful.
``` ```
peer chaincode query -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 assets_transfer -c '{"function":"GetAsset","Args":["asset1"]}' peer chaincode query -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 assets_transfer -c '{"function":"ReadAsset","Args":["asset1"]}'
``` ```
The record now lists Org2 as the asset owner: The record now lists Org2 as the asset owner:
@ -330,7 +330,7 @@ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.exa
Query the ledger to verify that the asset is no longer for sale: Query the ledger to verify that the asset is no longer for sale:
``` ```
peer chaincode query -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 assets_transfer -c '{"function":"GetAsset","Args":["asset1"]}' peer chaincode query -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 assets_transfer -c '{"function":"ReadAsset","Args":["asset1"]}'
``` ```
## Clean up ## Clean up

View file

@ -120,7 +120,7 @@ func (s *SmartContract) ChangePublicDescription(ctx contractapi.TransactionConte
return fmt.Errorf("failed to get verified OrgID: %s", err.Error()) return fmt.Errorf("failed to get verified OrgID: %s", err.Error())
} }
asset, err := s.GetAsset(ctx, assetID) asset, err := s.ReadAsset(ctx, assetID)
if err != nil { if err != nil {
return fmt.Errorf("failed to get asset: %s", err.Error()) return fmt.Errorf("failed to get asset: %s", err.Error())
} }
@ -143,7 +143,7 @@ func (s *SmartContract) ChangePublicDescription(ctx contractapi.TransactionConte
// AgreeToSell adds seller's asking price to seller's implicit private data collection // AgreeToSell adds seller's asking price to seller's implicit private data collection
func (s *SmartContract) AgreeToSell(ctx contractapi.TransactionContextInterface, assetID string) error { func (s *SmartContract) AgreeToSell(ctx contractapi.TransactionContextInterface, assetID string) error {
// Query asset and verify that this clientOrgId actually owns the asset. // Query asset and verify that this clientOrgId actually owns the asset.
asset, err := s.GetAsset(ctx, assetID) asset, err := s.ReadAsset(ctx, assetID)
if err != nil { if err != nil {
return err return err
} }
@ -219,7 +219,7 @@ func (s *SmartContract) VerifyAssetProperties(ctx contractapi.TransactionContext
return false, fmt.Errorf("asset_properties key not found in the transient map") return false, fmt.Errorf("asset_properties key not found in the transient map")
} }
asset, err := s.GetAsset(ctx, assetID) asset, err := s.ReadAsset(ctx, assetID)
if err != nil { if err != nil {
return false, fmt.Errorf("failed to get asset: %s", err.Error()) return false, fmt.Errorf("failed to get asset: %s", err.Error())
} }
@ -278,7 +278,7 @@ func (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterfac
return fmt.Errorf("failed to unmarshal price JSON: %s", err.Error()) return fmt.Errorf("failed to unmarshal price JSON: %s", err.Error())
} }
asset, err := s.GetAsset(ctx, assetID) asset, err := s.ReadAsset(ctx, assetID)
if err != nil { if err != nil {
return fmt.Errorf("failed to get asset: %s", err.Error()) return fmt.Errorf("failed to get asset: %s", err.Error())
} }

View file

@ -40,8 +40,8 @@ type Agreement struct {
TradeID string `json:"trade_id"` TradeID string `json:"trade_id"`
} }
// GetAsset returns the public asset data // ReadAsset returns the public asset data
func (s *SmartContract) GetAsset(ctx contractapi.TransactionContextInterface, assetID string) (*Asset, error) { func (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, assetID string) (*Asset, error) {
// since only public data is accessed in this function, no access control is required // since only public data is accessed in this function, no access control is required