mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-21 17:15:10 +00:00
Merge "[FAB-15051] delStandard() function for high-throughput"
This commit is contained in:
commit
ccf765ad56
3 changed files with 22 additions and 2 deletions
|
|
@ -170,7 +170,7 @@ row in the ledger 1000 times, with a value incrementing by one each time (i.e. t
|
||||||
expectation would be that the final value of the row is 999. However, the final value changes each time this script is run and you'll find
|
expectation would be that the final value of the row is 999. However, the final value changes each time this script is run and you'll find
|
||||||
errors in the peer and orderer logs.
|
errors in the peer and orderer logs.
|
||||||
|
|
||||||
There is one other script, `get-traditional.sh`, which simply gets the value of a row in the traditional way, with no deltas.
|
There are two other scripts, `get-traditional.sh`, which simply gets the value of a row in the traditional way, with no deltas, and `del-traditional.sh` will delete an asset in the traditional way.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
`./many-updates.sh testvar 100 +` --> final value from `./get-invoke.sh testvar` should be 100000
|
`./many-updates.sh testvar 100 +` --> final value from `./get-invoke.sh testvar` should be 100000
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,8 @@ func (s *SmartContract) Invoke(APIstub shim.ChaincodeStubInterface) sc.Response
|
||||||
return s.putStandard(APIstub, args)
|
return s.putStandard(APIstub, args)
|
||||||
} else if function == "getstandard" {
|
} else if function == "getstandard" {
|
||||||
return s.getStandard(APIstub, args)
|
return s.getStandard(APIstub, args)
|
||||||
|
} else if function == "delstandard" {
|
||||||
|
return s.delStandard(APIstub, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
return shim.Error("Invalid Smart Contract function name.")
|
return shim.Error("Invalid Smart Contract function name.")
|
||||||
|
|
@ -360,7 +362,7 @@ func (s *SmartContract) putStandard(APIstub shim.ChaincodeStubInterface, args []
|
||||||
|
|
||||||
_, getErr := APIstub.GetState(name)
|
_, getErr := APIstub.GetState(name)
|
||||||
if getErr != nil {
|
if getErr != nil {
|
||||||
return shim.Error(fmt.Sprintf("Failed to retrieve the statr of %s: %s", name, getErr.Error()))
|
return shim.Error(fmt.Sprintf("Failed to retrieve the state of %s: %s", name, getErr.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
putErr := APIstub.PutState(name, []byte(valStr))
|
putErr := APIstub.PutState(name, []byte(valStr))
|
||||||
|
|
@ -381,3 +383,14 @@ func (s *SmartContract) getStandard(APIstub shim.ChaincodeStubInterface, args []
|
||||||
|
|
||||||
return shim.Success(val)
|
return shim.Success(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SmartContract) delStandard(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
getErr := APIstub.DelState(name)
|
||||||
|
if getErr != nil {
|
||||||
|
return shim.Error(fmt.Sprintf("Failed to delete state: %s", getErr.Error()))
|
||||||
|
}
|
||||||
|
|
||||||
|
return shim.Success(nil)
|
||||||
|
}
|
||||||
|
|
|
||||||
7
high-throughput/scripts/del-traditional.sh
Normal file
7
high-throughput/scripts/del-traditional.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#
|
||||||
|
# Copyright IBM Corp All Rights Reserved
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n $CC_NAME -c '{"Args":["delstandard","'$1'"]}'
|
||||||
Loading…
Reference in a new issue