From 57aa6c0809bfe4657ac7a8eaf81d985843e4bb39 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 28 Mar 2017 11:55:57 -0400 Subject: [PATCH] add log warning about using default creds file --- app.js | 18 +++++++++ config/blockchain_creds1.json | 13 +++---- config/blockchain_creds2.json | 69 +++++++++++++++++------------------ utils/helper.js | 5 +++ 4 files changed, 63 insertions(+), 42 deletions(-) diff --git a/app.js b/app.js index 04ec936f5..0c2de151e 100644 --- a/app.js +++ b/app.js @@ -105,6 +105,24 @@ console.log('------------------------------------------ Server Up - ' + host + ' if (process.env.PRODUCTION) logger.debug('Running using Production settings'); else logger.debug('Running using Developer settings'); +if(helper.getNetworkId() === 'FakeNetworkId') { + console.log('\n\n'); + logger.warn('----------------------------------------------------------------------'); + logger.warn('----------------------------- Hey Buddy! -----------------------------'); + logger.warn('------------------------ It looks like you did -----------------------'); + logger.error('------------------------------- not --------------------------------'); + logger.warn('------------------------- follow my instructions ---------------------'); + logger.warn('----------------------------------------------------------------------'); + logger.warn('Your network config JSON has a network ID of "FakeNetworkID"...'); + logger.warn('You likely have other settings that are wrong too!'); + logger.warn('----------------------------------------------------------------------'); + logger.error('Fix this file: ' + helper.getNetworkCredFileName()); + logger.warn('It must have credentials/hostnames/ports/channels/etc for YOUR network'); + logger.warn('How/where would I get that info? Using the Bluemix service? Then look at these instructions(near the end): '); + logger.warn(' https://github.com/IBM-Blockchain/marbles/blob/v3.0/docs/install_chaincode.md'); + logger.warn('----------------------------------------------------------------------'); + console.log('\n\n'); +} // ============================================================================================================================ // Warning diff --git a/config/blockchain_creds1.json b/config/blockchain_creds1.json index 131be8510..e1cca8975 100644 --- a/config/blockchain_creds1.json +++ b/config/blockchain_creds1.json @@ -1,16 +1,15 @@ { "credentials": { - "network_id": "test", - "network_name": "Marbles Tutorial", + "network_id": "FakeNetworkId", "orderers": [ { - "discovery": "grpc://varadvm2.rtp.raleigh.ibm.com:7050", + "discovery": "grpc://localhost:7050", "msp_id": "Org1MSP" } ], "cas": [ { - "api": "http://varadvm2.rtp.raleigh.ibm.com:7054", + "api": "http://localhost:7054", "msp_id": "Org1MSP", "users": [ { @@ -23,8 +22,8 @@ "peers": [ { "name": "fabric-peer-1a", - "discovery": "grpc://varadvm2.rtp.raleigh.ibm.com:7051", - "events": "grpc://varadvm2.rtp.raleigh.ibm.com:7053", + "discovery": "grpc://localhost:7051", + "events": "grpc://localhost:7053", "msp_id": "Org1MSP" } ], @@ -32,7 +31,7 @@ "channel_id": "mychannel", "chaincode_id": "marbles", "chaincode_version": "v0", - "block_delay": 1000 + "block_delay": 1000 } } } \ No newline at end of file diff --git a/config/blockchain_creds2.json b/config/blockchain_creds2.json index 131be8510..48e04d377 100644 --- a/config/blockchain_creds2.json +++ b/config/blockchain_creds2.json @@ -1,38 +1,37 @@ { - "credentials": { - "network_id": "test", - "network_name": "Marbles Tutorial", - "orderers": [ - { - "discovery": "grpc://varadvm2.rtp.raleigh.ibm.com:7050", - "msp_id": "Org1MSP" - } - ], - "cas": [ - { - "api": "http://varadvm2.rtp.raleigh.ibm.com:7054", - "msp_id": "Org1MSP", - "users": [ - { - "enrollId": "admin", - "enrollSecret": "adminpw" - } - ] - } - ], - "peers": [ - { - "name": "fabric-peer-1a", - "discovery": "grpc://varadvm2.rtp.raleigh.ibm.com:7051", - "events": "grpc://varadvm2.rtp.raleigh.ibm.com:7053", - "msp_id": "Org1MSP" - } - ], - "app": { - "channel_id": "mychannel", - "chaincode_id": "marbles", - "chaincode_version": "v0", + "credentials": { + "network_id": "FakeNetworkId", + "orderers": [ + { + "discovery": "grpc://localhost:7050", + "msp_id": "Org1MSP" + } + ], + "cas": [ + { + "api": "http://localhost:8054", + "msp_id": "Org1MSP", + "users": [ + { + "enrollId": "admin2", + "enrollSecret": "adminpw2" + } + ] + } + ], + "peers": [ + { + "name": "fabric-peer-2a", + "discovery": "grpc://localhost:8051", + "events": "grpc://localhost:8053", + "msp_id": "Org1MSP" + } + ], + "app": { + "channel_id": "mychannel", + "chaincode_id": "marbles", + "chaincode_version": "v0", "block_delay": 1000 - } - } + } + } } \ No newline at end of file diff --git a/utils/helper.js b/utils/helper.js index 26549c226..17a96f9a2 100644 --- a/utils/helper.js +++ b/utils/helper.js @@ -31,6 +31,11 @@ module.exports = function (config_filename, logger) { return helper.creds.credentials.network_id; }; + // get cred file name + helper.getNetworkCredFileName = function () { + return helper.config.cred_filename; + }; + // get a peer's grpc url helper.getPeersUrl = function (index) { if (index === undefined || index == null) {