mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 07:25:10 +00:00
Rename GetAsset to ReadAsset
Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
This commit is contained in:
parent
f1775d7fdc
commit
7b2dcbf2ed
3 changed files with 11 additions and 11 deletions
|
|
@ -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:
|
||||
```
|
||||
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:
|
||||
```
|
||||
|
|
@ -207,7 +207,7 @@ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.exa
|
|||
```
|
||||
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:
|
||||
```
|
||||
|
|
@ -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:
|
||||
```
|
||||
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:
|
||||
```
|
||||
|
|
@ -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.
|
||||
|
||||
```
|
||||
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:
|
||||
|
|
@ -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:
|
||||
```
|
||||
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
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ func (s *SmartContract) ChangePublicDescription(ctx contractapi.TransactionConte
|
|||
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 {
|
||||
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
|
||||
func (s *SmartContract) AgreeToSell(ctx contractapi.TransactionContextInterface, assetID string) error {
|
||||
// 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 {
|
||||
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")
|
||||
}
|
||||
|
||||
asset, err := s.GetAsset(ctx, assetID)
|
||||
asset, err := s.ReadAsset(ctx, assetID)
|
||||
if err != nil {
|
||||
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())
|
||||
}
|
||||
|
||||
asset, err := s.GetAsset(ctx, assetID)
|
||||
asset, err := s.ReadAsset(ctx, assetID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get asset: %s", err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ type Agreement struct {
|
|||
TradeID string `json:"trade_id"`
|
||||
}
|
||||
|
||||
// GetAsset returns the public asset data
|
||||
func (s *SmartContract) GetAsset(ctx contractapi.TransactionContextInterface, assetID string) (*Asset, error) {
|
||||
// ReadAsset returns the public asset data
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue