MCPcopy
hub / github.com/hyperledger/fabric / Invoke

Method Invoke

integration/chaincode/multi/chaincode.go:27–65  ·  view source on GitHub ↗

Invoke - Our entry point for Invocations ========================================

(stub shim.ChaincodeStubInterface)

Source from the content-addressed store, hash-verified

25// Invoke - Our entry point for Invocations
26// ========================================
27func (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)"
68func (t *Operations) put(stub shim.ChaincodeStubInterface, numberCallsPut string) *pb.Response {

Callers

nothing calls this directly

Calls 7

putMethod · 0.95
getKeyMethod · 0.95
putPrivateKeyMethod · 0.95
getMultipleMethod · 0.95
ErrorMethod · 0.65
StartWriteBatchMethod · 0.45

Tested by

no test coverage detected