Skip to content

Commit

Permalink
change how creds work
Browse files Browse the repository at this point in the history
  • Loading branch information
dshuffma-ibm committed Mar 19, 2017
1 parent 752b4ce commit 2bcee37
Show file tree
Hide file tree
Showing 14 changed files with 174 additions and 114 deletions.
37 changes: 37 additions & 0 deletions config/blockchain_creds1.json
Original file line number Diff line number Diff line change
@@ -0,0 +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"
}
}
}
File renamed without changes.
11 changes: 11 additions & 0 deletions config/marbles1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"cred_filename": "blockchain_creds3.json",
"company": "United Marbles",
"usernames": [
"amy",
"alice",
"ava"
],
"port": 3001,
"last_startup_hash": "a6b69ade1e3529ae79a3093a7ecd53f687565839"
}
11 changes: 11 additions & 0 deletions config/marbles2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"credentials": "marbles2.json",
"company": "eMarbles",
"usernames": [
"cliff",
"cody",
"chuck"
],
"port": 3002,
"last_startup_hash": "380c2263aab82a818586b5abaaf96dfd1cdd25be"
}
41 changes: 0 additions & 41 deletions config/mycreds1.json

This file was deleted.

4 changes: 2 additions & 2 deletions docker-compose/marbles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
ports:
- 3000:3000
volumes:
- ${CREDS_LOCATION}/creds_united_marbles.json:/app/mycreds.json
- ${CREDS_LOCATION}/blockchain_creds1.json:/app/marbles1.json
- ${CREDS_LOCATION}/keyValStore-1:/app/keyValStore-asdf
container_name: united_marbles
entrypoint: gulp united_marbles
Expand All @@ -35,7 +35,7 @@ services:
ports:
- 3001:3000
volumes:
- ${CREDS_LOCATION}/creds_marble_market.json:/app/mycreds.json
- ${CREDS_LOCATION}/blockchain_creds2.json:/app/marbles2.json
- ${CREDS_LOCATION}/keyValStore-2:/app/keyValStore-asdf
container_name: marble_market
entrypoint: gulp marble_market
Expand Down
6 changes: 3 additions & 3 deletions docs/host_marbles_locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Lets do the very last setup for marbles.

1. Next the settuping up panel should pop up. Ideally it will walk itself through the 3 stages of initial setup.
1. Enroll Admin - this step is communicating with your network's CA to verify the admin user credentails (enrollID/enrollSecret)
- if it fails double check the enrollID and enrollSecret fields in your `mycreds.json` file
1. Finding Chaincode - this step is looking for the marbles chaincode on your peer. It is using the chaincode ID found in your `mycreds.json` file. If this is a brand new network it will not exist yet. Simply click the "Deploy" button.
- if it fails double check the enrollID and enrollSecret fields in your `blockchain_creds1.json` file
1. Finding Chaincode - this step is looking for the marbles chaincode on your peer. It is using the chaincode ID found in your `blockchain_creds1.json` file. If this is a brand new network it will not exist yet. Simply click the "Deploy" button.
- if the chaincode was deployed but it was unable to find it try the "Retry" button.
1. Register Marble Owners - this step will create the marble owners you specificed in the `mycreds.json` file
1. Register Marble Owners - this step will create the marble owners you specificed in the `blockchain_creds1.json` file

![](/doc_images/localhost3.png)

Expand Down
5 changes: 4 additions & 1 deletion docs/install_chaincode.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

- Fill out the chaincode name as "marbles"
- Fill out the chaincode version as "v0"
- Select the "Choose Files" button and select **all 5** files found in `<marbles directory>/chaincode/src/marbles`
- Alternatively you can zip up the 5 .go files and submit a single zip file
- Click "Submit"

![](/doc_images/11-installed-marbles.PNG)
Expand All @@ -41,7 +43,8 @@
- On this panel, you should see something simialr to the picture above. Marbles is deployed on both peers and we can click the logs button to see it has started up.
- The last thing we need to do is grab all the service instance's credentials for our network. We will use this data to inform the marbles node.js application of our blockchain's networking addresses and credentials.
- Get basic service credentials by clicking the "JSON" button
- This will open the JSON in your browser. Copy this data and save/replace the entire contents of the file `<marbles directory>/config/mycreds1.json`
- This will open the JSON in your browser. Copy this data and save/replace the entire contents of the file `<marbles directory>/config/blockchain_creds1.json`
- This JSON a simplified version of your Service Credentials. It has 1 orderer, 1 ca, 1 peer which is all we need for marbles.

### Finish Up

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial_start_here.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ Let’s look at the operations involved when creating a new marble.

# SDK Deeper Dive
Now lets see how we interface with the Fabric Client SDK.
Most of the configuration options can be found in `/config/mycreds.json`.
Most of the configuration options can be found in `/config/blockchain_creds1.json`.
This file list the hostname (or ip) and port of various components of our blockchain network.
The `helper` functions will retreive IPs and ports from the configuration file.

Expand Down
12 changes: 6 additions & 6 deletions docs/use_local_hyperledger.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ This is normal and is because of a the long batch time.
Please be patient while we think of a better visual way handle and represent these long pauses.

Next we need to **pass the location of our peer to our marbles application**.
This is done by editing the `/config/mycreds.json` file.
This is done by editing the `/config/blockchain_creds1.json` file.

There are multiple credential files to show different setups.
Marbles will open the file found in the environmental variable `creds_filename`.
Gulp will set this for us based on what gulp task we tell it to do.
**Double check that [gulpfile.js](../gulpfile.js#L67) is using the mycreds.json filename.**
**Double check that [gulpfile.js](../gulpfile.js#L67) is using the blockchain_creds1.json filename.**

```js
gulp.task('start_marbles', function () {
env['creds_filename'] = 'mycreds.json';
env['creds_filename'] = 'blockchain_creds1.json';
console.log('\n[International Marbles Trading Consortium]\n');
});
```

Next we must edit `mycreds.json` with information about your network.
Next we must edit `blockchain_creds1.json` with information about your network.
Below is a sample showing the information that must be in the JSON file.

__sample mycreds.json__
__sample blockchain_creds1.json__

```js
{
Expand Down Expand Up @@ -123,6 +123,6 @@ Maps to:
}
```

Once you have edited `mycreds.json` you are ready to run Marbles.
Once you have edited `blockchain_creds1.json` you are ready to run Marbles.

1. Continue where you left off in [tutorial 1](./tutorial_start_here.md#hostmarbles).
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ gulp.task('marbles2', ['start_marbles2', 'watch-sass', 'watch-js', 'watch-server

//marbles 2
gulp.task('start_marbles1', function () {
env['creds_filename'] = 'mycreds1.json';
env['creds_filename'] = 'marbles1.json';
console.log('\n[International Marbles Trading Consortium] 1\n');
});

//marbles 1
gulp.task('start_marbles2', function () {
env['creds_filename'] = 'mycreds2.json';
env['creds_filename'] = 'marbles2.json';
console.log('\n[International Marbles Trading Consortium] 2\n');
});
4 changes: 3 additions & 1 deletion utils/fc_wrangler/enrollment.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ module.exports = function (logger) {
try {
for (var i in options.peer_urls) {
chain.addPeer(new Peer(options.peer_urls[i]));
console.log('added peer', options.peer_urls[i]);
}
}
catch (e) {
//might error if peer already exists, but we don't care
}
try{
chain.setPrimaryPeer(new Peer(options.peer_urls[0]));
console.log('added primary peer', options.peer_urls[0]);
}
catch(e){
//might error b/c bugs, don't care
Expand Down Expand Up @@ -104,7 +106,7 @@ module.exports = function (logger) {
// Need to enroll it with CA server
var ca_client = new CaService(options.ca_url);
console.log('id', options.enroll_id, 'secret', options.enroll_secret); //dsh todo remove this

console.log('msp_id', options.msp_id);
return ca_client.enroll({
enrollmentID: options.enroll_id,
enrollmentSecret: options.enroll_secret
Expand Down
2 changes: 1 addition & 1 deletion utils/fc_wrangler/invoke_cc.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = function (logger) {
var msg = '[fcw] Failed to receive block event within the timeout period';
logger.error(msg);
throw msg;
}, 30000);
}, 120000);

// Wait for block event
eventhub.registerTxEvent(request.txId.toString(), (tx, code) => {
Expand Down
Loading

0 comments on commit 2bcee37

Please sign in to comment.