Skip to content

Commit

Permalink
[FAB-5222] Correct misleading CLI output on join
Browse files Browse the repository at this point in the history
The peer join command submits a join proposal request asynchronously, so
it does not know the outcome of the request immediately after command
is finished. But the output it prints is "Peer joined the channel", which
is misleading. The change set corrects this message to "Successfully
submitted proposal to join the channel"

Change-Id: I3e468547d128c0118769d5b551c465838567940b
Signed-off-by: Anil Ambati <aambati@us.ibm.com>
  • Loading branch information
Anil Ambati committed Nov 3, 2017
1 parent 2d4a96e commit a93d1da
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions peer/channel/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var (
genesisBlockPath string

// create related variables
chainID string
channelID string
channelTxFile string
orderingEndpoint string
tls bool
Expand Down Expand Up @@ -100,7 +100,7 @@ func resetFlags() {
flags = &pflag.FlagSet{}

flags.StringVarP(&genesisBlockPath, "blockpath", "b", common.UndefinedParamValue, "Path to file containing genesis block")
flags.StringVarP(&chainID, "channelID", "c", common.UndefinedParamValue, "In case of a newChain command, the channel ID to create.")
flags.StringVarP(&channelID, "channelID", "c", common.UndefinedParamValue, "In case of a newChain command, the channel ID to create.")
flags.StringVarP(&channelTxFile, "file", "f", "", "Configuration transaction file generated by a tool such as configtxgen for submitting to orderer")
flags.IntVarP(&timeout, "timeout", "t", 5, "Channel creation timeout")
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func InitCmdFactory(isEndorserRequired EndorserRequirement, isOrdererRequired Or
return nil, fmt.Errorf("Error connecting due to %s", err)
}

cmdFact.DeliverClient = newDeliverClient(conn, client, chainID)
cmdFact.DeliverClient = newDeliverClient(conn, client, channelID)
}
logger.Infof("Endorser and orderer connections initialized")
return cmdFact, nil
Expand Down
16 changes: 8 additions & 8 deletions peer/channel/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func createChannelFromDefaults(cf *ChannelCmdFactory) (*cb.Envelope, error) {
return nil, err
}

chCrtEnv, err := encoder.MakeChannelCreationTransaction(chainID, genesisconfig.SampleConsortiumName, signer, nil)
chCrtEnv, err := encoder.MakeChannelCreationTransaction(channelID, genesisconfig.SampleConsortiumName, signer, nil)

if err != nil {
return nil, err
Expand Down Expand Up @@ -119,12 +119,12 @@ func sanityCheckAndSignConfigTx(envConfigUpdate *cb.Envelope) (*cb.Envelope, err

// Specifying the chainID on the CLI is usually redundant, as a hack, set it
// here if it has not been set explicitly
if chainID == "" {
chainID = ch.ChannelId
if channelID == "" {
channelID = ch.ChannelId
}

if ch.ChannelId != chainID {
return nil, InvalidCreateTx(fmt.Sprintf("mismatched channel ID %s != %s", ch.ChannelId, chainID))
if ch.ChannelId != channelID {
return nil, InvalidCreateTx(fmt.Sprintf("mismatched channel ID %s != %s", ch.ChannelId, channelID))
}

configUpdateEnv, err := configtx.UnmarshalConfigUpdateEnvelope(payload.Data)
Expand All @@ -146,7 +146,7 @@ func sanityCheckAndSignConfigTx(envConfigUpdate *cb.Envelope) (*cb.Envelope, err

configUpdateEnv.Signatures = append(configUpdateEnv.Signatures, configSig)

return utils.CreateSignedEnvelope(cb.HeaderType_CONFIG_UPDATE, chainID, signer, configUpdateEnv, 0, 0)
return utils.CreateSignedEnvelope(cb.HeaderType_CONFIG_UPDATE, channelID, signer, configUpdateEnv, 0, 0)
}

func sendCreateChainTransaction(cf *ChannelCmdFactory) error {
Expand Down Expand Up @@ -196,7 +196,7 @@ func executeCreate(cf *ChannelCmdFactory) error {
return err
}

file := chainID + ".block"
file := channelID + ".block"
if err = ioutil.WriteFile(file, b, 0644); err != nil {
return err
}
Expand All @@ -206,7 +206,7 @@ func executeCreate(cf *ChannelCmdFactory) error {

func create(cmd *cobra.Command, args []string, cf *ChannelCmdFactory) error {
//the global chainID filled by the "-c" command
if chainID == common.UndefinedParamValue {
if channelID == common.UndefinedParamValue {
return errors.New("Must supply channel ID")
}

Expand Down
6 changes: 3 additions & 3 deletions peer/channel/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,10 @@ func TestSanityCheckAndSignChannelCreateTx(t *testing.T) {

// Error case 4
mockchannel := "mockchannel"
cid := chainID
chainID = mockchannel
cid := channelID
channelID = mockchannel
defer func() {
chainID = cid
channelID = cid
}()
ch := &cb.ChannelHeader{Type: int32(cb.HeaderType_CONFIG_UPDATE), ChannelId: mockchannel}
data, err = proto.Marshal(ch)
Expand Down
2 changes: 1 addition & 1 deletion peer/channel/fetchconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func fetch(cmd *cobra.Command, args []string, cf *ChannelCmdFactory) error {

var file string
if len(args) == 1 {
file = chainID + "_" + args[0] + ".block"
file = channelID + "_" + args[0] + ".block"
} else {
file = args[1]
}
Expand Down
4 changes: 2 additions & 2 deletions peer/channel/getinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (cc *endorserClient) getBlockChainInfo() (*cb.BlockchainInfo, error) {
ChaincodeSpec: &pb.ChaincodeSpec{
Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value["GOLANG"]),
ChaincodeId: &pb.ChaincodeID{Name: "qscc"},
Input: &pb.ChaincodeInput{Args: [][]byte{[]byte(qscc.GetChainInfo), []byte(chainID)}},
Input: &pb.ChaincodeInput{Args: [][]byte{[]byte(qscc.GetChainInfo), []byte(channelID)}},
},
}

Expand Down Expand Up @@ -84,7 +84,7 @@ func (cc *endorserClient) getBlockChainInfo() (*cb.BlockchainInfo, error) {

func getinfo(cf *ChannelCmdFactory) error {
//the global chainID filled by the "-c" command
if chainID == common.UndefinedParamValue {
if channelID == common.UndefinedParamValue {
return errors.New("Must supply channel ID")
}

Expand Down
2 changes: 1 addition & 1 deletion peer/channel/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func executeJoin(cf *ChannelCmdFactory) (err error) {
if proposalResp.Response.Status != 0 && proposalResp.Response.Status != 200 {
return ProposalFailedErr(fmt.Sprintf("bad proposal response %d", proposalResp.Response.Status))
}
logger.Infof("Peer joined the channel!")
logger.Infof("Successfully submitted proposal to join channel '%s'", channelID)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion peer/channel/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func updateCmd(cf *ChannelCmdFactory) *cobra.Command {

func update(cmd *cobra.Command, args []string, cf *ChannelCmdFactory) error {
//the global chainID filled by the "-c" command
if chainID == common.UndefinedParamValue {
if channelID == common.UndefinedParamValue {
return errors.New("Must supply channel ID")
}

Expand Down

0 comments on commit a93d1da

Please sign in to comment.