Invoke - Our entry point for Invocations ========================================
(stub shim.ChaincodeStubInterface)
| 25 | // Invoke - Our entry point for Invocations |
| 26 | // ======================================== |
| 27 | func (t *Operations) Invoke(stub shim.ChaincodeStubInterface) *pb.Response { |
| 28 | function, args := stub.GetFunctionAndParameters() |
| 29 | fmt.Println("invoke is running " + function) |
| 30 | |
| 31 | switch function { |
| 32 | case "invoke": |
| 33 | startWB, _ := strconv.ParseBool(args[0]) |
| 34 | if startWB { |
| 35 | stub.StartWriteBatch() |
| 36 | } |
| 37 | if len(args) != 2 { |
| 38 | return shim.Error("Incorrect number of arguments. Expecting 1") |
| 39 | } |
| 40 | return t.put(stub, args[1]) |
| 41 | case "get-key": |
| 42 | if len(args) != 1 { |
| 43 | return shim.Error("Incorrect number of arguments. Expecting 1") |
| 44 | } |
| 45 | return t.getKey(stub, args[0]) |
| 46 | case "put-private-key": |
| 47 | startWB, _ := strconv.ParseBool(args[0]) |
| 48 | if startWB { |
| 49 | stub.StartWriteBatch() |
| 50 | } |
| 51 | if len(args) != 2 { |
| 52 | return shim.Error("Incorrect number of arguments. Expecting 1") |
| 53 | } |
| 54 | return t.putPrivateKey(stub, args[1]) |
| 55 | case "get-multiple-keys": |
| 56 | if len(args) != 1 { |
| 57 | return shim.Error("Incorrect number of arguments. Expecting 1") |
| 58 | } |
| 59 | return t.getMultiple(stub, args[0]) |
| 60 | default: |
| 61 | // error |
| 62 | fmt.Println("invoke did not find func: " + function) |
| 63 | return shim.Error("Received unknown function invocation") |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // put to state keys from "key0" to "key(cntCall-1)" |
| 68 | func (t *Operations) put(stub shim.ChaincodeStubInterface, numberCallsPut string) *pb.Response { |
nothing calls this directly
no test coverage detected