From 73f011225b93e9d8cb5a598bd78c35563317da58 Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Sun, 11 Jun 2017 15:16:36 -0400 Subject: [PATCH 01/15] Update to beta for fabric-client and fabric-ca-client --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d328b0b..0930c5c 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,8 @@ "debug": "^2.2.0", "express": "^4.13.4", "express-session": "^1.15.1", - "fabric-ca-client": "1.0.0-alpha2", - "fabric-client": "1.0.0-alpha2", + "fabric-ca-client": "1.0.0-beta", + "fabric-client": "1.0.0-beta", "grpc": ">=1.1.2 <1.3.0", "js-sha256": "^0.5.0", "morgan": "^1.7.0", From 96101086c8526a0b5619393fec7f9975f0b1550a Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Sun, 11 Jun 2017 15:39:07 -0400 Subject: [PATCH 02/15] Update to the beta images in docker-compose --- test/fixtures-V1/docker-compose-template.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/fixtures-V1/docker-compose-template.yaml b/test/fixtures-V1/docker-compose-template.yaml index ba1a1bc..446c4c8 100644 --- a/test/fixtures-V1/docker-compose-template.yaml +++ b/test/fixtures-V1/docker-compose-template.yaml @@ -2,7 +2,7 @@ version: '2' services: ca.blocledger.com: - image: hyperledger/fabric-ca:x86_64-1.0.0-alpha2 + image: hyperledger/fabric-ca:x86_64-1.0.0-beta environment: - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server - FABRIC_CA_SERVER_TLS_ENABLED=true @@ -19,7 +19,7 @@ services: orderer.blocledger.com: container_name: orderer.blocledger.com - image: hyperledger/fabric-orderer:x86_64-1.0.0-alpha2 + image: hyperledger/fabric-orderer:x86_64-1.0.0-beta environment: - ORDERER_GENERAL_LOGLEVEL=debug - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 @@ -45,7 +45,7 @@ services: peer0.org1.blocledger.com: container_name: peer0.org1.blocledger.com - image: hyperledger/fabric-peer:x86_64-1.0.0-alpha2 + image: hyperledger/fabric-peer:x86_64-1.0.0-beta environment: - CORE_PEER_ID=peer0.org1.blocledger.com - CORE_PEER_ADDRESS=peer0.org1.blocledger.com:7051 @@ -83,7 +83,7 @@ services: peer1.org1.blocledger.com: container_name: peer1.org1.blocledger.com - image: hyperledger/fabric-peer:x86_64-1.0.0-alpha2 + image: hyperledger/fabric-peer:x86_64-1.0.0-beta environment: - CORE_PEER_ID=peer1.org1.blocledger.com - CORE_PEER_ADDRESS=peer1.org1.blocledger.com:7051 From 53a2c32fa788178d213b9307d3573bfa9c928bd0 Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Sun, 11 Jun 2017 16:23:39 -0400 Subject: [PATCH 03/15] Change to the new cryptoSuite config --- createChannel.js | 4 +++- initialize.js | 4 +++- util.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/createChannel.js b/createChannel.js index 502b23c..c12c680 100644 --- a/createChannel.js +++ b/createChannel.js @@ -47,7 +47,9 @@ let opts = {path: config.keyPath}; debug(opts); debug('============================================================='); -var cryptoSuite = client.newCryptoSuite(opts); +var cryptoSuite = HFC.newCryptoSuite(); +cryptoSuite.setCryptoKeyStore(HFC.newCryptoKeyStore(opts)); +client.setCryptoSuite(cryptoSuite); debug(cryptoSuite); debug('============================================================='); var ca = new FabricCAServices(cred.cas[0].api_url, tlsOptions, '', cryptoSuite); // Create a new CA diff --git a/initialize.js b/initialize.js index 122ced9..031118b 100644 --- a/initialize.js +++ b/initialize.js @@ -48,7 +48,9 @@ var tlsOptions = { debug('ca tls cert', cred.cas[0].tls_cacerts); -var cryptoSuite = client.newCryptoSuite({path: config.keyPath}); +var cryptoSuite = HFC.newCryptoSuite(); +cryptoSuite.setCryptoKeyStore(HFC.newCryptoKeyStore({path: config.keyPath})); +client.setCryptoSuite(cryptoSuite); // It may not be necessary to set the cryptoSuite here var ca = new FabricCAServices(cred.cas[0].api_url, tlsOptions, '', cryptoSuite); var admin; var member; diff --git a/util.js b/util.js index 1f228c2..2325998 100644 --- a/util.js +++ b/util.js @@ -22,6 +22,7 @@ var util = require('util'); var config = require('./configuration.js'); var User = require('fabric-client/lib/User.js'); +var HFC = require('fabric-client'); var init = require('./initialize.js'); // jscs:disable requireCamelCaseOrUpperCaseIdentifiers @@ -68,7 +69,8 @@ function newUser(appUser) { debug('user enrollment ', enrollment); user = new User(appUser.userName, client); - var cryptoSuite = client.newCryptoSuite({path: config.keyPath}); + var cryptoSuite = HFC.newCryptoSuite(); + cryptoSuite.setCryptoKeyStore(HFC.newCryptoKeyStore({path: config.keyPath})); user.setCryptoSuite(cryptoSuite); return user.setEnrollment(enrollment.key, enrollment.certificate, mspid); }) From 6b86b3398fe9b430cbec9e9010eb016d85bfa3f2 Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Sun, 11 Jun 2017 16:43:00 -0400 Subject: [PATCH 04/15] Use the new client.newTransactionID call --- createChannel.js | 14 ++++---------- sdkInterface.js | 16 ++++------------ 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/createChannel.js b/createChannel.js index c12c680..8ee1d96 100644 --- a/createChannel.js +++ b/createChannel.js @@ -190,9 +190,8 @@ HFC.newDefaultKeyValueStore({ var signatures = []; signatures.push(signature); signatures.push(signature); // this second signature is from the sdk test code. Appears to work around a problem somewhere - let nonce = utils.getNonce(); - let txId = HFC.buildTransactionID(nonce, peerorg1Admin); - ehtxid = txId.toString(); + let txId = client.newTransactionID(); + ehtxid = txId.getTransactionID(); // jscs:disable requireCamelCaseOrUpperCaseIdentifiers // set up the event hub @@ -237,7 +236,6 @@ HFC.newDefaultKeyValueStore({ config: channelConfig, signatures: signatures, txId: txId, - nonce: nonce }; debug('============ calling createChannel ====================='); @@ -293,11 +291,9 @@ HFC.newDefaultKeyValueStore({ debug('finished enrolling orderer admin'); debug(admin); - let nonce = utils.getNonce(); - let txId = HFC.buildTransactionID(nonce, admin); + let txId = client.newTransactionID(); let request = { txId: txId, - nonce: nonce }; return chain.getGenesisBlock(request); }) @@ -310,13 +306,11 @@ HFC.newDefaultKeyValueStore({ // join the peers to the channel debug('join the peers to the channel'); - let nonce = utils.getNonce(); - let txId = HFC.buildTransactionID(nonce, user); + let txId = client.newTransactionID(); var request = { targets: targets, block: genisisBlock, txId: txId, - nonce: nonce }; return chain.joinChannel(request); }) diff --git a/sdkInterface.js b/sdkInterface.js index 389f644..67434ad 100644 --- a/sdkInterface.js +++ b/sdkInterface.js @@ -52,8 +52,7 @@ function deploy(req, res) { debug('set the client user context'); debug(user); - let nonce = utils.getNonce(); - let txId = hfc.buildTransactionID(nonce, deployUser); + let txId = client.newTransactionID(); // send proposal to endorser let request = { @@ -62,7 +61,6 @@ function deploy(req, res) { chaincodeId: ccName, chaincodeVersion: ccVersion, txId: txId, - nonce: nonce }; debug('install chaincode request'); debug(request); @@ -88,8 +86,7 @@ function deploy(req, res) { .then(function(results) { console.log('chain initialize result ', results); - let nonce = utils.getNonce(); - let txId = hfc.buildTransactionID(nonce, deployUser); + let txId = client.newTransactionID(); // send proposal to endorser let request = { @@ -101,7 +98,6 @@ function deploy(req, res) { args: [], chainId: config.channelId, txId: txId, - nonce: nonce }; debug('====== Instantiate Proposal request ==========='); debug(request); @@ -179,8 +175,7 @@ function sdkInvoke(user, invokeRequest) { eventhub.connect(); // jscs:enable requireCamelCaseOrUpperCaseIdentifiers - let nonce = utils.getNonce(); - let txId = hfc.buildTransactionID(nonce, user); + let txId = client.newTransactionID(); ehtxid = txId.toString(); // debug('the user context is ', client.getUserContext()); let ccID = {}; @@ -194,7 +189,6 @@ function sdkInvoke(user, invokeRequest) { args: invokeRequest.args, chainId: config.channelId, txId: txId, - nonce: nonce }; debug(request); return chain.sendTransactionProposal(request); @@ -290,8 +284,7 @@ function sdkQuery(user, queryRequest, maxRetries) { return client.setUserContext(user, true) .then(function(user) { - let nonce = utils.getNonce(); - let txId = hfc.buildTransactionID(nonce, user); + let txId = client.newTransactionID(); let ccID = {}; ccID = queryRequest.chaincodeID; @@ -304,7 +297,6 @@ function sdkQuery(user, queryRequest, maxRetries) { args: queryRequest.args, chainId: config.channelId, txId: txId, - nonce: nonce }; debug(request); return chain.queryByChaincode(request); From 78b05bf917ce0321b79ee59ad0eb247b9dbf23f1 Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Sun, 11 Jun 2017 16:51:36 -0400 Subject: [PATCH 05/15] Change newChain to newChannel --- createChannel.js | 4 ++-- initialize.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/createChannel.js b/createChannel.js index 8ee1d96..ba36c1e 100644 --- a/createChannel.js +++ b/createChannel.js @@ -246,7 +246,7 @@ HFC.newDefaultKeyValueStore({ debug('Channel created ', result); if (!config.windows) {eventhub.disconnect();} - chain = client.newChain('mychannel'); + chain = client.newChannel(config.channelId); chain.addOrderer(orderer); // see if the channel has been created @@ -261,7 +261,7 @@ HFC.newDefaultKeyValueStore({ debug(err); if (!config.windows) {eventhub.disconnect();} - chain = client.newChain('mychannel'); + chain = client.newChannel(config.channelId); chain.addOrderer(orderer); debug('----------calling getChannelConfig after createChannel fails -----------'); return chain.getChannelConfig(); diff --git a/initialize.js b/initialize.js index 031118b..020bdbf 100644 --- a/initialize.js +++ b/initialize.js @@ -38,7 +38,7 @@ var cred = config.cred; // Configuration file for the test network from the fab var client = new HFC(); // jscs:disable requireCamelCaseOrUpperCaseIdentifiers -var chain = client.newChain(config.channelId); +var chain = client.newChannel(config.channelId); var targets = []; var tlsOptions = { From 8a62f2bd381d2b9a86eefa3dfc2248991030b3db Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Sun, 11 Jun 2017 18:18:08 -0400 Subject: [PATCH 06/15] Stop using getPrimaryPeer --- sdkInterface.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sdkInterface.js b/sdkInterface.js index 67434ad..401cf2c 100644 --- a/sdkInterface.js +++ b/sdkInterface.js @@ -44,7 +44,7 @@ function deploy(req, res) { var cred = init.cred; var targets = chain.getPeers(); var store = client.getStateStore(); - debug('primary peer is ', chain.getPrimaryPeer()); + debug('The first peer is ', targets[0]); client.getUserContext('peerorg1Admin', true) .then(function(user) { @@ -278,7 +278,6 @@ function retrySdkInvoke(user, invokeRequest, maxRetries) { function sdkQuery(user, queryRequest, maxRetries) { var client = init.client; var chain = init.chain; - var target = chain.getPrimaryPeer(); var store = client.getStateStore(); return client.setUserContext(user, true) @@ -290,7 +289,7 @@ function sdkQuery(user, queryRequest, maxRetries) { ccID = queryRequest.chaincodeID; let request = { - targets: target, + targets: targets[0], chaincodeId: ccID.chaincodeId, chaincodeVersion: ccID.chaincodeVersion, fcn: queryRequest.fcn, From 7f00af479cbac26046bb45bdd2b8c0a4a9e169d0 Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Sun, 11 Jun 2017 19:45:46 -0400 Subject: [PATCH 07/15] Switch from admin to peerorg1Admin for queryChannels --- initialize.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/initialize.js b/initialize.js index 020bdbf..062e45d 100644 --- a/initialize.js +++ b/initialize.js @@ -185,11 +185,13 @@ HFC.newDefaultKeyValueStore({ debug('Finished initializing users'); debug(results); - return client.setUserContext(member); + return client.getUserContext('peerorg1Admin', true); }) -.then(function() { +.then(function(user) { debug('Channel information ---------------------'); + debug('User name ', user.getName()); + debug(user.getIdentity()); let promises = []; targets.forEach(function(target) { promises.push(client.queryChannels(target)); From 824959bdf6fe2cc97e9d076f5a03162b286b57d0 Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Sun, 11 Jun 2017 20:16:46 -0400 Subject: [PATCH 08/15] Remove txId and chaincodeVersion from query call --- sdkInterface.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sdkInterface.js b/sdkInterface.js index 401cf2c..c063967 100644 --- a/sdkInterface.js +++ b/sdkInterface.js @@ -279,11 +279,11 @@ function sdkQuery(user, queryRequest, maxRetries) { var client = init.client; var chain = init.chain; var store = client.getStateStore(); + var targets = chain.getPeers(); return client.setUserContext(user, true) .then(function(user) { - let txId = client.newTransactionID(); let ccID = {}; ccID = queryRequest.chaincodeID; @@ -291,11 +291,9 @@ function sdkQuery(user, queryRequest, maxRetries) { let request = { targets: targets[0], chaincodeId: ccID.chaincodeId, - chaincodeVersion: ccID.chaincodeVersion, fcn: queryRequest.fcn, args: queryRequest.args, - chainId: config.channelId, - txId: txId, + channelId: config.channelId, }; debug(request); return chain.queryByChaincode(request); From b7f86e4a4a98b7e5d5a26a022cb8fd6a101195d5 Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Mon, 12 Jun 2017 19:19:04 -0400 Subject: [PATCH 09/15] Fix the eventhub notification Switch from toString to getTransactionID --- sdkInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkInterface.js b/sdkInterface.js index c063967..e8d004d 100644 --- a/sdkInterface.js +++ b/sdkInterface.js @@ -176,7 +176,7 @@ function sdkInvoke(user, invokeRequest) { // jscs:enable requireCamelCaseOrUpperCaseIdentifiers let txId = client.newTransactionID(); - ehtxid = txId.toString(); + ehtxid = txId.getTransactionID(); // debug('the user context is ', client.getUserContext()); let ccID = {}; debug(invokeRequest); From 929104be53d7cad34f17916f36724a8b99489818 Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Tue, 13 Jun 2017 18:19:50 -0400 Subject: [PATCH 10/15] Remove txId from installChaincode --- sdkInterface.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/sdkInterface.js b/sdkInterface.js index e8d004d..6b32d87 100644 --- a/sdkInterface.js +++ b/sdkInterface.js @@ -52,15 +52,12 @@ function deploy(req, res) { debug('set the client user context'); debug(user); - let txId = client.newTransactionID(); - // send proposal to endorser let request = { targets: targets, chaincodePath: chaincodePath, chaincodeId: ccName, chaincodeVersion: ccVersion, - txId: txId, }; debug('install chaincode request'); debug(request); From d81db540e894f4431b85409123aa30139bf30ecb Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Thu, 15 Jun 2017 09:24:50 -0400 Subject: [PATCH 11/15] Remove duplicate signature for the createChannel --- createChannel.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/createChannel.js b/createChannel.js index ba36c1e..62f58a6 100644 --- a/createChannel.js +++ b/createChannel.js @@ -189,7 +189,6 @@ HFC.newDefaultKeyValueStore({ var signature = client.signChannelConfig(channelConfig); var signatures = []; signatures.push(signature); - signatures.push(signature); // this second signature is from the sdk test code. Appears to work around a problem somewhere let txId = client.newTransactionID(); ehtxid = txId.getTransactionID(); @@ -231,7 +230,7 @@ HFC.newDefaultKeyValueStore({ // Create the new form for request... request = { - name: 'mychannel', + name: config.channelId, orderer: orderer, config: channelConfig, signatures: signatures, From 681c2b3817b9c5d880950c53e04c9581f438ca6d Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Thu, 15 Jun 2017 09:56:01 -0400 Subject: [PATCH 12/15] Remove unused parameters from sendInstantiateProposal The chaincodePath and chainID parameters were removed from the request --- sdkInterface.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdkInterface.js b/sdkInterface.js index 6b32d87..ff1d7e5 100644 --- a/sdkInterface.js +++ b/sdkInterface.js @@ -88,12 +88,10 @@ function deploy(req, res) { // send proposal to endorser let request = { targets: targets, - chaincodePath: chaincodePath, chaincodeId: ccName, chaincodeVersion: ccVersion, fcn: 'init', args: [], - chainId: config.channelId, txId: txId, }; debug('====== Instantiate Proposal request ==========='); From ef29562f671de9c49a55120cad2be7003ff723f0 Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Thu, 15 Jun 2017 13:05:47 -0400 Subject: [PATCH 13/15] Remove the windows eventhub workaround The hashtable package that was giving Windows problems has been removed from fabric-client so we can now call eventhub unregister and disconnect without crashing node. --- createChannel.js | 8 ++++---- sdkInterface.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/createChannel.js b/createChannel.js index 62f58a6..27db2f9 100644 --- a/createChannel.js +++ b/createChannel.js @@ -208,7 +208,7 @@ HFC.newDefaultKeyValueStore({ let ehPromise = new Promise(function(resolve, reject) { let handle = setTimeout(function() { - if (!config.windows) {eventhub.unregisterTxEvent(ehtxid);} + eventhub.unregisterTxEvent(ehtxid); reject(new Error('Event hub timed out.')); }, 10000); debug('registering for the Tx event'); @@ -216,7 +216,7 @@ HFC.newDefaultKeyValueStore({ // Setup event hug to listen for results eventhub.registerTxEvent(ehtxid, function(txid, code) { clearTimeout(handle); - if (!config.windows) {eventhub.unregisterTxEvent(txid);} + eventhub.unregisterTxEvent(txid); if (code !== 'VALID') { debug('Transaction failed event hub reported:', code); @@ -243,7 +243,7 @@ HFC.newDefaultKeyValueStore({ .then(function(result) { debug('--------------------------------------------'); debug('Channel created ', result); - if (!config.windows) {eventhub.disconnect();} + eventhub.disconnect(); chain = client.newChannel(config.channelId); chain.addOrderer(orderer); @@ -258,7 +258,7 @@ HFC.newDefaultKeyValueStore({ }, function(err) { debug('Error creating channel, maybe it is already created, try building it'); debug(err); - if (!config.windows) {eventhub.disconnect();} + eventhub.disconnect(); chain = client.newChannel(config.channelId); chain.addOrderer(orderer); diff --git a/sdkInterface.js b/sdkInterface.js index ff1d7e5..afecb9d 100644 --- a/sdkInterface.js +++ b/sdkInterface.js @@ -205,14 +205,14 @@ function sdkInvoke(user, invokeRequest) { let ehPromise = new Promise(function(resolve, reject) { let handle = setTimeout(function() { - if (!config.windows) {eventhub.unregisterTxEvent(ehtxid);} + eventhub.unregisterTxEvent(ehtxid); reject(new Error('Event hub timed out.')); }, 30000); debug('registering for the Tx event'); eventhub.registerTxEvent(ehtxid, function(txid, code) { clearTimeout(handle); - if (!config.windows) {eventhub.unregisterTxEvent(txid);} + eventhub.unregisterTxEvent(txid); if (code !== 'VALID') { debug('Transaction failed event hub reported:', code); @@ -240,13 +240,13 @@ function sdkInvoke(user, invokeRequest) { return Q.reject(results[i].reason); } } - if (!config.windows) {eventhub.disconnect();} + eventhub.disconnect(); return Q.resolve(results); }) .catch(function(err) { debug('====== invoke failed ==========='); debug(err); - if (!config.windows) {eventhub.disconnect();} + eventhub.disconnect(); return Q.reject(err); }); } From 4c799939a66465fa6016d0ebf216ae1ca1e2469b Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Thu, 15 Jun 2017 13:57:37 -0400 Subject: [PATCH 14/15] Change names from chain to channel --- api.js | 3 +-- createChannel.js | 24 ++++++++++++------------ initialize.js | 12 ++++++------ sdkInterface.js | 26 +++++++++++++------------- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/api.js b/api.js index 7fe3a92..d8f990f 100644 --- a/api.js +++ b/api.js @@ -59,7 +59,6 @@ debug(process.env.GOPATH); var confidentialSetting = config.confidentialSetting; // Store the exports from initialize.js in global variables -var chain = init.chain; var GlobalAppUser = init.GlobalAppUser; var cred = config.cred; @@ -116,7 +115,7 @@ app.get('/chain/transactions/:id', function(req, res) { init.client.setUserContext(appUser.hfcUser, true) .then(function(user) { console.log('user is ', user.getName()); - return init.chain.queryTransaction(req.params.id); + return init.channel.queryTransaction(req.params.id); }) .then(function(result) { debug(result); diff --git a/createChannel.js b/createChannel.js index 27db2f9..0ea0b31 100644 --- a/createChannel.js +++ b/createChannel.js @@ -54,7 +54,7 @@ debug(cryptoSuite); debug('============================================================='); var ca = new FabricCAServices(cred.cas[0].api_url, tlsOptions, '', cryptoSuite); // Create a new CA var targets = []; -var chain = {}; +var channel = {}; var eventhub; var ehtxid; @@ -245,25 +245,25 @@ HFC.newDefaultKeyValueStore({ debug('Channel created ', result); eventhub.disconnect(); - chain = client.newChannel(config.channelId); - chain.addOrderer(orderer); + channel = client.newChannel(config.channelId); + channel.addOrderer(orderer); // see if the channel has been created - debug(chain); - debug('chain name', chain.getName()); - debug('orderers', chain.getOrderers()); + debug(channel); + debug('channel name', channel.getName()); + debug('orderers', channel.getOrderers()); debug('----------calling getChannelConfig after createChannel succeeded -----------'); - return chain.getChannelConfig(); + return channel.getChannelConfig(); }, function(err) { debug('Error creating channel, maybe it is already created, try building it'); debug(err); eventhub.disconnect(); - chain = client.newChannel(config.channelId); - chain.addOrderer(orderer); + channel = client.newChannel(config.channelId); + channel.addOrderer(orderer); debug('----------calling getChannelConfig after createChannel fails -----------'); - return chain.getChannelConfig(); + return channel.getChannelConfig(); }) .then(function(result) { debug('channel config', result); @@ -294,7 +294,7 @@ HFC.newDefaultKeyValueStore({ let request = { txId: txId, }; - return chain.getGenesisBlock(request); + return channel.getGenesisBlock(request); }) .then(function(block) { genisisBlock = block; @@ -311,7 +311,7 @@ HFC.newDefaultKeyValueStore({ block: genisisBlock, txId: txId, }; - return chain.joinChannel(request); + return channel.joinChannel(request); }) .then(function(result) { debug('-------- join channel results ---------'); diff --git a/initialize.js b/initialize.js index 062e45d..0274b1d 100644 --- a/initialize.js +++ b/initialize.js @@ -38,7 +38,7 @@ var cred = config.cred; // Configuration file for the test network from the fab var client = new HFC(); // jscs:disable requireCamelCaseOrUpperCaseIdentifiers -var chain = client.newChannel(config.channelId); +var channel = client.newChannel(config.channelId); var targets = []; var tlsOptions = { @@ -69,7 +69,7 @@ for (var i = 0; i < cred.peers.length; i++) { } for (var i = 0; i < peerList.length; i++) { targets.push(peerList[i]); - chain.addPeer(peerList[i]); + channel.addPeer(peerList[i]); } // Add orderer @@ -80,7 +80,7 @@ var orderer = client.newOrderer( 'ssl-target-name-override': cred.orderers[0].common_name } ); -chain.addOrderer(orderer); +channel.addOrderer(orderer); // Configure the KeyValStore which is used to store sensitive keys // check that the ./tmp directory existsSync @@ -205,8 +205,8 @@ HFC.newDefaultKeyValueStore({ }); debug('-----------------------------------------'); - debug('calling chain initialize'); - return chain.initialize(); + debug('calling channel initialize'); + return channel.initialize(); }) .then(function(result) { debug('initialize success', result); @@ -228,7 +228,7 @@ HFC.newDefaultKeyValueStore({ debug('Failed registration or initialization', err); }); -exports.chain = chain; +exports.channel = channel; exports.GlobalAppUser = GlobalAppUser; exports.poeChaincode = poeChaincode; exports.setPoeChaincode = setPoeChaincode; diff --git a/sdkInterface.js b/sdkInterface.js index afecb9d..a66ca5e 100644 --- a/sdkInterface.js +++ b/sdkInterface.js @@ -40,9 +40,9 @@ function deploy(req, res) { var ccName = 'poe' + '-' + Math.floor(Math.random() * 1000); var deployUser; var client = init.client; - var chain = init.chain; + var channel = init.channel; var cred = init.cred; - var targets = chain.getPeers(); + var targets = channel.getPeers(); var store = client.getStateStore(); debug('The first peer is ', targets[0]); @@ -78,10 +78,10 @@ function deploy(req, res) { } } - return chain.initialize(); + return channel.initialize(); }) .then(function(results) { - console.log('chain initialize result ', results); + console.log('channel initialize result ', results); let txId = client.newTransactionID(); @@ -96,7 +96,7 @@ function deploy(req, res) { }; debug('====== Instantiate Proposal request ==========='); debug(request); - return chain.sendInstantiateProposal(request); + return channel.sendInstantiateProposal(request); }) .then(function(results) { let proposalResponses = results[0]; @@ -114,7 +114,7 @@ function deploy(req, res) { proposal: proposal, header: header }; - return chain.sendTransaction(request); + return channel.sendTransaction(request); }) .then(function(results) { debug('====== sendTransaction results ==========='); @@ -145,11 +145,11 @@ function deploy(req, res) { // create a promise for the chaincode Invoke so it can be easily retried function sdkInvoke(user, invokeRequest) { var client = init.client; - var chain = init.chain; + var channel = init.channel; var cred = init.cred; var eventhub; var ehtxid; - var targets = chain.getPeers(); + var targets = channel.getPeers(); var store = client.getStateStore(); debug(invokeRequest); @@ -186,7 +186,7 @@ function sdkInvoke(user, invokeRequest) { txId: txId, }; debug(request); - return chain.sendTransactionProposal(request); + return channel.sendTransactionProposal(request); }) .then(function(results) { let proposalResponses = results[0]; @@ -230,7 +230,7 @@ function sdkInvoke(user, invokeRequest) { header: header }; debug('====== sending transaction ========='); - return Q.allSettled([chain.sendTransaction(request), ehPromise]); + return Q.allSettled([channel.sendTransaction(request), ehPromise]); }) .then(function(results) { debug('====== sendTransaction results ==========='); @@ -272,9 +272,9 @@ function retrySdkInvoke(user, invokeRequest, maxRetries) { // create a promise for the chaincode query so it can be easily retried function sdkQuery(user, queryRequest, maxRetries) { var client = init.client; - var chain = init.chain; + var channel = init.channel; var store = client.getStateStore(); - var targets = chain.getPeers(); + var targets = channel.getPeers(); return client.setUserContext(user, true) .then(function(user) { @@ -291,7 +291,7 @@ function sdkQuery(user, queryRequest, maxRetries) { channelId: config.channelId, }; debug(request); - return chain.queryByChaincode(request); + return channel.queryByChaincode(request); }) .then(function(results) { debug('====== queryByChaincode results =========='); From d5cdd28e4c24a10802ffa7cede0dd2fa784c7bec Mon Sep 17 00:00:00 2001 From: ericmvaughn Date: Thu, 15 Jun 2017 14:06:11 -0400 Subject: [PATCH 15/15] Update the README file --- README.md | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 2186d99..fa6f1b2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ hash so that its existence can be later proved through transaction queries. * node - v6.9.5 * Git client * Windows needs OpenSSL installed into C:/OpenSSL-Win64 - * Goto https://slproweb.com/products/Win32OpenSSL.html and pick the full Win64 package + * Goto https://slproweb.com/products/Win32OpenSSL.html and pick the full Win64 package ## Installation @@ -24,17 +24,6 @@ npm install -g bower npm install ``` -> **Windows note:** To avoid a problem with the windows style '\\' during -> the chaincode install resulting in the error: -> -> `Promise is rejected: Error: Illegal file detected in payload: "src\github.com\chaincode\poe_chaincode.go"` -> -> per FAB-3975, -> add `.split('\\').join('/')` to the end of line 98 of -> node_modules/fabric-client/lib/packager/Golang.js like this: -> -> `name: path.relative(goPath, entry.path).split('\\').join('/'),` - ## Setting up a test blockchain using Docker A Hyperledger Fabric blockchain network can be run on your local machine @@ -48,7 +37,7 @@ The instructions below assume that you already have docker installed and running Pull the fabric chaincode environment image using the x86_64-1.0.0-alpha tag. ``` -docker pull hyperledger/fabric-ccenv:x86_64-1.0.0-alpha2 +docker pull hyperledger/fabric-ccenv:x86_64-1.0.0-beta ``` Next give the fabric-ccenv the 'latest' tag so that software can use it. Replace the image ID (4ac07a26ca7a) in the example command with the image ID