File tree Expand file tree Collapse file tree 6 files changed +615
-0
lines changed
integration/e2e/lifecycle Expand file tree Collapse file tree 6 files changed +615
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ Copyright IBM Corp. All Rights Reserved.
3
+
4
+ SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ package callee
8
+
9
+ import (
10
+ "github.com/hyperledger/fabric/core/chaincode/shim"
11
+ pb "github.com/hyperledger/fabric/protos/peer"
12
+ )
13
+
14
+ // CC example simple Chaincode implementation
15
+ type CC struct {
16
+ }
17
+
18
+ func (t * CC ) Init (stub shim.ChaincodeStubInterface ) pb.Response {
19
+ err := stub .PutState ("foo" , []byte ("foo" ))
20
+ if err != nil {
21
+ return shim .Error (err .Error ())
22
+ }
23
+
24
+ return shim .Success (nil )
25
+ }
26
+
27
+ func (t * CC ) Invoke (stub shim.ChaincodeStubInterface ) pb.Response {
28
+ fn , _ := stub .GetFunctionAndParameters ()
29
+ switch fn {
30
+ case "INVOKE" :
31
+ err := stub .PutState ("foo" , []byte ("bar" ))
32
+ if err != nil {
33
+ return shim .Error (err .Error ())
34
+ }
35
+
36
+ return shim .Success (nil )
37
+ case "QUERY" :
38
+ val , err := stub .GetState ("foo" )
39
+ if err != nil {
40
+ return shim .Error (err .Error ())
41
+ }
42
+
43
+ return shim .Success (val )
44
+ default :
45
+ return shim .Error ("unknown function" )
46
+ }
47
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ Copyright IBM Corp. All Rights Reserved.
3
+
4
+ SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ package main
8
+
9
+ import (
10
+ "fmt"
11
+ "os"
12
+
13
+ "github.com/hyperledger/fabric/core/chaincode/shim"
14
+ "github.com/hyperledger/fabric/integration/e2e/lifecycle/chaincode/callee"
15
+ )
16
+
17
+ func main () {
18
+ err := shim .Start (& callee.CC {})
19
+ if err != nil {
20
+ fmt .Fprintf (os .Stderr , "Exiting callee chaincode: %s" , err )
21
+ os .Exit (2 )
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ Copyright IBM Corp. All Rights Reserved.
3
+
4
+ SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ package caller
8
+
9
+ import (
10
+ "github.com/hyperledger/fabric/core/chaincode/shim"
11
+ pb "github.com/hyperledger/fabric/protos/peer"
12
+ )
13
+
14
+ // CC example simple Chaincode implementation
15
+ type CC struct {
16
+ }
17
+
18
+ func (t * CC ) Init (stub shim.ChaincodeStubInterface ) pb.Response {
19
+ err := stub .PutState ("foo" , []byte ("foo" ))
20
+ if err != nil {
21
+ return shim .Error (err .Error ())
22
+ }
23
+
24
+ return shim .Success (nil )
25
+ }
26
+
27
+ func (t * CC ) Invoke (stub shim.ChaincodeStubInterface ) pb.Response {
28
+ fn , args := stub .GetFunctionAndParameters ()
29
+ switch fn {
30
+ case "INVOKE" :
31
+ err := stub .PutState ("foo" , []byte ("bar" ))
32
+ if err != nil {
33
+ return shim .Error (err .Error ())
34
+ }
35
+
36
+ return stub .InvokeChaincode (string (args [0 ]), [][]byte {[]byte ("INVOKE" )}, "" )
37
+ case "QUERY" :
38
+ val , err := stub .GetState ("foo" )
39
+ if err != nil {
40
+ return shim .Error (err .Error ())
41
+ }
42
+
43
+ return shim .Success (val )
44
+ default :
45
+ return shim .Error ("unknown function" )
46
+ }
47
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ Copyright IBM Corp. All Rights Reserved.
3
+
4
+ SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ package main
8
+
9
+ import (
10
+ "fmt"
11
+ "os"
12
+
13
+ "github.com/hyperledger/fabric/core/chaincode/shim"
14
+ "github.com/hyperledger/fabric/integration/e2e/lifecycle/chaincode/caller"
15
+ )
16
+
17
+ func main () {
18
+ err := shim .Start (& caller.CC {})
19
+ if err != nil {
20
+ fmt .Fprintf (os .Stderr , "Exiting caller chaincode: %s" , err )
21
+ os .Exit (2 )
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments