@@ -58,7 +58,6 @@ public abstract class ChaincodeBase implements Chaincode {
58
58
59
59
private static Log logger = LogFactory .getLog (ChaincodeBase .class );
60
60
61
- public abstract String getChaincodeID ();
62
61
public static final String DEFAULT_HOST = "127.0.0.1" ;
63
62
public static final int DEFAULT_PORT = 7051 ;
64
63
@@ -69,26 +68,32 @@ public abstract class ChaincodeBase implements Chaincode {
69
68
private String rootCertFile = "/etc/hyperledger/fabric/peer.crt" ;
70
69
71
70
private Handler handler ;
72
- private String id = getChaincodeID () ;
71
+ private String id ;
73
72
74
73
private final static String CORE_CHAINCODE_ID_NAME = "CORE_CHAINCODE_ID_NAME" ;
75
74
private final static String CORE_PEER_ADDRESS = "CORE_PEER_ADDRESS" ;
76
75
private final static String CORE_PEER_TLS_ENABLED = "CORE_PEER_TLS_ENABLED" ;
77
76
private final static String CORE_PEER_TLS_SERVERHOSTOVERRIDE = "CORE_PEER_TLS_SERVERHOSTOVERRIDE" ;
78
77
private static final String CORE_PEER_TLS_ROOTCERT_FILE = "CORE_PEER_TLS_ROOTCERT_FILE" ;
79
78
80
- // Start entry point for chaincodes bootstrap.
81
- public void start (String [] args ) {
82
- processEnvironmentOptions ();
83
- processCommandLineOptions (args );
84
- new Thread (() -> {
85
- logger .trace ("chaincode started" );
86
- final ManagedChannel connection = newPeerClientConnection ();
87
- logger .trace ("connection created" );
88
- chatWithPeer (connection );
89
- logger .trace ("chatWithPeer DONE" );
90
- }).start ();
91
- }
79
+ /**
80
+ * Start chaincode
81
+ * @param args command line arguments
82
+ */
83
+ public void start (String [] args ) {
84
+ processEnvironmentOptions ();
85
+ processCommandLineOptions (args );
86
+ if (this .id == null ) {
87
+ logger .error (String .format ("The chaincode id must be specified using either the -i or --i command line options or the %s environment variable." , CORE_CHAINCODE_ID_NAME ));
88
+ }
89
+ new Thread (() -> {
90
+ logger .trace ("chaincode started" );
91
+ final ManagedChannel connection = newPeerClientConnection ();
92
+ logger .trace ("connection created" );
93
+ chatWithPeer (connection );
94
+ logger .trace ("chatWithPeer DONE" );
95
+ }).start ();
96
+ }
92
97
93
98
private void processCommandLineOptions (String [] args ) {
94
99
Options options = new Options ();
0 commit comments