Skip to content

Commit

Permalink
readme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dshuffma-ibm committed Mar 19, 2017
1 parent c1da6ad commit ae30bbf
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 70 deletions.
2 changes: 1 addition & 1 deletion config/marbles1.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cred_filename": "blockchain_creds4.json",
"cred_filename": "blockchain_creds1.json",
"company": "United Marbles",
"usernames": [
"amy",
Expand Down
Binary file modified doc_images/comm_flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 34 additions & 11 deletions docs/tutorial_start_here.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,25 +222,46 @@ Next, we need to send these fields to the SDK.
//enroll admin
function enroll_admin(id, secret, ca_url, cb){
try {
//[1]
// [Step 1]
var client = new HFC();
chain = client.newChain('mychain' + file_safe_name(process.env.marble_company) + '-' + uuid);
chain = client.newChain(options.channel_id);
}
catch (e) {
//it might error about 1 chain per network, but that's not a problem just continue
}

// [2] - Make Cert kvs
// [Step 2] - Make Cert kvs
HFC.newDefaultKeyValueStore({
path: path.join(__dirname, './keyValStore-' + file_safe_name(process.env.marble_company) + '-' + uuid)
}).then(function(store){
path: path.join(__dirname, '/kvs/' + options.uuid) //store eCert in the kvs directory
}).then(function (store) {
client.setStateStore(store);
console.log('! using id', id, 'secret', secret);

//[3]
return getSubmitter(id, secret, ca_url, client); //do most of the work here
// [Step 3]
return getSubmitter(client, options); //do most of the work here
}).then(function(submitter){

// [Step 4]
chain.addOrderer(new Orderer(options.orderer_url));

// [Step 5]
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
}

// [Step 6]
// --- Success --- //
console.log('Successfully enrolled ' + id);
setTimeout(function(){
Expand All @@ -258,10 +279,12 @@ function enroll_admin(id, secret, ca_url, cb){
}
```

1. The first thing the code does is create an instance of HFC, our SDK.
1. The first thing the code does is create an instance of our SDK.
1. Next we create a key value store to store the enrollment certifcates with `newDefaultKeyValueStore`
1. Next we enroll our admin. This is when we authenticate to the CA with our enroll ID and enroll secret. The CA will issue enrollment certificates which the SDK will store in the key value store. Since we are using the default key value store, it will be stored in our local file system. This will be in the marbles directory in a folder named something like `keyValStore-united_marbles`.
1. After successful enrollment the SDK is fully configured and ready to interact with the blockchain.
1. Next we enroll our admin. This is when we authenticate to the CA with our enroll ID and enroll secret. The CA will issue enrollment certificates which the SDK will store in the key value store. Since we are using the default key value store, it will be stored in our local file system.
1. After successful enrollment we set the orderer URL. The orderer is not needed yet, but will be when we try to invoke chaincode.
1. Next we set the Peer URLs. These are also not needed yet, but we are going to setup our SDK chain object fully.
1. At this point the SDK is fully configured and ready to interact with the blockchain.


# Marbles Deeper Dive
Expand Down
92 changes: 34 additions & 58 deletions docs/use_local_hyperledger.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,15 @@ This is a litttttle long for our application, and may give you unexpected behavi
Basicaly if you move a marble the trade will take 10 seconds to settle.
The **UI may redraw the marble back in its original position**, and then jump to a correct position after some time.
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/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 blockchain_creds1.json filename.**

```js
gulp.task('start_marbles', function () {
env['creds_filename'] = 'blockchain_creds1.json';
console.log('\n[International Marbles Trading Consortium]\n');
});
```
This initial file (`marbles1.json`) points to our blockchain credentials file with the field "cred_filename". Thats the file that holds our network ips/hostnames/ports and other similar data.

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.
Expand All @@ -39,54 +32,39 @@ __sample blockchain_creds1.json__

```js
{
"credentials": {
"network_id": "asdf", //not important atm
"peers": [
{
"grpc_host": "192.168.99.100", //must match the ip or hostname of your peer
"grpc_port": 8051, //must match the gRPC port on your peer
"event_host": "192.168.99.100",
"event_port:": 8053,
"type": "peer", //leave this as peer
"network_id": "asdf", //not important atm
"id": "peer1" //not important atm
}
],
"cas": [
{
"host": "192.168.99.100", //must match the ip or hostname of your peer
"port": 8054, //must match the gRPC port on your peer
"type": "ca", //leave this as ca
"network_id": "asdf" //not important atm
"id": "asdf-ca", //not important atm
}
],
"orderers": [
{
"host": "192.168.99.100", //must match the ip or hostname of your peer
"port": 8050, //must match the gRPC port on your peer
"type": "orderer", //leave this as ca
"network_id": "asdf", //not important atm
"id": "orderer-01" //not important atm
}
],
"users": [
{
"enrollId": "admin",, //must match enroll ID found in CA
"enrollSecret": "adminpw" //must match enroll Secret found in CA
}
],
"cert": "https://blockchain-certs.mybluemix.net/us.blockchain.ibm.com.cert",
"marbles": {
"company": "Marble Market", //name of marble company
"chaincode_id": "marbles", //name of deployed chaincode
"usernames": [ //marble owner usernames
"amy",
"bill"
],
"port": 3000 //port for marbles to use
}
}
"credentials": {
"network_id": "asdf", //not important atm
"peers": [
{
"discovery": "grpc://192.168.99.100:8051", //must match the ip or hostname of your peer
"events": "grpc://192.168.99.100:8053", //must match the ip or hostname of your peer
"msp_id": "Org1MSP"
}
],
"cas": [
{
"api": "http://192.168.99.100:8054", //must match the ip or hostname of your ca
"msp_id": "Org1MSP",
"users": [
{
"enrollId": "admin",
"enrollSecret": "adminpw"
}
]
}
],
"orderers": [
{
"discovery": "grpc://192.168.99.100", //must match the ip or hostname of your peer
"msp_id": "Org1MSP"
}
],
"app": {
"channel_id": "mychannel", //name of the blockchain channel
"chaincode_id": "marbles", //name of deployed chaincode
"chaincode_version": "v0"
}
}
}
```

Expand All @@ -98,8 +76,6 @@ If its not there you need to add it such that `peers`, `cas` and etc are inside

Marbles only talks to 1 peer.
Therefore, you should have 1 entry in the `peers` array and 1 entry in the `users` array.
You can omit the `users` array entirely if the network does not use a CA.
The default docker-compose example does use a CA.
You will need to look up the default CA enroll ID/users for your Hyperledger Fabric version to populate the `users` array.
Fabric version 0.7.0 enroll Ids can be found in the [cop.json](https://github.com/hyperledger/fabric-cop/blob/master/docker/fabric-cop/cop.json) file.

Expand Down

0 comments on commit ae30bbf

Please sign in to comment.