diff --git a/examples/e2e_cli/end-to-end.rst b/examples/e2e_cli/end-to-end.rst index d5a5e2b72a8..08d214c1795 100644 --- a/examples/e2e_cli/end-to-end.rst +++ b/examples/e2e_cli/end-to-end.rst @@ -442,7 +442,7 @@ Install the sample go code onto one of the four peer nodes .. code:: bash - peer chaincode install -o orderer:7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 + peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 Instantiate chaincode and define the endorsement policy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -476,7 +476,7 @@ Query chaincode .. code:: bash - peer chaincode query -o orderer:7050 -C mychannel -n mycc -c '{"Args":["query","a"]}' + peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}' The result of the above command should be as below: diff --git a/examples/e2e_cli/scripts/script.sh b/examples/e2e_cli/scripts/script.sh index 22c43b85690..8a9b67e05c0 100755 --- a/examples/e2e_cli/scripts/script.sh +++ b/examples/e2e_cli/scripts/script.sh @@ -82,7 +82,7 @@ joinChannel () { installChaincode () { PEER=$1 setGlobals $PEER - peer chaincode install -o $ORDERER_IP:7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 >&log.txt + peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 >&log.txt res=$? cat log.txt verifyResult $res "Chaincode installation on remote peer PEER$PEER has Failed" @@ -114,7 +114,7 @@ chaincodeQuery () { do sleep 3 echo "Attempting to Query PEER$PEER ...$(($(date +%s)-starttime)) secs" - peer chaincode query -o $ORDERER_IP:7050 -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}' >&log.txt + peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}' >&log.txt test $? -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}') test "$VALUE" = "$2" && let rc=0 done diff --git a/peer/chaincode/common.go b/peer/chaincode/common.go index afccd710701..e82ca3fbaab 100644 --- a/peer/chaincode/common.go +++ b/peer/chaincode/common.go @@ -214,7 +214,7 @@ type ChaincodeCmdFactory struct { } // InitCmdFactory init the ChaincodeCmdFactory with default clients -func InitCmdFactory() (*ChaincodeCmdFactory, error) { +func InitCmdFactory(isOrdererRequired bool) (*ChaincodeCmdFactory, error) { endorserClient, err := common.GetEndorserClient() if err != nil { return nil, fmt.Errorf("Error getting endorser client %s: %s", chainFuncName, err) @@ -225,11 +225,14 @@ func InitCmdFactory() (*ChaincodeCmdFactory, error) { return nil, fmt.Errorf("Error getting default signer: %s", err) } - broadcastClient, err := common.GetBroadcastClient(orderingEndpoint) - if err != nil { - return nil, fmt.Errorf("Error getting broadcast client: %s", err) - } + var broadcastClient common.BroadcastClient + if isOrdererRequired { + broadcastClient, err = common.GetBroadcastClient(orderingEndpoint) + if err != nil { + return nil, fmt.Errorf("Error getting broadcast client: %s", err) + } + } return &ChaincodeCmdFactory{ EndorserClient: endorserClient, Signer: signer, diff --git a/peer/chaincode/install.go b/peer/chaincode/install.go index 49c099642f7..391af205467 100644 --- a/peer/chaincode/install.go +++ b/peer/chaincode/install.go @@ -88,7 +88,7 @@ func chaincodeInstall(cmd *cobra.Command, args []string, cf *ChaincodeCmdFactory var err error if cf == nil { - cf, err = InitCmdFactory() + cf, err = InitCmdFactory(false) if err != nil { return err } diff --git a/peer/chaincode/instantiate.go b/peer/chaincode/instantiate.go index b1e489fac19..fcaaa649a77 100644 --- a/peer/chaincode/instantiate.go +++ b/peer/chaincode/instantiate.go @@ -99,7 +99,7 @@ func instantiate(cmd *cobra.Command, cf *ChaincodeCmdFactory) (*protcommon.Envel func chaincodeDeploy(cmd *cobra.Command, args []string, cf *ChaincodeCmdFactory) error { var err error if cf == nil { - cf, err = InitCmdFactory() + cf, err = InitCmdFactory(true) if err != nil { return err } diff --git a/peer/chaincode/invoke.go b/peer/chaincode/invoke.go index b55d5918710..a8d1f11e901 100644 --- a/peer/chaincode/invoke.go +++ b/peer/chaincode/invoke.go @@ -42,7 +42,7 @@ func invokeCmd(cf *ChaincodeCmdFactory) *cobra.Command { func chaincodeInvoke(cmd *cobra.Command, args []string, cf *ChaincodeCmdFactory) error { var err error if cf == nil { - cf, err = InitCmdFactory() + cf, err = InitCmdFactory(true) if err != nil { return err } diff --git a/peer/chaincode/query.go b/peer/chaincode/query.go index b65edf1bee3..cb3c26cbb05 100644 --- a/peer/chaincode/query.go +++ b/peer/chaincode/query.go @@ -47,12 +47,11 @@ func queryCmd(cf *ChaincodeCmdFactory) *cobra.Command { func chaincodeQuery(cmd *cobra.Command, args []string, cf *ChaincodeCmdFactory) error { var err error if cf == nil { - cf, err = InitCmdFactory() + cf, err = InitCmdFactory(false) if err != nil { return err } } - defer cf.BroadcastClient.Close() return chaincodeInvokeOrQuery(cmd, args, false, cf) } diff --git a/peer/chaincode/upgrade.go b/peer/chaincode/upgrade.go index 4d7ee3fd55e..34ed8ed6fdc 100644 --- a/peer/chaincode/upgrade.go +++ b/peer/chaincode/upgrade.go @@ -98,7 +98,7 @@ func upgrade(cmd *cobra.Command, cf *ChaincodeCmdFactory) (*protcommon.Envelope, func chaincodeUpgrade(cmd *cobra.Command, args []string, cf *ChaincodeCmdFactory) error { var err error if cf == nil { - cf, err = InitCmdFactory() + cf, err = InitCmdFactory(true) if err != nil { return err }