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

Function getChaincodeSpec

internal/peer/chaincode/common.go:36–58  ·  view source on GitHub ↗

getChaincodeSpec get chaincode spec from the cli cmd parameters

(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

34
35// getChaincodeSpec get chaincode spec from the cli cmd parameters
36func getChaincodeSpec(cmd *cobra.Command) (*pb.ChaincodeSpec, error) {
37 spec := &pb.ChaincodeSpec{}
38 if err := checkChaincodeCmdParams(cmd); err != nil {
39 // unset usage silence because it's a command line usage error
40 cmd.SilenceUsage = false
41 return spec, err
42 }
43
44 // Build the spec
45 input := chaincodeInput{}
46 if err := json.Unmarshal([]byte(chaincodeCtorJSON), &input); err != nil {
47 return spec, errors.Wrap(err, "chaincode argument error")
48 }
49 input.IsInit = isInit
50
51 chaincodeLang = strings.ToUpper(chaincodeLang)
52 spec = &pb.ChaincodeSpec{
53 Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[chaincodeLang]),
54 ChaincodeId: &pb.ChaincodeID{Path: chaincodePath, Name: chaincodeName, Version: chaincodeVersion},
55 Input: &input.ChaincodeInput,
56 }
57 return spec, nil
58}
59
60// chaincodeInput is wrapper around the proto defined ChaincodeInput message that
61// is decorated with a custom JSON unmarshaller.

Callers 1

chaincodeInvokeOrQueryFunction · 0.85

Calls 3

checkChaincodeCmdParamsFunction · 0.85
WrapMethod · 0.80
UnmarshalMethod · 0.65

Tested by

no test coverage detected