fabric1.4示例

nodejs安装:
https://www.runoob.com/nodejs/nodejs-install-setup.html

wang@wang:~$ wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz
--2019-06-11 18:38:57--  https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz
Resolving nodejs.org (nodejs.org)... 104.20.22.46, 104.20.23.46, 2606:4700:10::6814:162e, ...
Connecting to nodejs.org (nodejs.org)|104.20.22.46|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12330296 (12M) [application/x-xz]
Saving to: ‘node-v10.9.0-linux-x64.tar.xz’

node-v10.9.0-linux- 100%[===================>]  11.76M   875KB/s    in 13s     

2019-06-11 18:39:11 (940 KB/s) - ‘node-v10.9.0-linux-x64.tar.xz’ saved [12330296/12330296]

wang@wang:~$ ls
1.0        examples.desktop               Oracle        Templates
Desktop    go                             oraInventory  Videos
Documents  Music                          Pictures      vmware-tools-distrib
Downloads  node-v10.9.0-linux-x64.tar.xz  Public
wang@wang:~$ tar xf  node-v10.9.0-linux-x64.tar.xz
wang@wang:~$ ls
1.0               Music                          Public
Desktop           node-v10.9.0-linux-x64         Templates
Documents         node-v10.9.0-linux-x64.tar.xz  Videos
Downloads         Oracle                         vmware-tools-distrib
examples.desktop  oraInventory
go                Pictures
wang@wang:~$ cd node-v10.9.0-linux-x64/
wang@wang:~/node-v10.9.0-linux-x64$ ls
bin  CHANGELOG.md  include  lib  LICENSE  README.md  share
wang@wang:~/node-v10.9.0-linux-x64$ ./bin/node -v
v10.9.0
wang@wang:~/node-v10.9.0-linux-x64$ 

然后改下环境变量,当前用户的bashrc文件中:

NODE_HOME=/home/wang/node-v10.9.0-linux-x64
export PATH=$PATH:/home/wang/1.0/scripts:$NODE_HOME/bin
wang@wang:~$ node -v
v10.9.0

一、转账

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts$ ls
bootstrap.sh   check_license.sh         compile_protos.sh    goListFiles.sh  pull_build_artifacts.sh
changelog.sh   check_spelling.sh        generateHelpDocs.sh  metrics_doc.sh  run-integration-tests.sh
check_deps.sh  check_trailingspaces.sh  golinter.sh          multiarch.sh
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts$ ./bootstrap.sh 
./bootstrap.sh: line 179: [: too many arguments

Installing hyperledger/fabric-samples repo

===> Cloning hyperledger/fabric-samples repo and checkout v1.4.1
Cloning into 'fabric-samples'...
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 3251 (delta 13), reused 31 (delta 11), pack-reused 3213
Receiving objects: 100% (3251/3251), 1.07 MiB | 474.00 KiB/s, done.
Resolving deltas: 100% (1596/1596), done.
Checking connectivity... done.
Note: checking out 'v1.4.1'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 6c0203a... FABCI-284 Update CI Pipeline script

Installing Hyperledger Fabric binaries

===> Downloading version 1.4.1 platform specific fabric binaries
===> Downloading:  https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/linux-amd64-1.4.1/hyperledger-fabric-linux-amd64-1.4.1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 51.9M  100 51.9M    0     0  22516      0  0:40:17  0:40:17 --:--:-- 43842
==> Done.
===> Downloading version 1.4.1 platform specific fabric-ca-client binary
===> Downloading:  https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/linux-amd64-1.4.1/hyperledger-fabric-ca-linux-amd64-1.4.1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 6323k  100 6323k    0     0  24086      0  0:04:28  0:04:28 --:--:-- 19786
==> Done.

Installing Hyperledger Fabric docker images

===> Pulling fabric Images
==> FABRIC IMAGE: peer

1.4.1: Pulling from hyperledger/fabric-peer
34667c7e4631: Pull complete 
d18d76a881a4: Pull complete 
119c7358fbfc: Pull complete 
2aaf13f3eff0: Pull complete 
3f89de4cf84b: Pull complete 
24194f819972: Pull complete 
979cc59b6d95: Pull complete 
8eb49214b84e: Pull complete 
0e108783b4cb: Pull complete 
Digest: sha256:05315d05b2892d34b4ed48f6502d28fe15a71090c36a39c97022a44475a984ad
Status: Downloaded newer image for hyperledger/fabric-peer:1.4.1
==> FABRIC IMAGE: orderer

1.4.1: Pulling from hyperledger/fabric-orderer
34667c7e4631: Already exists 
d18d76a881a4: Already exists 
119c7358fbfc: Already exists 
2aaf13f3eff0: Already exists 
3f89de4cf84b: Already exists 
24194f819972: Already exists 
979cc59b6d95: Already exists 
c06474c386d6: Pull complete 
f215c85a7c15: Pull complete 
Digest: sha256:09f31ca4dabe1eb2af870ea062561ca6686fc59a296ecc3b4bd7e32102c48934
Status: Downloaded newer image for hyperledger/fabric-orderer:1.4.1
==> FABRIC IMAGE: ccenv

1.4.1: Pulling from hyperledger/fabric-ccenv
34667c7e4631: Already exists 
d18d76a881a4: Already exists 
119c7358fbfc: Already exists 
2aaf13f3eff0: Already exists 
3f89de4cf84b: Already exists 
24194f819972: Already exists 
78e4eabd31a5: Pull complete 
c7652b6bde40: Pull complete 
b4646dd65c45: Pull complete 
5e6defad8a30: Pull complete 
dbf64847ffc5: Pull complete 
79f572cfe27b: Pull complete 
0a5850389088: Pull complete 
Digest: sha256:bb929eef560b50e0fbd730c6b195e49fece28dd4612ec30db0ce2cc096483463
Status: Downloaded newer image for hyperledger/fabric-ccenv:1.4.1
==> FABRIC IMAGE: javaenv

1.4.1: Pulling from hyperledger/fabric-javaenv
34667c7e4631: Already exists 
d18d76a881a4: Already exists 
119c7358fbfc: Already exists 
2aaf13f3eff0: Already exists 
3f89de4cf84b: Already exists 
24194f819972: Already exists 
78e4eabd31a5: Already exists 
c7652b6bde40: Already exists 
b4646dd65c45: Already exists 
5e6defad8a30: Already exists 
eb47063381b3: Pulling fs layer 
5d96c91121a9: Pulling fs layer 
bb517f8ff419: Pulling fs layer 
4312bf8e6cfe: Pulling fs layer 
1e8681f2352c: Pull complete 
cb0b7dd33c79: Pull complete 
bebfcea7bcae: Pull complete 
5be1ee716cf0: Pull complete 
7dc7ea1dac5a: Pull complete 
2e645bfbd09e: Pull complete 
581bb97c79a3: Pull complete 
592997691b75: Pull complete 
b683e95a3992: Pull complete 
8bd4f04d2ba4: Pull complete 
b96572cb2772: Pull complete 
ad484dac00f0: Pull complete 
b0baff9a0b74: Pull complete 
c85e9716a7a4: Pull complete 
c527d24bce1f: Pull complete 
e9ee2c9e0a80: Pull complete 
a91422a9f1b9: Pull complete 
71e2394f7f51: Pull complete 
0a4a45339133: Pull complete 
9d811a6b148f: Pull complete 
722560716002: Pull complete 
98d317dd5a01: Pull complete 
652de911abbf: Pull complete 
Digest: sha256:9f4a99b36f33f4071f34f295f6a440ff51e22393ef5458e69c12fad897ae46f8
Status: Downloaded newer image for hyperledger/fabric-javaenv:1.4.1
==> FABRIC IMAGE: tools

1.4.1: Pulling from hyperledger/fabric-tools
34667c7e4631: Already exists 
d18d76a881a4: Already exists 
119c7358fbfc: Already exists 
2aaf13f3eff0: Already exists 
3f89de4cf84b: Already exists 
24194f819972: Already exists 
78e4eabd31a5: Already exists 
c7652b6bde40: Already exists 
b4646dd65c45: Already exists 
5e6defad8a30: Already exists 
afff1a4f3772: Pull complete 
91abd3b624d2: Pull complete 
53c55265651f: Pull complete 
Digest: sha256:c458ddc3109d3519b209baaf9abff113641267ec2adb01dfdcf8f4c9e77a2fa0
Status: Downloaded newer image for hyperledger/fabric-tools:1.4.1
===> Pulling fabric ca Image
==> FABRIC CA IMAGE

1.4.1: Pulling from hyperledger/fabric-ca
34667c7e4631: Already exists 
d18d76a881a4: Already exists 
119c7358fbfc: Already exists 
2aaf13f3eff0: Already exists 
3f89de4cf84b: Already exists 
24194f819972: Already exists 
a3d7dc54e295: Pull complete 
9a3c9a0ecc41: Pull complete 
dc5d0553c3a1: Pull complete 
e1f5909edf17: Pull complete 
8d735007731d: Pull complete 
Digest: sha256:f77aa0ff885c572b090d1ff7564780daafd50d9e839b6241c2ab12c37f47b94a
Status: Downloaded newer image for hyperledger/fabric-ca:1.4.1
===> Pulling thirdparty docker images
==> THIRDPARTY DOCKER IMAGE: couchdb

0.4.15: Pulling from hyperledger/fabric-couchdb
34667c7e4631: Already exists 
d18d76a881a4: Already exists 
119c7358fbfc: Already exists 
2aaf13f3eff0: Already exists 
3f89de4cf84b: Already exists 
24194f819972: Already exists 
78e4eabd31a5: Already exists 
c7652b6bde40: Already exists 
b4646dd65c45: Already exists 
5e6defad8a30: Already exists 
7695bf5d0b9d: Pull complete 
6d9d46f66bc3: Pull complete 
4912f1b4990a: Pull complete 
f3b174a93eea: Pull complete 
3763a939777a: Pull complete 
f293593adbb6: Pull complete 
1ae53ace804f: Pull complete 
d4aa6d764b18: Pull complete 
d747b2b30e48: Pull complete 
52cbd2253fea: Pull complete 
Digest: sha256:f6c724592abf9c2b35d2f4cd6a7afcde9c1052cfed61560b20ef9e2e927d1790
Status: Downloaded newer image for hyperledger/fabric-couchdb:0.4.15
==> THIRDPARTY DOCKER IMAGE: kafka

0.4.15: Pulling from hyperledger/fabric-kafka
34667c7e4631: Already exists 
d18d76a881a4: Already exists 
119c7358fbfc: Already exists 
2aaf13f3eff0: Already exists 
3f89de4cf84b: Already exists 
24194f819972: Already exists 
78e4eabd31a5: Already exists 
c7652b6bde40: Already exists 
b4646dd65c45: Already exists 
5e6defad8a30: Already exists 
d0459116a54a: Pull complete 
1bbcec7bfdef: Pull complete 
5911218c5933: Pull complete 
Digest: sha256:62418a885c291830510379d9eb09fbdd3d397052d916ed877a468b0e2026b9e3
Status: Downloaded newer image for hyperledger/fabric-kafka:0.4.15
==> THIRDPARTY DOCKER IMAGE: zookeeper

0.4.15: Pulling from hyperledger/fabric-zookeeper
34667c7e4631: Already exists 
d18d76a881a4: Already exists 
119c7358fbfc: Already exists 
2aaf13f3eff0: Already exists 
3f89de4cf84b: Already exists 
24194f819972: Already exists 
78e4eabd31a5: Already exists 
c7652b6bde40: Already exists 
b4646dd65c45: Already exists 
5e6defad8a30: Already exists 
0e045d9c2cdc: Pull complete 
7ef4d8920518: Pull complete 
dbeed81d9a45: Pull complete 
aeea025ecc4e: Pull complete 
Digest: sha256:180553e88d09167370aa62a41587a9a95b819b981ad74cad218689412b85f130
Status: Downloaded newer image for hyperledger/fabric-zookeeper:0.4.15

===> List out hyperledger docker images
hyperledger/fabric-ca          1.4.1               3a1799cda5d7        2 months ago        252MB
hyperledger/fabric-ca          latest              3a1799cda5d7        2 months ago        252MB
hyperledger/fabric-tools       1.4.1               432c24764fbb        2 months ago        1.55GB
hyperledger/fabric-tools       latest              432c24764fbb        2 months ago        1.55GB
hyperledger/fabric-ccenv       1.4.1               d7433c4b2a1c        2 months ago        1.43GB
hyperledger/fabric-ccenv       latest              d7433c4b2a1c        2 months ago        1.43GB
hyperledger/fabric-orderer     1.4.1               ec4ca236d3d4        2 months ago        173MB
hyperledger/fabric-orderer     latest              ec4ca236d3d4        2 months ago        173MB
hyperledger/fabric-peer        1.4.1               a1e3874f338b        2 months ago        178MB
hyperledger/fabric-peer        latest              a1e3874f338b        2 months ago        178MB
hyperledger/fabric-javaenv     1.4.1               b8c9d7ff6243        2 months ago        1.74GB
hyperledger/fabric-javaenv     latest              b8c9d7ff6243        2 months ago        1.74GB
hyperledger/fabric-zookeeper   0.4.15              20c6045930c8        2 months ago        1.43GB
hyperledger/fabric-zookeeper   latest              20c6045930c8        2 months ago        1.43GB
hyperledger/fabric-kafka       0.4.15              b4ab82bbaf2f        2 months ago        1.44GB
hyperledger/fabric-kafka       latest              b4ab82bbaf2f        2 months ago        1.44GB
hyperledger/fabric-couchdb     0.4.15              8de128a55539        2 months ago        1.5GB
hyperledger/fabric-couchdb     latest              8de128a55539        2 months ago        1.5GB
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts$ 
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network$ ./byfn.sh generate -c mychannel
Generating certs and genesis block for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/../bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
+ cryptogen generate --config=./crypto-config.yaml
org1.example.com
org2.example.com
+ res=0
+ set +x

/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/../bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
CONSENSUS_TYPE=solo
+ '[' solo == solo ']'
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
2019-06-11 16:40:22.990 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-06-11 16:40:23.123 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: solo
2019-06-11 16:40:23.123 CST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded configuration: /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2019-06-11 16:40:23.243 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 004 orderer type: solo
2019-06-11 16:40:23.244 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 005 Loaded configuration: /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2019-06-11 16:40:23.246 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating genesis block
2019-06-11 16:40:23.246 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
+ set +x

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2019-06-11 16:40:23.315 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-06-11 16:40:23.431 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2019-06-11 16:40:23.560 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-06-11 16:40:23.560 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2019-06-11 16:40:23.560 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Generating new channel configtx
2019-06-11 16:40:23.563 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 006 Writing new channel tx
+ res=0
+ set +x

#################################################################
#######    Generating anchor peer update for Org1MSP   ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
2019-06-11 16:40:23.620 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-06-11 16:40:23.726 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2019-06-11 16:40:23.827 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-06-11 16:40:23.828 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2019-06-11 16:40:23.828 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2019-06-11 16:40:23.828 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x

#################################################################
#######    Generating anchor peer update for Org2MSP   ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
2019-06-11 16:40:23.878 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-06-11 16:40:23.974 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2019-06-11 16:40:24.075 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-06-11 16:40:24.075 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2019-06-11 16:40:24.075 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2019-06-11 16:40:24.075 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network$
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network$ ./byfn.sh up -c mychannel
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=1.4.1
DOCKER_IMAGE_VERSION=1.4.1
Creating network "net_byfn" with the default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_orderer.example.com" with default driver
Creating peer1.org2.example.com
Creating orderer.example.com
Creating peer0.org2.example.com
Creating peer1.org1.example.com
Creating peer0.org1.example.com
Creating cli
CONTAINER ID        IMAGE                               COMMAND             CREATED             STATUS                  PORTS                      NAMES
eff423bfc1a8        hyperledger/fabric-tools:latest     "/bin/bash"         2 seconds ago       Up Less than a second                              cli
dcbc07ca2c46        hyperledger/fabric-peer:latest      "peer node start"   6 seconds ago       Up 2 seconds            0.0.0.0:7051->7051/tcp     peer0.org1.example.com
f0ce04d8e64a        hyperledger/fabric-peer:latest      "peer node start"   6 seconds ago       Up 2 seconds            0.0.0.0:8051->8051/tcp     peer1.org1.example.com
a257a1a33052        hyperledger/fabric-peer:latest      "peer node start"   6 seconds ago       Up 2 seconds            0.0.0.0:10051->10051/tcp   peer1.org2.example.com
9f5f8de48685        hyperledger/fabric-peer:latest      "peer node start"   6 seconds ago       Up 1 second             0.0.0.0:9051->9051/tcp     peer0.org2.example.com
8274a994a995        hyperledger/fabric-orderer:latest   "orderer"           6 seconds ago       Up 3 seconds            0.0.0.0:7050->7050/tcp     orderer.example.com

 ____    _____      _      ____    _____ 
/ ___|  |_   _|    / \    |  _ \  |_   _|
\___ \    | |     / _ \   | |_) |   | |  
 ___) |   | |    / ___ \  |  _ <    | |  
