serialSendAsync serves the same purpose as serialSend (serialize msgs so gRPC will be happy). In addition, it is also asynchronous so send-remoterecv--localrecv loop can be nonblocking. Only errors need to be handled and these are handled by communication on supplied error channel. A typical use wil
(msg *pb.ChaincodeMessage)
| 355 | // communication on supplied error channel. A typical use will be a non-blocking or |
| 356 | // nil channel |
| 357 | func (h *Handler) serialSendAsync(msg *pb.ChaincodeMessage) { |
| 358 | go func() { |
| 359 | if err := h.serialSend(msg); err != nil { |
| 360 | // provide an error response to the caller |
| 361 | resp := &pb.ChaincodeMessage{ |
| 362 | Type: pb.ChaincodeMessage_ERROR, |
| 363 | Payload: []byte(err.Error()), |
| 364 | Txid: msg.Txid, |
| 365 | ChannelId: msg.ChannelId, |
| 366 | } |
| 367 | h.Notify(resp) |
| 368 | |
| 369 | // surface send error to stream processing |
| 370 | h.errChan <- err |
| 371 | } |
| 372 | }() |
| 373 | } |
| 374 | |
| 375 | // Check if the transactor is allow to call this chaincode on this channel |
| 376 | func (h *Handler) checkACL(signedProp *pb.SignedProposal, proposal *pb.Proposal, ccIns *sysccprovider.ChaincodeInstance) error { |
no test coverage detected