|
6 | 6 |
|
7 | 7 | package org.hyperledger.fabric.shim; |
8 | 8 |
|
9 | | -import io.grpc.ManagedChannel; |
10 | | -import io.grpc.netty.GrpcSslContexts; |
11 | | -import io.grpc.netty.NegotiationType; |
12 | | -import io.grpc.netty.NettyChannelBuilder; |
13 | | -import io.netty.handler.ssl.SslContext; |
| 9 | +import static org.hyperledger.fabric.shim.Chaincode.Response.Status.INTERNAL_SERVER_ERROR; |
| 10 | +import static org.hyperledger.fabric.shim.Chaincode.Response.Status.SUCCESS; |
| 11 | + |
| 12 | +import java.io.File; |
| 13 | +import java.io.PrintWriter; |
| 14 | +import java.io.StringWriter; |
| 15 | +import java.nio.charset.StandardCharsets; |
| 16 | + |
| 17 | +import javax.net.ssl.SSLException; |
| 18 | + |
14 | 19 | import org.apache.commons.cli.CommandLine; |
15 | 20 | import org.apache.commons.cli.DefaultParser; |
16 | 21 | import org.apache.commons.cli.Options; |
|
21 | 26 | import org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage.Type; |
22 | 27 | import org.hyperledger.fabric.shim.impl.ChatStream; |
23 | 28 |
|
24 | | -import javax.net.ssl.SSLException; |
25 | | -import java.io.File; |
26 | | -import java.io.PrintWriter; |
27 | | -import java.io.StringWriter; |
28 | | -import java.nio.charset.StandardCharsets; |
29 | | - |
30 | | -import static org.hyperledger.fabric.shim.Chaincode.Response.Status.INTERNAL_SERVER_ERROR; |
31 | | -import static org.hyperledger.fabric.shim.Chaincode.Response.Status.SUCCESS; |
| 29 | +import io.grpc.ManagedChannel; |
| 30 | +import io.grpc.netty.GrpcSslContexts; |
| 31 | +import io.grpc.netty.NegotiationType; |
| 32 | +import io.grpc.netty.NettyChannelBuilder; |
| 33 | +import io.netty.handler.ssl.SslContext; |
32 | 34 |
|
33 | 35 | public abstract class ChaincodeBase implements Chaincode { |
34 | 36 |
|
@@ -79,14 +81,19 @@ public void start(String[] args) { |
79 | 81 |
|
80 | 82 | private void processCommandLineOptions(String[] args) { |
81 | 83 | Options options = new Options(); |
82 | | - options.addOption("a", "peerAddress", true, "Address of peer to connect to"); |
| 84 | + options.addOption("a", "peer.address", true, "Address of peer to connect to"); |
| 85 | + options.addOption(null, "peerAddress", true, "Address of peer to connect to"); |
83 | 86 | options.addOption("s", "securityEnabled", false, "Present if security is enabled"); |
84 | 87 | options.addOption("i", "id", true, "Identity of chaincode"); |
85 | 88 | options.addOption("o", "hostNameOverride", true, "Hostname override for server certificate"); |
86 | 89 | try { |
87 | 90 | CommandLine cl = new DefaultParser().parse(options, args); |
88 | | - if (cl.hasOption('a')) { |
89 | | - host = cl.getOptionValue('a'); |
| 91 | + if (cl.hasOption("peerAddress") || cl.hasOption('a')) { |
| 92 | + if (cl.hasOption('a')) { |
| 93 | + host = cl.getOptionValue('a'); |
| 94 | + } else { |
| 95 | + host = cl.getOptionValue("peerAddress"); |
| 96 | + } |
90 | 97 | port = new Integer(host.split(":")[1]); |
91 | 98 | host = host.split(":")[0]; |
92 | 99 | } |
|
0 commit comments