|____/    |_|   /_/   \_\ |_| \_\   |_|  

Build your first network (BYFN) end-to-end test

Channel name : mychannel
Creating channel...
+ peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-06-11 08:41:53.234 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-06-11 08:41:53.322 UTC [cli.common] readBlock -> INFO 002 Received block: 0
===================== Channel 'mychannel' created ===================== 

Having all peers join the channel...
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-06-11 08:41:53.416 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-06-11 08:41:53.636 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org1 joined channel 'mychannel' ===================== 

+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-06-11 08:41:56.788 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-06-11 08:41:56.854 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org1 joined channel 'mychannel' ===================== 

+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-06-11 08:41:59.969 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-06-11 08:42:00.043 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org2 joined channel 'mychannel' ===================== 

+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-06-11 08:42:03.159 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-06-11 08:42:03.212 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org2 joined channel 'mychannel' ===================== 

Updating anchor peers for org1...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-06-11 08:42:06.341 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-06-11 08:42:06.358 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' ===================== 

Updating anchor peers for org2...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-06-11 08:42:09.498 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-06-11 08:42:09.522 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' ===================== 

Installing chaincode on peer0.org1...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2019-06-11 08:42:12.660 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-06-11 08:42:12.661 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-06-11 08:42:14.761 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" > 
===================== Chaincode is installed on peer0.org1 ===================== 

Install chaincode on peer0.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2019-06-11 08:42:14.851 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-06-11 08:42:14.851 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-06-11 08:42:15.133 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" > 
===================== Chaincode is installed on peer0.org2 ===================== 

Instantiating chaincode on peer0.org2...
+ peer chaincode instantiate -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P 'AND ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'')'
+ res=0
+ set +x
2019-06-11 08:42:15.243 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-06-11 08:42:15.243 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
===================== Chaincode is instantiated on peer0.org2 on channel 'mychannel' ===================== 

Querying chaincode on peer0.org1...
===================== Querying on peer0.org1 on channel 'mychannel'... ===================== 
Attempting to Query peer0.org1 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x

100
===================== Query successful on peer0.org1 on channel 'mychannel' ===================== 
Sending invoke transaction on peer0.org1 peer0.org2...
+ peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
2019-06-11 08:43:33.057 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200 
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' ===================== 

Installing chaincode on peer1.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2019-06-11 08:43:33.169 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-06-11 08:43:33.169 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-06-11 08:43:33.475 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" > 
===================== Chaincode is installed on peer1.org2 ===================== 

Querying chaincode on peer1.org2...
===================== Querying on peer1.org2 on channel 'mychannel'... ===================== 
Attempting to Query peer1.org2 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x

90
===================== Query successful on peer1.org2 on channel 'mychannel' ===================== 

========= All GOOD, BYFN execution completed =========== 


 _____   _   _   ____   
| ____| | \ | | |  _ \  
|  _|   |  \| | | | | | 
| |___  | |\  | | |_| | 
|_____| |_| \_| |____/  

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network$ 

scripts/script.sh在byfn.sh的networkup函数中调用了

wang@wang:~$ top

top - 16:45:14 up  2:39,  1 user,  load average: 1.17, 0.93, 0.44
Tasks: 260 total,   1 running, 259 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.5 us,  2.8 sy,  0.0 ni, 93.8 id,  0.0 wa,  0.0 hi,  0.9 si,  0.0 st
KiB Mem :  4028132 total,   679944 free,  1374972 used,  1973216 buff/cache
KiB Swap:  2094076 total,  2087136 free,     6940 used.  2271612 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND    
 15045 root      20   0  476792 146964  23628 S   5.6  3.6   0:09.16 peer       
 15064 root      20   0  609976 151304  23344 S   5.3  3.8   0:09.37 peer       
 15060 root      20   0  413112 151420  22528 S   5.0  3.8   0:09.38 peer       
 15072 root      20   0  468404  80704  22444 S   5.0  2.0   0:07.74 peer       
 18890 wang      20   0   43656   4164   3440 R   0.7  0.1   0:00.15 top        
  7855 root      20   0  334156  60120  28616 S   0.3  1.5   2:04.66 Xorg       
  8400 root      20   0  608916  41336  20948 S   0.3  1.0   0:32.79 docker-co+ 
  8960 wang      20   0  218028  23460  20200 S   0.3  0.6   0:25.25 vmtoolsd   
     1 root      20   0  119924   6044   3984 S   0.0  0.2   0:04.50 systemd    
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.02 kthreadd   
     3 root      20   0       0      0      0 S   0.0  0.0   0:00.31 ksoftirqd+ 
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0+ 
     7 root      20   0       0      0      0 S   0.0  0.0   0:13.70 rcu_sched  
     8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh     
     9 root      rt   0       0      0      0 S   0.0  0.0   0:00.10 migration+ 
    10 root      rt   0       0      0      0 S   0.0  0.0   0:00.09 watchdog/0 
    11 root      rt   0       0      0      0 S   0.0  0.0   0:00.09 watchdog/1 
