(txParams *ccprovider.TransactionParams, namespace string, msg *pb.ChaincodeMessage, timeout time.Duration)
| 1421 | } |
| 1422 | |
| 1423 | func (h *Handler) Execute(txParams *ccprovider.TransactionParams, namespace string, msg *pb.ChaincodeMessage, timeout time.Duration) (*pb.ChaincodeMessage, error) { |
| 1424 | chaincodeLogger.Debugf("Entry") |
| 1425 | defer chaincodeLogger.Debugf("Exit") |
| 1426 | |
| 1427 | txParams.CollectionStore = h.getCollectionStore(msg.ChannelId) |
| 1428 | txParams.IsInitTransaction = msg.Type == pb.ChaincodeMessage_INIT |
| 1429 | txParams.NamespaceID = namespace |
| 1430 | |
| 1431 | txctx, err := h.TXContexts.Create(txParams) |
| 1432 | if err != nil { |
| 1433 | return nil, err |
| 1434 | } |
| 1435 | defer h.TXContexts.Delete(msg.ChannelId, msg.Txid) |
| 1436 | |
| 1437 | if err = h.setChaincodeProposal(txParams.SignedProp, txParams.Proposal, msg); err != nil { |
| 1438 | return nil, err |
| 1439 | } |
| 1440 | |
| 1441 | h.serialSendAsync(msg) |
| 1442 | |
| 1443 | var ccresp *pb.ChaincodeMessage |
| 1444 | select { |
| 1445 | case ccresp = <-txctx.ResponseNotifier: |
| 1446 | // response is sent to user or calling chaincode. ChaincodeMessage_ERROR |
| 1447 | // are typically treated as error |
| 1448 | case <-time.After(timeout): |
| 1449 | err = errors.New(ErrorExecutionTimeout) |
| 1450 | h.Metrics.ExecuteTimeouts.With("chaincode", h.chaincodeID).Add(1) |
| 1451 | case <-h.streamDone(): |
| 1452 | err = errors.New(ErrorStreamTerminated) |
| 1453 | } |
| 1454 | |
| 1455 | return ccresp, err |
| 1456 | } |
| 1457 | |
| 1458 | func (h *Handler) setChaincodeProposal(signedProp *pb.SignedProposal, prop *pb.Proposal, msg *pb.ChaincodeMessage) error { |
| 1459 | if prop != nil && signedProp == nil { |
nothing calls this directly
no test coverage detected