@@ -8,9 +8,15 @@ SPDX-License-Identifier: Apache-2.0
88package enclave_go
99
1010import (
11+ "fmt"
12+ //lint:ignore SA1019 the package is needed to unmarshall the header
13+ protoV1 "github.com/golang/protobuf/proto"
1114 "github.com/hyperledger/fabric-chaincode-go/shim"
1215 "github.com/hyperledger/fabric-private-chaincode/internal/utils"
16+ common "github.com/hyperledger/fabric-protos-go/common"
1317 pb "github.com/hyperledger/fabric-protos-go/peer"
18+
19+ "google.golang.org/protobuf/proto"
1420 timestamp "google.golang.org/protobuf/types/known/timestamppb"
1521)
1622
@@ -177,7 +183,7 @@ func (f *FpcStubInterface) SplitCompositeKey(compositeKey string) (string, []str
177183}
178184
179185func (f * FpcStubInterface ) GetQueryResult (query string ) (shim.StateQueryIteratorInterface , error ) {
180- panic ( " not implemented" ) // TODO: Implement
186+ return nil , fmt . Errorf ( "function not yet supported" )
181187}
182188
183189func (f * FpcStubInterface ) GetQueryResultWithPagination (query string , pageSize int32 , bookmark string ) (shim.StateQueryIteratorInterface , * pb.QueryResponseMetadata , error ) {
@@ -233,7 +239,7 @@ func (f *FpcStubInterface) GetCreator() ([]byte, error) {
233239}
234240
235241func (f * FpcStubInterface ) GetTransient () (map [string ][]byte , error ) {
236- panic ( " not implemented" ) // TODO: Implement
242+ return nil , fmt . Errorf ( "function not yet supported" )
237243}
238244
239245func (f * FpcStubInterface ) GetBinding () ([]byte , error ) {
@@ -249,9 +255,22 @@ func (f *FpcStubInterface) GetSignedProposal() (*pb.SignedProposal, error) {
249255}
250256
251257func (f * FpcStubInterface ) GetTxTimestamp () (* timestamp.Timestamp , error ) {
252- panic ("not implemented" ) // TODO: Implement
258+ hdr := & common.Header {}
259+ proposal , Proposalerr := f .GetSignedProposal ()
260+ if Proposalerr != nil {
261+ return nil , fmt .Errorf ("error retrieving the proposal from the FPC Stub" )
262+ }
263+ if err := proto .Unmarshal (proposal .ProposalBytes , protoV1 .MessageV2 (hdr )); err != nil {
264+ return nil , fmt .Errorf ("error unmarshaling Header: %s" , err )
265+ }
266+
267+ chdr := & common.ChannelHeader {}
268+ if err := proto .Unmarshal (hdr .ChannelHeader , protoV1 .MessageV2 (chdr )); err != nil {
269+ return nil , fmt .Errorf ("error unmarshaling ChannelHeader: %s" , err )
270+ }
271+ return chdr .GetTimestamp (), nil
253272}
254273
255274func (f * FpcStubInterface ) SetEvent (name string , payload []byte ) error {
256- panic ( " not implemented" ) // TODO: Implement
275+ return fmt . Errorf ( "function not yet supported" )
257276}
0 commit comments