wang@wang:~$ 

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network$ docker exec -it cli bash
root@eff423bfc1a8:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
90
root@eff423bfc1a8:/opt/gopath/src/github.com/hyperledger/fabric/peer# 
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network$ ./byfn.sh down
Stopping for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
Stopping cli ... done
Stopping peer0.org1.example.com ... done
Stopping peer1.org1.example.com ... done
Stopping peer1.org2.example.com ... done
Stopping peer0.org2.example.com ... done
Stopping orderer.example.com ... done
Removing cli ... done
Removing peer0.org1.example.com ... done
Removing peer1.org1.example.com ... done
Removing peer1.org2.example.com ... done
Removing peer0.org2.example.com ... done
Removing orderer.example.com ... done
Removing network net_byfn
Removing volume net_peer0.org3.example.com
WARNING: Volume net_peer0.org3.example.com not found.
Removing volume net_peer1.org3.example.com
WARNING: Volume net_peer1.org3.example.com not found.
Removing volume net_orderer2.example.com
WARNING: Volume net_orderer2.example.com not found.
Removing volume net_orderer.example.com
Removing volume net_peer0.org2.example.com
Removing volume net_peer0.org1.example.com
Removing volume net_peer1.org1.example.com
Removing volume net_peer1.org2.example.com
Removing volume net_orderer5.example.com
WARNING: Volume net_orderer5.example.com not found.
Removing volume net_orderer4.example.com
WARNING: Volume net_orderer4.example.com not found.
Removing volume net_orderer3.example.com
WARNING: Volume net_orderer3.example.com not found.
2ba7f83992c6
47e52933e8d9
9a3f6b5aadbe
Untagged: dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab:latest
Deleted: sha256:a1e7a6d42e2aca3806ef8613054ea0eeabad1b25e121b1aae2393972de71b9be
Deleted: sha256:38e49864d5fe6e965b073de29e6758fd22c7ea2fe166a97dd5562cb7bfba7bdf
Deleted: sha256:45c7da98a5a0eae056e1c6af74176f083a25d7a4fbb1ff1fa6b62bc73568e0a5
Deleted: sha256:45f44ed8ca3dde6b78430c28aec7602480ce6fa6ae4d9e6541425e7995988686
Untagged: dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9:latest
Deleted: sha256:219ec174fbc3fad2f868b6c5a9ff49488dacdd7f6ff7845779b4117093080ceb
Deleted: sha256:6f2d02148b53cac8594ac782804ed736bca2c52a7b584dad880c3a80d132d402
Deleted: sha256:2748a2c6b482ef73c8ad2d9ad6492a8b58bb5bed97e410bc8d16f1cbee3cc4ea
Deleted: sha256:fd55f57a66df5618caf1c08f43c3d5c1f42ceeb3d25a5350360be76f29ce5cb7
Untagged: dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b:latest
Deleted: sha256:b8d403106583c38a29a228f4a33d7f368077d11c09159e618393011807698605
Deleted: sha256:1c2fcfaa91173d88dfb33eeea5645af54b1dad64fb9a844148143c1e2167d661
Deleted: sha256:c7ee17c68f8e511585902e3174c7168ac106accc335b9ec85594aad302ef1ac1
Deleted: sha256:80255ea358e8f8502959e203069b4ed76c4e08b3e389b9f59a44c0dfa4248abe
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network$ 

二、票据

terminal 1:

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/basic-network$ ./start.sh 

# don't rewrite paths for Windows Git Bash users
export MSYS_NO_PATHCONV=1

docker-compose -f docker-compose.yml down
Removing network net_basic

docker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com peer0.org1.example.com couchdb
Creating network "net_basic" with the default driver
Creating orderer.example.com
Creating ca.example.com
Creating couchdb
Creating peer0.org1.example.com
docker ps -a
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                  PORTS                                            NAMES
9285fc24031f        hyperledger/fabric-peer      "peer node start"        1 second ago        Up Less than a second   0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.example.com
de39f974843d        hyperledger/fabric-couchdb   "tini -- /docker-ent…"   4 seconds ago       Up 1 second             4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp       couchdb
1da87858a10f        hyperledger/fabric-ca        "sh -c 'fabric-ca-se…"   4 seconds ago       Up 2 seconds            0.0.0.0:7054->7054/tcp                           ca.example.com
d13b7c783c0e        hyperledger/fabric-orderer   "orderer"                4 seconds ago       Up 1 second             0.0.0.0:7050->7050/tcp                           orderer.example.com

# wait for Hyperledger Fabric to start
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
export FABRIC_START_TIMEOUT=10
#echo ${FABRIC_START_TIMEOUT}
sleep ${FABRIC_START_TIMEOUT}

# Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
2019-06-11 09:31:18.317 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-06-11 09:31:18.376 UTC [cli.common] readBlock -> INFO 002 Received block: 0
# Join peer0.org1.example.com to the channel.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel join -b mychannel.block
2019-06-11 09:31:18.927 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-06-11 09:31:19.170 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/basic-network$ 

再打开一个terminal 2:

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/configuration/cli$ ./monitordocker.sh ne
t_basic
Starting monitoring on all containers on the network net_basic
93b835a82ff961c0aef64713fabc90866f84575778b7352f07d2562655b299a8
(等待ing...)

terminal 2(1):

(install)
peer0.org1.example.com|2019-06-11 09:46:02.961 UTC [endorser] callChaincode -> INFO 03a [][4f3a0838] Entry chaincode: name:"lscc" 
               couchdb|[notice] 2019-06-11T09:46:02.978484Z nonode@nohost <0.15382.0> 4c63c09126 couchdb:5984 172.22.0.5 undefined GET /mychannel_lscc 404 ok 7
peer0.org1.example.com|2019-06-11 09:46:03.015 UTC [couchdb] CreateDatabaseIfNotExist -> INFO 03b Created state database mychannel_lscc
               couchdb|[notice] 2019-06-11T09:46:03.015895Z nonode@nohost <0.15382.0> e8a4ebecfb couchdb:5984 172.22.0.5 undefined PUT /mychannel_lscc 201 ok 36
               couchdb|[notice] 2019-06-11T09:46:03.019244Z nonode@nohost <0.15382.0> f5d6f18e34 couchdb:5984 172.22.0.5 undefined GET /mychannel_lscc/papercontract?attachments=true 404 ok 1
peer0.org1.example.com|2019-06-11 09:46:03.021 UTC [lscc] executeInstall -> INFO 03c Installed Chaincode [papercontract] Version [0] to peer
peer0.org1.example.com|2019-06-11 09:46:03.027 UTC [endorser] callChaincode -> INFO 03d [][4f3a0838] Exit chaincode: name:"lscc"  (65ms)
peer0.org1.example.com|2019-06-11 09:46:03.027 UTC [comm.grpc.server] 1 -> INFO 03e unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=172.22.0.7:45318 grpc.code=OK grpc.call_duration=66.989762ms
等待ing...

terminal 2 (2):

(instantiate)
.
.
.
6Z nonode@nohost <0.8502.1> 7f71d237d8 couchdb:5984 172.22.0.5 undefined POST /mychannel_lscc/_all_docs?include_docs=true 200 ok 16
                                   couchdb|[notice] 2019-06-11T10:12:02.830647Z nonode@nohost <0.8502.1> c0852558a4 couchdb:5984 172.22.0.5 undefined GET /mychannel_lscc/papercontract~collection?attachments=true 404 ok 5
                                   couchdb|[notice] 2019-06-11T10:12:02.832818Z nonode@nohost <0.8502.1> b3d316bb8d couchdb:5984 172.22.0.5 undefined GET /mychannel_lscc/papercontract?attachments=true 404 ok 1
                                   couchdb|[notice] 2019-06-11T10:12:02.835082Z nonode@nohost <0.8502.1> aa8ab1771c couchdb:5984 172.22.0.5 undefined GET /mychannel_lscc/papercontract~collection?attachments=true 404 ok 2
                                   couchdb|[notice] 2019-06-11T10:12:02.858070Z nonode@nohost <0.8502.1> 0ad07c06a0 couchdb:5984 172.22.0.5 undefined POST /mychannel_lscc/_bulk_docs 201 ok 13
                                   couchdb|[notice] 2019-06-11T10:12:02.865072Z nonode@nohost <0.8502.1> 39cd49f06b couchdb:5984 172.22.0.5 undefined POST /mychannel_lscc/_ensure_full_commit 201 ok 6
                                   couchdb|[notice] 2019-06-11T10:12:02.885759Z nonode@nohost <0.8577.1> af4195c801 couchdb:5984 172.22.0.5 undefined GET /mychannel_lscc/_index 200 ok 11
                                   couchdb|[notice] 2019-06-11T10:12:02.893070Z nonode@nohost <0.8502.1> 82bbdb070e couchdb:5984 172.22.0.5 undefined GET /mychannel_/statedb_savepoint?attachments=true 200 ok 24
                                   couchdb|[notice] 2019-06-11T10:12:02.924619Z nonode@nohost <0.8502.1> 874c66f233 couchdb:5984 172.22.0.5 undefined PUT /mychannel_/statedb_savepoint 201 ok 30
                    peer0.org1.example.com|2019-06-11 10:12:02.927 UTC [kvledger] CommitWithPvtData -> INFO 04f [mychannel] Committed block [1] with 1 transaction(s) in 124ms (state_validation=30ms block_commit=8ms state_commit=82ms)
                                   couchdb|[notice] 2019-06-11T10:12:02.937805Z nonode@nohost <0.8502.1> 0d3230430f couchdb:5984 172.22.0.5 undefined GET /mychannel_lscc/papercontract?attachments=true 200 ok 4

等待ing...

再打开一个terminal 3:

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/configuration/cli$ docker-compose -f docker-co
mpose.yml up -d cliMagnetoCorp
Creating cliMagnetoCorp
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/configuration/cli$

再打开一个terminal 4,看下fabric-tools镜像是否已经拉取下来并加入到网络中:

wang@wang:~$ docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                            NAMES
ff2452e367f2        hyperledger/fabric-tools     "/bin/bash"              2 minutes ago       Up 2 minutes                                                         cliMagnetoCorp
93b835a82ff9        gliderlabs/logspout          "/bin/logspout"          6 minutes ago       Up 6 minutes        127.0.0.1:8000->80/tcp                           logspout
9285fc24031f        hyperledger/fabric-peer      "peer node start"        8 minutes ago       Up 8 minutes        0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.example.com
de39f974843d        hyperledger/fabric-couchdb   "tini -- /docker-ent…"   8 minutes ago       Up 8 minutes        4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp       couchdb
1da87858a10f        hyperledger/fabric-ca        "sh -c 'fabric-ca-se…"   8 minutes ago       Up 8 minutes        0.0.0.0:7054->7054/tcp                           ca.example.com
d13b7c783c0e        hyperledger/fabric-orderer   "orderer"                8 minutes ago       Up 8 minutes        0.0.0.0:7050->7050/tcp                           orderer.example.com
wang@wang:~$

再打开一个terminal 5:
执行下面的命令的时候,在terminal 2中会打印,如terminal 2(1)所示。

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/contract/lib$ docker exec cliMagnetoCorp peer 
chaincode install -n papercontract -v 0 -p /opt/gopath/src/github.com/contract -l node
2019-06-11 09:46:02.918 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-06-11 09:46:02.918 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-06-11 09:46:03.028 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" > 
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/contract/lib$

terminal 5中继续,terminal 2 中继续打印,如terminal 2(2)所示如上:
这里每次实例化的时候都会失败,失败这一过程大概等它结束要10分钟,然后再次实例化就会成功。
实例化terminal:

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/contract/lib$ docker exec cliMagnetoCorp peer 
chaincode instantiate -n papercontract -v 0 -l node -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' -C mychannel -P "AND ('Org1MSP.member')"
2019-06-12 01:54:01.550 UTC [chaincodeCmd] InitCmdFactory -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
2019-06-12 01:54:01.553 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default escc
2019-06-12 01:54:01.553 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default vscc
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg timeout expired while starting chaincode papercontract:0 for transaction

监控terminal:

 couchdb|[notice] 2019-06-12T01:54:01.567781Z nonode@nohost <0.625.0> 7e68d93e2c couchdb:5984 172.24.0.5 undefined GET /mychannel_lscc/papercontract?attachments=true 404 ok 7





               couchdb|[info] 2019-06-12T01:59:53.496445Z nonode@nohost <0.47.0> -------- alarm_handler: {set,{system_memory_high_watermark,[]}}
        competent_ride|
        competent_ride|> @ampretia/[email protected] install /chaincode/output/node_modules/@ampretia/x509
        competent_ride|> node-gyp rebuild
        competent_ride|
        competent_ride|make: Entering directory '/chaincode/output/node_modules/@ampretia/x509/build'
        competent_ride|  CXX(target) Release/obj.target/x509/src/addon.o
        competent_ride|  CXX(target) Release/obj.target/x509/src/x509.o
^[[A        competent_ride|../src/x509.cc: In function 'v8::Local<v8::Value> try_parse(const string&)':
        competent_ride|../src/x509.cc:395:38: warning: value computed is not used [-Wunused-value]
        competent_ride|     BIO_set_close(ext_bio, BIO_CLOSE);
        competent_ride|                                      ^
        competent_ride|  SOLINK_MODULE(target) Release/obj.target/x509.node
        competent_ride|  COPY Release/x509.node
        competent_ride|make: Leaving directory '/chaincode/output/node_modules/@ampretia/x509/build'
        competent_ride|
        competent_ride|> [email protected] install /chaincode/output/node_modules/grpc
        competent_ride|> node-pre-gyp install --fallback-to-build --l
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/contract/lib$ docker exec cliMagnetoCorp peer 
chaincode instantiate -n papercontract -v 0 -l node -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' -C mychannel -P "AND ('Org1MSP.member')"
2019-06-11 10:11:58.290 UTC [chaincodeCmd] InitCmdFactory -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
2019-06-11 10:11:58.296 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default escc
2019-06-11 10:11:58.296 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default vscc
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/contract/lib$ 

成功时,terminal 4中:

wang@wang:~$ docker ps
CONTAINER ID        IMAGE                                                                                                         COMMAND                  CREATED             STATUS              PORTS                                            NAMES
a0920b11c57c        dev-peer0.org1.example.com-papercontract-0-d96abb966a1ed760663cf0a061700a902284832716c55b4cb05eca53054fe011   "/bin/sh -c 'cd /usr…"   32 seconds ago      Up 31 seconds                                                        dev-peer0.org1.example.com-papercontract-0
ff2452e367f2        hyperledger/fabric-tools                                                                                      "/bin/bash"              35 minutes ago      Up 35 minutes                                                        cliMagnetoCorp
93b835a82ff9        gliderlabs/logspout                                                                                           "/bin/logspout"          39 minutes ago      Up 39 minutes       127.0.0.1:8000->80/tcp                           logspout
9285fc24031f        hyperledger/fabric-peer                                                                                       "peer node start"        41 minutes ago      Up 41 minutes       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.example.com
de39f974843d        hyperledger/fabric-couchdb                                                                                    "tini -- /docker-ent…"   41 minutes ago      Up 41 minutes       4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp       couchdb
1da87858a10f        hyperledger/fabric-ca                                                                                         "sh -c 'fabric-ca-se…"   41 minutes ago      Up 41 minutes       0.0.0.0:7054->7054/tcp                           ca.example.com
d13b7c783c0e        hyperledger/fabric-orderer                                                                                    "orderer"                41 minutes ago      Up 41 minutes       0.0.0.0:7050->7050/tcp                           orderer.example.com
wang@wang:~$ 

terminal 6中:

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ node addToWallet.js 
/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application/addToWallet.js:9
const { FileSystemWallet, X509WalletMixin } = require('fabric-network');
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ node -v
v4.2.6
出现这个问题的原因就是这个了,版本。

换了版本之后:

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ node -v
v10.9.0
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ node addToWallet.js 
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'fabric-network'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application/addToWallet.js:9:47)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ 
这个问题解决如下:
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ npm install --unsafe-perm fabric-network
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).

