github.com/s7techlab/cckit@v0.10.5/extensions/pinger/pinger.go (about) 1 // Package pinger contains structure and functions for checking chain code accessibility 2 package pinger 3 4 import ( 5 "github.com/hyperledger/fabric-chaincode-go/pkg/cid" 6 "google.golang.org/protobuf/types/known/timestamppb" 7 8 "github.com/s7techlab/cckit/identity" 9 r "github.com/s7techlab/cckit/router" 10 ) 11 12 // Ping create PingInfo struct with tx creator ID and certificate in PEM format 13 func Ping(ctx r.Context) (interface{}, error) { 14 id, err := cid.GetID(ctx.Stub()) 15 if err != nil { 16 return nil, err 17 } 18 19 //take certificate from creator 20 invoker, err := identity.FromStub(ctx.Stub()) 21 if err != nil { 22 return nil, err 23 } 24 25 txTime, err := ctx.Time() 26 if err != nil { 27 return nil, err 28 } 29 30 return &PingInfo{ 31 InvokerId: id, 32 InvokerCert: invoker.GetPEM(), 33 EndorsingServerTime: timestamppb.Now(), 34 TxTime: timestamppb.New(txTime), 35 }, nil 36 }