@@ -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
3130func 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
4243func (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
7372func (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
106103func (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
0 commit comments