-
Notifications
You must be signed in to change notification settings - Fork 18
Feature/Edit CCAPI to support FPC #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
osamamagdy
wants to merge
14
commits into
hyperledger-labs:main
from
osamamagdy:feat/integrate-with-fpc
+1,931
−143
Closed
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0d66481
feat: import fpc code
osamamagdy 75c060f
remove unnecessary tests
osamamagdy 4a19850
feat: change variables naming to suit fpc
osamamagdy 9ee6537
feat: edit ccapi volume mount
osamamagdy 2a7cf1f
feat: integrate with fpc
osamamagdy e7b7e50
feat: ccapi example is working
osamamagdy a3a9ddf
revert changes for originial docker compose
osamamagdy 2f0f002
switch in case of fpc mode
osamamagdy bfd5f23
handle chaincode name and channel name dynamically
osamamagdy a28ba47
remove init enclave
osamamagdy 79c0493
rename FPC_MODE env
osamamagdy 57ad005
fix: revert changes in the chaincode
osamamagdy eae6380
fix: edit folder mapping and bump cc-tools version
osamamagdy 8f21aaf
fix: revert all unrelevant changes
osamamagdy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,24 @@ | ||
| /* | ||
| Copyright IBM Corp. All Rights Reserved. | ||
|
|
||
| SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package chaincode | ||
|
|
||
| import ( | ||
| "net/http" | ||
|
|
||
| "github.com/hyperledger-labs/ccapi/common" | ||
| ) | ||
|
|
||
| func InvokeFpc(channelName string, chaincodeName string, txname string, args [][]byte) ([]byte, int, error) { | ||
| stringArgs := make([]string, len(args)) | ||
| for i, b := range args { | ||
| stringArgs[i] = string(b) | ||
| } | ||
|
|
||
| client := common.NewFpcClient(channelName, chaincodeName) | ||
| res := client.Invoke(txname, stringArgs[0:]...) | ||
| return []byte(res), http.StatusOK, nil | ||
| } |
This file contains hidden or 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,24 @@ | ||
| /* | ||
| Copyright IBM Corp. All Rights Reserved. | ||
|
|
||
| SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package chaincode | ||
|
|
||
| import ( | ||
| "net/http" | ||
|
|
||
| "github.com/hyperledger-labs/ccapi/common" | ||
| ) | ||
|
|
||
| func InvokeFpcDefault(txname string, args [][]byte) ([]byte, int, error) { | ||
| stringArgs := make([]string, len(args)) | ||
| for i, b := range args { | ||
| stringArgs[i] = string(b) | ||
| } | ||
|
|
||
| client := common.NewDefaultFpcClient() | ||
| res := client.Invoke(txname, stringArgs[0:]...) | ||
| return []byte(res), http.StatusOK, nil | ||
| } |
This file contains hidden or 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,24 @@ | ||
| /* | ||
| Copyright IBM Corp. All Rights Reserved. | ||
|
|
||
| SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package chaincode | ||
|
|
||
| import ( | ||
| "net/http" | ||
|
|
||
| "github.com/hyperledger-labs/ccapi/common" | ||
| ) | ||
|
|
||
| func QueryFpc(chaincodeName string, channelName string, txName string, args [][]byte) ([]byte, int, error) { | ||
| stringArgs := make([]string, len(args)) | ||
| for i, b := range args { | ||
| stringArgs[i] = string(b) | ||
| } | ||
|
|
||
| client := common.NewFpcClient(chaincodeName, channelName) | ||
| res := client.Query(txName, stringArgs[0:]...) | ||
| return []byte(res), http.StatusOK, nil | ||
| } |
This file contains hidden or 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,24 @@ | ||
| /* | ||
| Copyright IBM Corp. All Rights Reserved. | ||
|
|
||
| SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package chaincode | ||
|
|
||
| import ( | ||
| "net/http" | ||
|
|
||
| "github.com/hyperledger-labs/ccapi/common" | ||
| ) | ||
|
|
||
| func QueryFpcDefault(txName string, args [][]byte) ([]byte, int, error) { | ||
| stringArgs := make([]string, len(args)) | ||
| for i, b := range args { | ||
| stringArgs[i] = string(b) | ||
| } | ||
|
|
||
| client := common.NewDefaultFpcClient() | ||
| res := client.Query(txName, stringArgs[0:]...) | ||
| return []byte(res), http.StatusOK, nil | ||
| } |
This file contains hidden or 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,68 @@ | ||
| /* | ||
| Copyright IBM Corp. All Rights Reserved. | ||
|
|
||
| SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package common | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
| "strconv" | ||
|
|
||
| pkgFpc "github.com/hyperledger-labs/ccapi/fpcUtils" | ||
| ) | ||
|
|
||
| var ( | ||
| defaultFpcConfig *pkgFpc.Config | ||
| ) | ||
|
|
||
| func InitFpcConfig() { | ||
|
|
||
| getStrEnv := func(key string) string { | ||
| val := os.Getenv(key) | ||
| if val == "" { | ||
| panic(fmt.Sprintf("%s not set", key)) | ||
| } | ||
| return val | ||
| } | ||
|
|
||
| getBoolEnv := func(key string) bool { | ||
| val := getStrEnv(key) | ||
| ret, err := strconv.ParseBool(val) | ||
| if err != nil { | ||
| if val == "" { | ||
| panic(fmt.Sprintf("invalid bool value for %s", key)) | ||
| } | ||
| } | ||
| return ret | ||
| } | ||
|
|
||
| defaultFpcConfig = &pkgFpc.Config{ | ||
| CorePeerAddress: getStrEnv("CORE_PEER_ADDRESS"), | ||
| CorePeerId: getStrEnv("CORE_PEER_ID"), | ||
| CorePeerLocalMSPID: getStrEnv("CORE_PEER_LOCALMSPID"), | ||
| CorePeerMSPConfigPath: getStrEnv("CORE_PEER_MSPCONFIGPATH"), | ||
| CorePeerTLSCertFile: getStrEnv("CORE_PEER_TLS_CERT_FILE"), | ||
| CorePeerTLSEnabled: getBoolEnv("CORE_PEER_TLS_ENABLED"), | ||
| CorePeerTLSKeyFile: getStrEnv("CORE_PEER_TLS_KEY_FILE"), | ||
| CorePeerTLSRootCertFile: getStrEnv("CORE_PEER_TLS_ROOTCERT_FILE"), | ||
| OrdererCA: getStrEnv("ORDERER_CA"), | ||
| ChaincodeId: getStrEnv("CCNAME"), | ||
| ChannelId: getStrEnv("CHANNEL"), | ||
| GatewayConfigPath: getStrEnv("GATEWAY_CONFIG"), | ||
| } | ||
|
|
||
| } | ||
|
|
||
| func NewDefaultFpcClient() *pkgFpc.Client { | ||
| return pkgFpc.NewClient(defaultFpcConfig) | ||
| } | ||
|
|
||
| func NewFpcClient(channelName string, chaincodeName string) *pkgFpc.Client { | ||
| fpcConfig := defaultFpcConfig | ||
| fpcConfig.ChannelId = channelName | ||
| fpcConfig.ChaincodeId = chaincodeName | ||
| return pkgFpc.NewClient(fpcConfig) | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,83 @@ | ||
| version: "2" | ||
| services: | ||
| ccapi.org1.example.com: | ||
| build: | ||
| dockerfile: Dockerfile | ||
| context: . | ||
| ports: | ||
| - 80:80 | ||
| volumes: | ||
| - ./:/rest-server | ||
| - /src/github.com/hyperledger/fabric-private-chaincode/samples/deployment/test-network/fabric-samples/test-network/organizations:/fabric/organizations | ||
| - /src/github.com/hyperledger/fabric-private-chaincode/samples/deployment/test-network/fabric-samples/test-network/organizations/:/project/src/github.com/hyperledger/fabric-private-chaincode/samples/deployment/test-network/fabric-samples/test-network/organizations/ | ||
| logging: | ||
| options: | ||
| max-size: 50m | ||
| environment: | ||
| - SDK_PATH=./config/configsdk-org1.yaml | ||
| - USER=Admin | ||
| - ORG=org1 | ||
| - DOMAIN=example.com | ||
| - CHANNEL=mychannel | ||
| - CCNAME=cc-tools-demo | ||
| - FABRIC_GATEWAY_ENDPOINT=peer0.org1.example.com:7051 | ||
| - FABRIC_GATEWAY_NAME=peer0.org1.example.com | ||
| - GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn | ||
| - FPC_ENABLED=true | ||
| - SGX_MODE=SIM | ||
| - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 | ||
| - CORE_PEER_ID=peer0.org1.example.com | ||
| - CORE_PEER_LOCALMSPID=Org1MSP | ||
| - CORE_PEER_MSPCONFIGPATH=/fabric/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp | ||
| - CORE_PEER_TLS_CERT_FILE=/fabric/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt | ||
| - CORE_PEER_TLS_ENABLED="true" | ||
| - CORE_PEER_TLS_KEY_FILE=/fabric/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key | ||
| - CORE_PEER_TLS_ROOTCERT_FILE=/fabric/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt | ||
| - ORDERER_CA=/fabric/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem | ||
| - GATEWAY_CONFIG=/fabric/organizations/peerOrganizations/org1.example.com/external-connection-org1.yaml | ||
| working_dir: /rest-server | ||
| container_name: ccapi.org1.example.com | ||
| networks: | ||
| - fabric_test | ||
| ccapi.org2.example.com: | ||
| build: | ||
| dockerfile: Dockerfile | ||
| context: . | ||
| ports: | ||
| - 980:80 | ||
| volumes: | ||
| - ./:/rest-server | ||
| - /src/github.com/hyperledger/fabric-private-chaincode/samples/deployment/test-network/fabric-samples/test-network/organizations:/fabric/organizations | ||
| - /src/github.com/hyperledger/fabric-private-chaincode/samples/deployment/test-network/fabric-samples/test-network/organizations/:/project/src/github.com/hyperledger/fabric-private-chaincode/samples/deployment/test-network/fabric-samples/test-network/organizations/ | ||
| logging: | ||
| options: | ||
| max-size: 50m | ||
| environment: | ||
| - SDK_PATH=./config/configsdk-org2.yaml | ||
| - USER=Admin | ||
| - ORG=org2 | ||
| - DOMAIN=example.com | ||
| - CHANNEL=mychannel | ||
| - CCNAME=cc-tools-demo | ||
| - FABRIC_GATEWAY_ENDPOINT=peer0.org2.example.com:7051 | ||
| - FABRIC_GATEWAY_NAME=peer0.org2.example.com | ||
| - GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn | ||
| - FPC_MODE=true | ||
| - SGX_MODE=SIM | ||
| - CORE_PEER_ADDRESS=peer0.org2.example.com:7051 | ||
| - CORE_PEER_ID=peer0.org2.example.com | ||
| - CORE_PEER_LOCALMSPID=Org2MSP | ||
| - CORE_PEER_MSPCONFIGPATH=/fabric/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp | ||
| - CORE_PEER_TLS_CERT_FILE=/fabric/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.crt | ||
| - CORE_PEER_TLS_ENABLED="true" | ||
| - CORE_PEER_TLS_KEY_FILE=/fabric/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.key | ||
| - CORE_PEER_TLS_ROOTCERT_FILE=/fabric/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt | ||
| - ORDERER_CA=/fabric/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem | ||
| - GATEWAY_CONFIG=/fabric/organizations/peerOrganizations/org2.example.com/external-connection-org2.yaml | ||
| working_dir: /rest-server | ||
| container_name: ccapi.org2.example.com | ||
| networks: | ||
| - fabric_test | ||
| networks: | ||
| fabric_test: | ||
| external: true |
This file contains hidden or 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,23 @@ | ||
| /* | ||
| Copyright IBM Corp. All Rights Reserved. | ||
|
|
||
| SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package fpcUtils | ||
|
|
||
| type Config struct { | ||
| CorePeerAddress string | ||
| CorePeerId string | ||
| CorePeerLocalMSPID string | ||
| CorePeerMSPConfigPath string | ||
| CorePeerTLSCertFile string | ||
| CorePeerTLSEnabled bool | ||
| CorePeerTLSKeyFile string | ||
| CorePeerTLSRootCertFile string | ||
| OrdererCA string | ||
| FpcPath string | ||
| ChaincodeId string | ||
| ChannelId string | ||
| GatewayConfigPath string | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.