@@ -17,9 +17,11 @@ limitations under the License.
17
17
package channel
18
18
19
19
import (
20
+ "errors"
20
21
"fmt"
21
22
"io/ioutil"
22
23
24
+ "github.com/hyperledger/fabric/core/scc/cscc"
23
25
"github.com/hyperledger/fabric/peer/common"
24
26
pcommon "github.com/hyperledger/fabric/protos/common"
25
27
pb "github.com/hyperledger/fabric/protos/peer"
@@ -28,20 +30,18 @@ import (
28
30
"golang.org/x/net/context"
29
31
)
30
32
31
- const joinFuncName = "join "
33
+ const commandDescription = "Joins the peer to a chain. "
32
34
33
35
func joinCmd (cf * ChannelCmdFactory ) * cobra.Command {
34
36
// Set the flags on the channel start command.
35
-
36
- channelJoinCmd := & cobra.Command {
37
+ return & cobra.Command {
37
38
Use : "join" ,
38
- Short : "Joins the peer to a chain." ,
39
- Long : `Joins the peer to a chain.` ,
39
+ Short : commandDescription ,
40
+ Long : commandDescription ,
40
41
RunE : func (cmd * cobra.Command , args []string ) error {
41
42
return join (cmd , args , cf )
42
43
},
43
44
}
44
- return channelJoinCmd
45
45
}
46
46
47
47
//GBFileNotFoundErr genesis block file not found
@@ -60,7 +60,7 @@ func (e ProposalFailedErr) Error() string {
60
60
61
61
func getJoinCCSpec () (* pb.ChaincodeSpec , error ) {
62
62
if genesisBlockPath == common .UndefinedParamValue {
63
- return nil , fmt . Errorf ("Must supply genesis block file.\n " )
63
+ return nil , errors . New ("Must supply genesis block file." )
64
64
}
65
65
66
66
gb , err := ioutil .ReadFile (genesisBlockPath )
@@ -71,7 +71,7 @@ func getJoinCCSpec() (*pb.ChaincodeSpec, error) {
71
71
spec := & pb.ChaincodeSpec {}
72
72
73
73
// Build the spec
74
- input := & pb.ChaincodeInput {Args : [][]byte {[]byte (" JoinChain" ), gb }}
74
+ input := & pb.ChaincodeInput {Args : [][]byte {[]byte (cscc . JoinChain ), gb }}
75
75
76
76
spec = & pb.ChaincodeSpec {
77
77
Type : pb .ChaincodeSpec_Type (pb .ChaincodeSpec_Type_value ["GOLANG" ]),
@@ -93,19 +93,19 @@ func executeJoin(cf *ChannelCmdFactory) (err error) {
93
93
94
94
creator , err := cf .Signer .Serialize ()
95
95
if err != nil {
96
- return fmt .Errorf ("Error serializing identity for %s: %s\n " , cf .Signer .GetIdentifier (), err )
96
+ return fmt .Errorf ("Error serializing identity for %s: %s" , cf .Signer .GetIdentifier (), err )
97
97
}
98
98
99
99
var prop * pb.Proposal
100
100
prop , _ , err = putils .CreateProposalFromCIS (pcommon .HeaderType_CONFIG , "" , invocation , creator )
101
101
if err != nil {
102
- return fmt .Errorf ("Error creating proposal for join %s\n " , err )
102
+ return fmt .Errorf ("Error creating proposal for join %s" , err )
103
103
}
104
104
105
105
var signedProp * pb.SignedProposal
106
106
signedProp , err = putils .GetSignedProposal (prop , cf .Signer )
107
107
if err != nil {
108
- return fmt .Errorf ("Error creating signed proposal %s \n " , err )
108
+ return fmt .Errorf ("Error creating signed proposal %s " , err )
109
109
}
110
110
111
111
var proposalResp * pb.ProposalResponse
@@ -122,7 +122,7 @@ func executeJoin(cf *ChannelCmdFactory) (err error) {
122
122
return ProposalFailedErr (fmt .Sprintf ("bad proposal response %d" , proposalResp .Response .Status ))
123
123
}
124
124
125
- fmt .Printf ( "Join Result: %s \n " , string ( proposalResp . Response . Payload ) )
125
+ fmt .Println ( "Peer joined the channel!" )
126
126
127
127
return nil
128
128
}
0 commit comments