> [email protected] install /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application/node_modules/pkcs11js
> node-gyp rebuild

make: Entering directory '/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application/node_modules/pkcs11js/build'
  CXX(target) Release/obj.target/pkcs11/src/main.o
  CXX(target) Release/obj.target/pkcs11/src/dl.o
  CXX(target) Release/obj.target/pkcs11/src/const.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/error.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/v8_convert.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/template.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/mech.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_aes.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_rsa.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_ecdh.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/pkcs11.o
  CXX(target) Release/obj.target/pkcs11/src/async.o
  CXX(target) Release/obj.target/pkcs11/src/node.o
  SOLINK_MODULE(target) Release/obj.target/pkcs11.node
  COPY Release/pkcs11.node
make: Leaving directory '/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application/node_modules/pkcs11js/build'

> [email protected] install /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp WARN Using request for node-pre-gyp https download 
[grpc] Success: "/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application/node_modules/grpc/src/node/extension_binary/node-v64-linux-x64-glibc/grpc_node.node" is installed via remote
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

+ [email protected]
added 222 packages from 185 contributors and audited 842 packages in 353.828s
found 0 vulnerabilities

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ 
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ node addToWallet.js
done

再出现缺少解析yaml的npm模块,解决方式同上。

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ node issue.js 
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'js-yaml'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application/issue.js:19:14)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ npm install --unsafe-perm js-yaml
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

+ [email protected]
added 1 package from 4 contributors and audited 846 packages in 3.187s
found 0 vulnerabilities
wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/magnetocorp/application$ node issue.js 
Connect to Fabric gateway.
Use network channel: mychannel.
Use org.papernet.commercialpaper smart contract.
Submit commercial paper issue transaction.
Process issue transaction response.
MagnetoCorp commercial paper : 00001 successfully issued for value 5000000
Transaction complete.
Disconnect from Fabric gateway.
Issue program complete.

以上都是在terminal6中完成的。

terminal7:
看好路径!

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/digibank/configuration/cli$ docker-compose -f docker-compo
se.yml up -d cliDigiBank
WARNING: Found orphan containers (cliMagnetoCorp) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Creating cliDigiBank

terminal 8:先用npm install命令安装应用程序require的package
看好路径!

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/digibank/application$ npm install
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).

> [email protected] install /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/digibank/application/node_modules/pkcs11js
> node-gyp rebuild

make: Entering directory '/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/digibank/application/node_modules/pkcs11js/build'
  CXX(target) Release/obj.target/pkcs11/src/main.o
  CXX(target) Release/obj.target/pkcs11/src/dl.o
  CXX(target) Release/obj.target/pkcs11/src/const.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/error.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/v8_convert.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/template.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/mech.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_aes.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_rsa.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_ecdh.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/pkcs11.o
  CXX(target) Release/obj.target/pkcs11/src/async.o
  CXX(target) Release/obj.target/pkcs11/src/node.o
  SOLINK_MODULE(target) Release/obj.target/pkcs11.node
  COPY Release/pkcs11.node
make: Leaving directory '/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/digibank/application/node_modules/pkcs11js/build'

> [email protected] install /home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/digibank/application/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp WARN Using request for node-pre-gyp https download 
[grpc] Success: "/home/wang/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/digibank/application/node_modules/grpc/src/node/extension_binary/node-v64-linux-x64-glibc/grpc_node.node" is installed via remote
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

added 320 packages from 230 contributors and audited 1491 packages in 62.608s
found 0 vulnerabilities

下载完依赖后,运行addToWallet程序,将Balaji的身份添加到他的钱包中:

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/digibank/application$ node addToWallet.js 
done

Balaji现在可以使用buy.js程序来提交交换商业票据00001所有权的交易:
buy的时候负责监控的terminal会打印日志。

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/digibank/application$ node buy.js 
Connect to Fabric gateway.
Use network channel: mychannel.
Use org.papernet.commercialpaper smart contract.
Submit commercial paper buy transaction.
Process buy transaction response.
MagnetoCorp commercial paper : 00001 successfully purchased by DigiBank
Transaction complete.
Disconnect from Fabric gateway.
Buy program complete.

wang@wang:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/commercial-paper/organization/digibank/application$ node redeem.js 
Connect to Fabric gateway.
Use network channel: mychannel.
Use org.papernet.commercialpaper smart contract.
Submit commercial paper redeem transaction.
Process redeem transaction response.
MagnetoCorp commercial paper : 00001 successfully redeemed with MagnetoCorp
Transaction complete.
Disconnect from Fabric gateway.
Redeem program complete.

猜你喜欢

转载自blog.csdn.net/u010931295/article/details/91454761