Skip to content

Commit 9935845

Browse files
committed
minor edit and add README
1 parent 1b339e0 commit 9935845

File tree

9 files changed

+36
-205
lines changed

9 files changed

+36
-205
lines changed

ecc_go/chaincode/enclave_go/tle_stub_Interface.go renamed to ecc_go/chaincode/enclave_go/tle_stub.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"bytes"
1111
"context"
1212
"crypto/sha256"
13-
"fmt"
1413
"log"
1514

1615
"google.golang.org/grpc"
@@ -29,19 +28,19 @@ type TleStubInterface struct {
2928
}
3029

3130
func NewTleStubInterface(stub shim.ChaincodeStubInterface, input *pb.ChaincodeInput, rwset *readWriteSet, sep StateEncryptionFunctions) shim.ChaincodeStubInterface {
32-
logger.Warning("==== Get New TLE Interface =====")
31+
logger.Debugf("==== Get New TLE Interface =====")
3332
fpcStub := NewFpcStubInterface(stub, input, rwset, sep)
34-
tleStub := TleStubInterface{fpcStub.(*FpcStubInterface), []byte{}, "host.docker.internal:50051"}
33+
// TODO: get address somewhere else.
34+
tleEnclaveAddr := "host.docker.internal:50051"
35+
tleStub := TleStubInterface{fpcStub.(*FpcStubInterface), []byte{}, tleEnclaveAddr}
3536
err := tleStub.InitTleStub()
3637
if err != nil {
37-
logger.Warningf("Error!! Initializing SKVS failed")
38+
logger.Warningf("Error!! Initializing TLE failed")
3839
}
3940
return &tleStub
4041
}
4142

4243
func (s *TleStubInterface) InitTleStub() error {
43-
logger.Warningf(" === Initializing Tle Stub === ")
44-
4544
// TODO: establish secure connection to TLE
4645
conn, err := grpc.Dial(s.Address, grpc.WithInsecure())
4746
if err != nil {
@@ -56,7 +55,7 @@ func (s *TleStubInterface) InitTleStub() error {
5655
return err
5756
}
5857
s.LastCommitHash = response.GetLastCommitHash()
59-
logger.Warningf("tle Stub Init finish, lastCommitHash: %s", s.LastCommitHash)
58+
logger.Debugf("tle Stub Init finish, lastCommitHash: %s", s.LastCommitHash)
6059
return nil
6160
}
6261

@@ -71,7 +70,6 @@ func (s *TleStubInterface) ValidateMeta(metadata []byte, encValue []byte) error
7170
}
7271

7372
func (s *TleStubInterface) GetMeta(key string) ([]byte, error) {
74-
logger.Warningf("Calling Get Meta from TLE, key: %s", key)
7573
// Q: How to get the namespace? or we dont need namespace?
7674
// TODO: establish secure connection to TLE
7775
conn, err := grpc.Dial(s.Address, grpc.WithInsecure())
@@ -95,7 +93,6 @@ func (s *TleStubInterface) GetMeta(key string) ([]byte, error) {
9593
// Process the response
9694
data := response.GetData()
9795
lastCommitHash := response.GetLastCommitHash()
98-
fmt.Printf("Received data: %s, lastCommitHash: %s\n", string(data), string(lastCommitHash))
9996

10097
if bytes.Equal(s.LastCommitHash, lastCommitHash) {
10198
return data, nil
@@ -104,8 +101,6 @@ func (s *TleStubInterface) GetMeta(key string) ([]byte, error) {
104101
}
105102

106103
func (s *TleStubInterface) GetState(key string) ([]byte, error) {
107-
logger.Warningf("Calling Get State (Start), key: %s", key)
108-
109104
// getmeta meta from TLE
110105
metadata, err := s.GetMeta(key)
111106
if err != nil {
@@ -124,8 +119,6 @@ func (s *TleStubInterface) GetState(key string) ([]byte, error) {
124119
return nil, errors.New("KVS key not found")
125120
}
126121

127-
logger.Warningf("Calling Get State, encValue: %x, Metadata: %x", encValue, metadata)
128-
129122
err = s.ValidateMeta(metadata, encValue)
130123
if err != nil {
131124
return nil, err

ecc_go/chaincode/solutionTLE.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package chaincode
8+
9+
import (
10+
"github.com/hyperledger/fabric-chaincode-go/shim"
11+
"github.com/hyperledger/fabric-private-chaincode/ecc/chaincode"
12+
"github.com/hyperledger/fabric-private-chaincode/ecc/chaincode/ercc"
13+
"github.com/hyperledger/fabric-private-chaincode/ecc_go/chaincode/enclave_go"
14+
"github.com/hyperledger/fabric-private-chaincode/internal/endorsement"
15+
)
16+
17+
func NewTleChaincode(cc shim.Chaincode) *chaincode.EnclaveChaincode {
18+
newStubInterfaceFunc := enclave_go.NewTleStubInterface
19+
ecc := &chaincode.EnclaveChaincode{
20+
Enclave: enclave_go.NewEnclaveStub(cc, newStubInterfaceFunc),
21+
Validator: endorsement.NewValidator(),
22+
Extractor: &chaincode.ExtractorImpl{},
23+
Ercc: &ercc.StubImpl{},
24+
}
25+
return ecc
26+
}

tle_go/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ mrenclave
66
details.env
77
tmpBlocks/
88
externalbuilder/
9-
lifecycle/
9+
lifecycle/

tle_go/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ WORKDIR ${CC_PATH}
3939
EXPOSE ${CAAS_PORT}
4040
EXPOSE 50051
4141

42-
# CMD ["tle"]
43-
CMD ["sleep", "infinity"]
42+
CMD ["tle"]
43+
# CMD ["sleep", "infinity"]

tle_go/Readme.md

Whitespace-only changes.

tle_go/client/client

-12 MB
Binary file not shown.

tle_go/client/client_linux

-11.3 MB
Binary file not shown.

tle_go/enclave.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@
5353
"fromHost": true
5454
}
5555
]
56-
}
56+
}

tle_go/tlecore/validator_test.go

Lines changed: 0 additions & 188 deletions
This file was deleted.

0 commit comments

Comments
 (0)