Skip to content

Commit c7028ec

Browse files
committed
feat: change secret-keeper-go makefile
Signed-off-by: chenchanglew <[email protected]>
1 parent e432083 commit c7028ec

File tree

4 files changed

+98
-2
lines changed

4 files changed

+98
-2
lines changed

ecc_go/build.mk

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@ DOCKER_FILE ?= $(FPC_PATH)/ecc_go/Dockerfile
1616
EGO_CONFIG_FILE ?= $(FPC_PATH)/ecc_go/enclave.json
1717
ECC_BINARY ?= ecc
1818
ECC_BUNDLE ?= $(ECC_BINARY)-bundle
19+
MAIN_GO_PATH ?= main.go
1920

2021
build: ecc docker env
2122

2223
ecc: ecc_dependencies
23-
ego-go build $(GOTAGS) -o $(ECC_BINARY) main.go
24+
ego-go build $(GOTAGS) -o $(ECC_BINARY) $(MAIN_GO_PATH)
2425
cp $(EGO_CONFIG_FILE) .
2526
ego sign
2627
ego uniqueid $(ECC_BINARY) > mrenclave
2728
ego bundle $(ECC_BINARY) $(ECC_BUNDLE)
2829

2930
.PHONY: with_go
3031
with_go: ecc_dependencies
31-
$(GO) build $(GOTAGS) -o $(ECC_BUNDLE) main.go
32+
$(GO) build $(GOTAGS) -o $(ECC_BUNDLE) $(MAIN_GO_PATH)
3233
echo "fake_mrenclave" > mrenclave
3334

3435
ecc_dependencies:

samples/chaincode/secret-keeper-go/Makefile

+12
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,15 @@ TOP = ../../..
77
include $(TOP)/ecc_go/build.mk
88

99
CC_NAME ?= fpc-secret-keeper-go
10+
11+
# Define paths for cmd subdirectories
12+
NAIVE_PATH = cmd/naive/main.go
13+
SKVS_PATH = cmd/skvs/main.go
14+
15+
# Target to build naive version
16+
naive:
17+
$(MAKE) build MAIN_GO_PATH=$(NAIVE_PATH)
18+
19+
# Target to build skvs version
20+
skvs:
21+
$(MAKE) build MAIN_GO_PATH=$(SKVS_PATH)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
Copyright 2020 Intel Corporation
4+
5+
SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
package main
9+
10+
import (
11+
"os"
12+
13+
"github.com/hyperledger/fabric-chaincode-go/shim"
14+
"github.com/hyperledger/fabric-contract-api-go/contractapi"
15+
fpc "github.com/hyperledger/fabric-private-chaincode/ecc_go/chaincode"
16+
"github.com/hyperledger/fabric-private-chaincode/samples/chaincode/secret-keeper-go/chaincode"
17+
)
18+
19+
func main() {
20+
21+
ccid := os.Getenv("CHAINCODE_PKG_ID")
22+
addr := os.Getenv("CHAINCODE_SERVER_ADDRESS")
23+
24+
// create chaincode
25+
secretChaincode, _ := contractapi.NewChaincode(&chaincode.SecretKeeper{})
26+
chaincode := fpc.NewPrivateChaincode(secretChaincode)
27+
28+
// start chaincode as a service
29+
server := &shim.ChaincodeServer{
30+
CCID: ccid,
31+
Address: addr,
32+
CC: chaincode,
33+
TLSProps: shim.TLSProperties{
34+
Disabled: true, // just for testing good enough
35+
},
36+
}
37+
38+
if err := server.Start(); err != nil {
39+
panic(err)
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
Copyright 2020 Intel Corporation
4+
5+
SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
package main
9+
10+
import (
11+
"os"
12+
13+
"github.com/hyperledger/fabric-chaincode-go/shim"
14+
"github.com/hyperledger/fabric-contract-api-go/contractapi"
15+
fpc "github.com/hyperledger/fabric-private-chaincode/ecc_go/chaincode"
16+
"github.com/hyperledger/fabric-private-chaincode/samples/chaincode/secret-keeper-go/chaincode"
17+
)
18+
19+
func main() {
20+
21+
ccid := os.Getenv("CHAINCODE_PKG_ID")
22+
addr := os.Getenv("CHAINCODE_SERVER_ADDRESS")
23+
24+
// create chaincode
25+
secretChaincode, _ := contractapi.NewChaincode(&chaincode.SecretKeeper{})
26+
// chaincode := fpc.NewPrivateChaincode(secretChaincode)
27+
skvsChaincode := fpc.NewSkvsChaincode(secretChaincode)
28+
29+
// start chaincode as a service
30+
server := &shim.ChaincodeServer{
31+
CCID: ccid,
32+
Address: addr,
33+
CC: skvsChaincode,
34+
TLSProps: shim.TLSProperties{
35+
Disabled: true, // just for testing good enough
36+
},
37+
}
38+
39+
if err := server.Start(); err != nil {
40+
panic(err)
41+
}
42+
}

0 commit comments

Comments
 (0)