-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
- Loading branch information
1 parent
9d7f161
commit 5edd740
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ecc | ||
ecc-bundle | ||
enclave.json | ||
private.pem | ||
public.pem | ||
mrenclave | ||
details.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright 2019 Intel Corporation | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
TOP = ../../.. | ||
include $(TOP)/ecc_go/build.mk | ||
|
||
CC_NAME ?= fpc-echo-go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package chaincode | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hyperledger/fabric-chaincode-go/shim" | ||
pb "github.com/hyperledger/fabric-protos-go/peer" | ||
) | ||
|
||
type Echo struct { | ||
} | ||
|
||
func (t *Echo) Init(stub shim.ChaincodeStubInterface) pb.Response { | ||
return shim.Success(nil) | ||
} | ||
|
||
func (t *Echo) Invoke(stub shim.ChaincodeStubInterface) pb.Response { | ||
functionName, params := stub.GetFunctionAndParameters() | ||
fmt.Println("EchoCC: Function:", functionName, "Params:", params) | ||
return shim.Success([]byte(functionName)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
Copyright 2020 Intel Corporation | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/hyperledger/fabric-chaincode-go/shim" | ||
fpc "github.com/hyperledger/fabric-private-chaincode/ecc_go/chaincode" | ||
"github.com/hyperledger/fabric-private-chaincode/samples/chaincode/echo-go/chaincode" | ||
) | ||
|
||
func main() { | ||
|
||
// we can control logging via FABRIC_LOGGING_SPEC, the default is FABRIC_LOGGING_SPEC=INFO | ||
// For more fine-grained logging we could also use different log level for loggers. | ||
// For example: FABRIC_LOGGING_SPEC=ecc=DEBUG:ecc_enclave=ERROR | ||
|
||
ccid := os.Getenv("CHAINCODE_PKG_ID") | ||
addr := os.Getenv("CHAINCODE_SERVER_ADDRESS") | ||
|
||
// create private chaincode | ||
privateChaincode := fpc.NewPrivateChaincode(&chaincode.Echo{}) | ||
|
||
// start chaincode as a service | ||
server := &shim.ChaincodeServer{ | ||
CCID: ccid, | ||
Address: addr, | ||
CC: privateChaincode, | ||
TLSProps: shim.TLSProperties{ | ||
Disabled: true, // just for testing good enough | ||
}, | ||
} | ||
|
||
if err := server.Start(); err != nil { | ||
panic(err) | ||
} | ||
} |