MCPcopy
hub / github.com/hyperledger/fabric / Send

Method Send

discovery/cmd/stub.go:94–132  ·  view source on GitHub ↗

Send sends the request, and receives a response

(server string, conf common.Config, req *discoveryclient.Request)

Source from the content-addressed store, hash-verified

92
93// Send sends the request, and receives a response
94func (stub *RawStub) Send(server string, conf common.Config, req *discoveryclient.Request) (ServiceResponse, error) {
95 comm, err := comm.NewClient(conf.TLSConfig)
96 if err != nil {
97 return nil, err
98 }
99 signer, err := signer.NewSigner(conf.SignerConfig)
100 if err != nil {
101 return nil, err
102 }
103 timeout, cancel := context.WithTimeout(context.Background(), defaultTimeout)
104 defer cancel()
105
106 req.Authentication = &discovery.AuthInfo{
107 ClientIdentity: signer.Creator,
108 ClientTlsCertHash: comm.TLSCertHash,
109 }
110
111 payload := protoutil.MarshalOrPanic(req.Request)
112 sig, err := signer.Sign(payload)
113 if err != nil {
114 return nil, err
115 }
116
117 cc, err := comm.NewDialer(server)()
118 if err != nil {
119 return nil, err
120 }
121 resp, err := discovery.NewDiscoveryClient(cc).Discover(timeout, &discovery.SignedRequest{
122 Payload: payload,
123 Signature: sig,
124 })
125 if err != nil {
126 return nil, err
127 }
128
129 return &response{
130 raw: resp,
131 }, nil
132}

Callers 1

TestRawStubFunction · 0.95

Calls 4

SignMethod · 0.95
NewDialerMethod · 0.95
MarshalOrPanicFunction · 0.92
DiscoverMethod · 0.45

Tested by 1

TestRawStubFunction · 0.76