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

Method Execute

core/chaincode/handler.go:1423–1456  ·  view source on GitHub ↗
(txParams *ccprovider.TransactionParams, namespace string, msg *pb.ChaincodeMessage, timeout time.Duration)

Source from the content-addressed store, hash-verified

1421}
1422
1423func (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
1458func (h *Handler) setChaincodeProposal(signedProp *pb.SignedProposal, prop *pb.Proposal, msg *pb.ChaincodeMessage) error {
1459 if prop != nil && signedProp == nil {

Callers

nothing calls this directly

Calls 11

getCollectionStoreMethod · 0.95
setChaincodeProposalMethod · 0.95
serialSendAsyncMethod · 0.95
streamDoneMethod · 0.95
DebugfMethod · 0.80
CreateMethod · 0.65
DeleteMethod · 0.65
AfterMethod · 0.65
NewMethod · 0.65
AddMethod · 0.65
WithMethod · 0.65

Tested by

no test coverage detected