diff --git a/internal/peer/chaincode/chaincode.go b/internal/peer/chaincode/chaincode.go index 109d673a80c..9c78ca54f89 100644 --- a/internal/peer/chaincode/chaincode.go +++ b/internal/peer/chaincode/chaincode.go @@ -13,7 +13,6 @@ import ( "github.com/hyperledger/fabric/bccsp" "github.com/hyperledger/fabric/common/flogging" "github.com/hyperledger/fabric/internal/peer/common" - "github.com/hyperledger/fabric/internal/peer/packaging" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -25,12 +24,6 @@ const ( var logger = flogging.MustGetLogger("chaincodeCmd") -// XXX This is a terrible singleton hack, however -// it simply making a latent dependency explicit. -// It should be removed along with the other package -// scoped variables -var platformRegistry = packaging.NewRegistry(packaging.SupportedPlatforms...) - func addFlags(cmd *cobra.Command) { common.AddOrdererFlags(cmd) flags := cmd.PersistentFlags() @@ -49,26 +42,23 @@ func Cmd(cf *ChaincodeCmdFactory, cryptoProvider bccsp.BCCSP) *cobra.Command { // Chaincode-related variables. var ( - chaincodeLang string - chaincodeCtorJSON string - chaincodePath string - chaincodeName string - chaincodeUsr string // Not used - chaincodeQueryRaw bool - chaincodeQueryHex bool - channelID string - chaincodeVersion string - policy string - policyMarshalled []byte - transient string - isInit bool - collectionsConfigFile string - collectionConfigBytes []byte - peerAddresses []string - tlsRootCertFiles []string - connectionProfile string - waitForEvent bool - waitForEventTimeout time.Duration + chaincodeLang string + chaincodeCtorJSON string + chaincodePath string + chaincodeName string + chaincodeUsr string // Not used + chaincodeQueryRaw bool + chaincodeQueryHex bool + channelID string + chaincodeVersion string + policy string + transient string + isInit bool + peerAddresses []string + tlsRootCertFiles []string + connectionProfile string + waitForEvent bool + waitForEventTimeout time.Duration ) var chaincodeCmd = &cobra.Command{ @@ -109,8 +99,6 @@ func resetFlags() { "The endorsement policy associated to this chaincode") flags.BoolVarP(&isInit, "isInit", "I", false, "Is this invocation for init (useful for supporting legacy chaincodes in the new lifecycle)") - flags.StringVar(&collectionsConfigFile, "collections-config", common.UndefinedParamValue, - "The fully qualified path to the collection JSON file including the file name") flags.StringArrayVarP(&peerAddresses, "peerAddresses", "", []string{common.UndefinedParamValue}, "The addresses of the peers to connect to") flags.StringArrayVarP(&tlsRootCertFiles, "tlsRootCertFiles", "", []string{common.UndefinedParamValue}, diff --git a/internal/peer/chaincode/common.go b/internal/peer/chaincode/common.go index f1612dc3f8f..55bb5923535 100644 --- a/internal/peer/chaincode/common.go +++ b/internal/peer/chaincode/common.go @@ -32,42 +32,6 @@ import ( "github.com/spf13/viper" ) -// checkSpec to see if chaincode resides within current package capture for language. -func checkSpec(spec *pb.ChaincodeSpec) error { - // Don't allow nil value - if spec == nil { - return errors.New("expected chaincode specification, nil received") - } - if spec.ChaincodeId == nil { - return errors.New("expected chaincode ID, nil received") - } - - return platformRegistry.ValidateSpec(spec.Type.String(), spec.ChaincodeId.Path) -} - -// getChaincodeDeploymentSpec get chaincode deployment spec given the chaincode spec -func getChaincodeDeploymentSpec(spec *pb.ChaincodeSpec, crtPkg bool) (*pb.ChaincodeDeploymentSpec, error) { - var codePackageBytes []byte - if crtPkg { - var err error - if err = checkSpec(spec); err != nil { - return nil, err - } - - codePackageBytes, err = platformRegistry.GetDeploymentPayload(spec.Type.String(), spec.ChaincodeId.Path) - if err != nil { - return nil, errors.WithMessage(err, "error getting chaincode package bytes") - } - chaincodePath, err := platformRegistry.NormalizePath(spec.Type.String(), spec.ChaincodeId.Path) - if err != nil { - return nil, errors.WithMessage(err, "failed to normalize chaincode path") - } - spec.ChaincodeId.Path = chaincodePath - } - - return &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec, CodePackage: codePackageBytes}, nil -} - // getChaincodeSpec get chaincode spec from the cli cmd parameters func getChaincodeSpec(cmd *cobra.Command) (*pb.ChaincodeSpec, error) { spec := &pb.ChaincodeSpec{} diff --git a/internal/peer/chaincode/common_test.go b/internal/peer/chaincode/common_test.go index 5bbada3c12a..fa82a02e36b 100644 --- a/internal/peer/chaincode/common_test.go +++ b/internal/peer/chaincode/common_test.go @@ -26,7 +26,6 @@ import ( "github.com/hyperledger/fabric/core/config/configtest" "github.com/hyperledger/fabric/internal/peer/chaincode/mock" "github.com/hyperledger/fabric/internal/peer/common" - "github.com/hyperledger/fabric/internal/pkg/identity" msptesttools "github.com/hyperledger/fabric/msp/mgmt/testtools" . "github.com/onsi/gomega" "github.com/spf13/cobra" @@ -34,24 +33,6 @@ import ( "github.com/stretchr/testify/require" ) -//go:generate counterfeiter -o mock/signer_serializer.go --fake-name SignerSerializer . signerSerializer - -type signerSerializer interface { - identity.SignerSerializer -} - -//go:generate counterfeiter -o mock/deliver.go --fake-name Deliver . deliver - -type deliver interface { - pb.Deliver_DeliverClient -} - -//go:generate counterfeiter -o mock/deliver_client.go --fake-name PeerDeliverClient . peerDeliverClient - -type peerDeliverClient interface { - pb.DeliverClient -} - func TestCheckChaincodeCmdParamsWithNewCallingSchema(t *testing.T) { chaincodeCtorJSON = `{ "Args":["func", "param"] }` chaincodePath = "some/path"