Skip to content

Commit a93d1da

Browse files
author
Anil Ambati
committed
[FAB-5222] Correct misleading CLI output on join
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>
1 parent 2d4a96e commit a93d1da

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

peer/channel/channel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var (
5555
genesisBlockPath string
5656

5757
// create related variables
58-
chainID string
58+
channelID string
5959
channelTxFile string
6060
orderingEndpoint string
6161
tls bool
@@ -100,7 +100,7 @@ func resetFlags() {
100100
flags = &pflag.FlagSet{}
101101

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

188-
cmdFact.DeliverClient = newDeliverClient(conn, client, chainID)
188+
cmdFact.DeliverClient = newDeliverClient(conn, client, channelID)
189189
}
190190
logger.Infof("Endorser and orderer connections initialized")
191191
return cmdFact, nil

peer/channel/create.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func createChannelFromDefaults(cf *ChannelCmdFactory) (*cb.Envelope, error) {
7676
return nil, err
7777
}
7878

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

8181
if err != nil {
8282
return nil, err
@@ -119,12 +119,12 @@ func sanityCheckAndSignConfigTx(envConfigUpdate *cb.Envelope) (*cb.Envelope, err
119119

120120
// Specifying the chainID on the CLI is usually redundant, as a hack, set it
121121
// here if it has not been set explicitly
122-
if chainID == "" {
123-
chainID = ch.ChannelId
122+
if channelID == "" {
123+
channelID = ch.ChannelId
124124
}
125125

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

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

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

149-
return utils.CreateSignedEnvelope(cb.HeaderType_CONFIG_UPDATE, chainID, signer, configUpdateEnv, 0, 0)
149+
return utils.CreateSignedEnvelope(cb.HeaderType_CONFIG_UPDATE, channelID, signer, configUpdateEnv, 0, 0)
150150
}
151151

152152
func sendCreateChainTransaction(cf *ChannelCmdFactory) error {
@@ -196,7 +196,7 @@ func executeCreate(cf *ChannelCmdFactory) error {
196196
return err
197197
}
198198

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

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

peer/channel/create_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,10 @@ func TestSanityCheckAndSignChannelCreateTx(t *testing.T) {
575575

576576
// Error case 4
577577
mockchannel := "mockchannel"
578-
cid := chainID
579-
chainID = mockchannel
578+
cid := channelID
579+
channelID = mockchannel
580580
defer func() {
581-
chainID = cid
581+
channelID = cid
582582
}()
583583
ch := &cb.ChannelHeader{Type: int32(cb.HeaderType_CONFIG_UPDATE), ChannelId: mockchannel}
584584
data, err = proto.Marshal(ch)

peer/channel/fetchconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func fetch(cmd *cobra.Command, args []string, cf *ChannelCmdFactory) error {
9797

9898
var file string
9999
if len(args) == 1 {
100-
file = chainID + "_" + args[0] + ".block"
100+
file = channelID + "_" + args[0] + ".block"
101101
} else {
102102
file = args[1]
103103
}

peer/channel/getinfo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (cc *endorserClient) getBlockChainInfo() (*cb.BlockchainInfo, error) {
4646
ChaincodeSpec: &pb.ChaincodeSpec{
4747
Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value["GOLANG"]),
4848
ChaincodeId: &pb.ChaincodeID{Name: "qscc"},
49-
Input: &pb.ChaincodeInput{Args: [][]byte{[]byte(qscc.GetChainInfo), []byte(chainID)}},
49+
Input: &pb.ChaincodeInput{Args: [][]byte{[]byte(qscc.GetChainInfo), []byte(channelID)}},
5050
},
5151
}
5252

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

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

peer/channel/join.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func executeJoin(cf *ChannelCmdFactory) (err error) {
124124
if proposalResp.Response.Status != 0 && proposalResp.Response.Status != 200 {
125125
return ProposalFailedErr(fmt.Sprintf("bad proposal response %d", proposalResp.Response.Status))
126126
}
127-
logger.Infof("Peer joined the channel!")
127+
logger.Infof("Successfully submitted proposal to join channel '%s'", channelID)
128128
return nil
129129
}
130130

peer/channel/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func updateCmd(cf *ChannelCmdFactory) *cobra.Command {
4848

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

0 commit comments

Comments
 (0)