區(qū)塊鏈之Fabric(三)動(dòng)態(tài)增刪機(jī)構(gòu)

Fabric 是聯(lián)盟鏈,一個(gè) channel 就好比一個(gè)聯(lián)盟剃浇,如果有新的機(jī)構(gòu)需要加入巾兆,則必須得到聯(lián)盟內(nèi)的成員的認(rèn)可。

正是基于這樣的場(chǎng)景虎囚,fabric 在為 channel 新增 org 時(shí)角塑,會(huì)涉及諸多的權(quán)限和證書操作。


為 Channel 動(dòng)態(tài)新增 Org 有以下幾步:

  1. 為新 org 生成證書
  2. 為新 org 生成配置文件
  3. 生成和提交新 org 的配置
    1. peer channel fetch config 創(chuàng)建添加新 org 的配置交易淘讥,為網(wǎng)絡(luò)新增 org
    2. peer channel signconfigtx 為配置交易簽名圃伶,需網(wǎng)絡(luò)中 MAJORITY 的 org 都簽名
    3. peer channel update 提交簽名后的配置交易至 orderer
  4. 將新 org 添加入 channel
    1. 啟動(dòng)新 org 集群,一般會(huì)有一個(gè) cli 和多個(gè) peer
    2. peer channel fetch 于 cli 中從 orderer 中獲取 channel 創(chuàng)世塊
    3. peer channel join 將新 org 下的 peer 加入 channel
  5. 升級(jí)chaincode和背書策略
    1. peer chaincode install 為新 org 的 peer 安裝 chaincode蒲列,于新 org 的 cli 中完成
    2. peer chaincode install, 為其他 org 升級(jí) chaincode窒朋,于原 org 的 cli 中完成
    3. peer chaincode upgrade 升級(jí)背書策略,于原 org 的 cli 中完成
  6. 測(cè)試是否成功

此文通過 fabric-samples 下的 first-network 樣例為基礎(chǔ)蝗岖,在其區(qū)塊鏈網(wǎng)絡(luò)上侥猩,為通道 mychannel 新增一個(gè) Org3,Org3 包含兩個(gè) peer抵赢。

初始環(huán)境

fabric-samples 地址為 https://github.com/hyperledger/fabric-samples 欺劳, 本文采用其中的 first-network 實(shí)驗(yàn)。

first-network 啟動(dòng)后铅鲤,會(huì)默認(rèn)創(chuàng)建 1 個(gè) orderer 節(jié)點(diǎn)划提,4個(gè) peer 節(jié)點(diǎn)(其中 2個(gè)屬于 org1,2個(gè)屬于 org2)邢享,并提供一個(gè) cli 用于相關(guān)操作鹏往。

docker ps 之后輸出如下:

CONTAINER ID        IMAGE                                                                                                  COMMAND                  CREATED              STATUS              PORTS                                              NAMES
a36d576296f4        dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab   "chaincode -peer.add…"   About a minute ago   Up About a minute                                                      dev-peer1.org2.example.com-mycc-1.0
70789dd829f0        dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9   "chaincode -peer.add…"   About a minute ago   Up About a minute                                                      dev-peer0.org1.example.com-mycc-1.0
c961ab191471        dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b   "chaincode -peer.add…"   About a minute ago   Up About a minute                                                      dev-peer0.org2.example.com-mycc-1.0
8314e683df95        hyperledger/fabric-tools:latest                                                                        "/bin/bash"              About a minute ago   Up About a minute                                                      cli
c80bb0cdbb3e        hyperledger/fabric-peer:latest                                                                         "peer node start"        About a minute ago   Up About a minute   0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp     peer1.org1.example.com
656efc4c4b94        hyperledger/fabric-orderer:latest                                                                      "orderer"                About a minute ago   Up About a minute   0.0.0.0:7050->7050/tcp                             orderer.example.com
1f6777d60647        hyperledger/fabric-peer:latest                                                                         "peer node start"        About a minute ago   Up About a minute   0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp   peer1.org2.example.com
8be768d5aed0        hyperledger/fabric-peer:latest                                                                         "peer node start"        About a minute ago   Up About a minute   0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp     peer0.org2.example.com
0680044f68b9        hyperledger/fabric-peer:latest                                                                         "peer node start"        About a minute ago   Up About a minute   0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp     peer0.org1.example.com


自動(dòng)化動(dòng)態(tài)添加

first-network 直接提供了自動(dòng)化添加的腳本 eyfn.sh。執(zhí)行 ./eyfn.sh up 即可自動(dòng)化為 channel 添加 org3驼仪。此法因不具擴(kuò)展性掸犬,且不方便理解 fabric,因此不再贅述绪爸。以下是執(zhí)行后的輸出,若成功宙攻,會(huì)輸出 All GOOD 奠货。

[work@gzhxy-fsg-fpu-hyperledger01 first-network]$ ./eyfn.sh up
Starting with channel 'mychannel' and CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] Y
proceeding ...
/home/work/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/cryptogen
... ...
... ...
... ...
2018-04-09 03:37:24.644 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 1B7235C3DC2AF4B066928DDEA387D4A0524357DEB4978C23DB70B01B893DBC3A
Query Result: 80
2018-04-09 03:37:24.651 UTC [main] main -> INFO 008 Exiting.....
===================== Query on peer0.org3 on channel 'mychannel' is successful =====================
========= All GOOD, EYFN test execution completed ===========
 _____   _   _   ____
| ____| | \ | | |  _ \
|  _|   |  \| | | | | |
| |___  | |\  | | |_| |
|_____| |_| \_| |____/

雖然不贅述 eyfn.sh,但腳本和手動(dòng)部署原理是一致的座掘,可以仔細(xì)學(xué)習(xí)递惋。


為 channel 動(dòng)態(tài)添加 Org

step1: 為新 org 生成證書

cd org3-artifacts/
cryptogen generate --config=./org3-crypto.yaml

會(huì)依據(jù) org3-crypto.yaml 生成柔滔,生成后的文件位于 org3-artifacts/crypto-config/ 下

org3-crypto.yaml 文件中 Org3 的配置如下:

PeerOrgs:
  - Name: Org3
    Domain: org3.example.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1


step2: 為新 org 生成配置文件

導(dǎo)入配置

export FABRIC_CFG_PATH=$PWD


將 org3 的配置以 json 格式輸出

configtxgen 命令會(huì)從 configtx.yaml 讀取 Org3 相關(guān)配置,生成 json 輸出至 org3.json

configtxgen -printOrg Org3MSP -profile ./configtx.yaml > ../channel-artifacts/org3.json

若成功萍虽,輸出如下:

2018-04-09 17:03:12.625 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-04-09 17:03:12.626 CST [msp] getMspConfig -> INFO 002 Loading NodeOUs


configtx.yaml 配置如下

-printOrg Org3MSP 中的名字要與 configtx.yaml 配置中的 Organizations睛廊,Name 一致。

Organizations:
    - &Org3
        Name: Org3MSP
        ID: Org3MSP
        MSPDir: crypto-config/peerOrganizations/org3.example.com/msp
        AnchorPeers:
            - Host: peer0.org3.example.com
              Port: 7051


生成的 org3.json 結(jié)構(gòu)大致如下

{
  "groups": {},
  "mod_policy": "Admins",
  "policies": {
    "Admins": {
      "mod_policy": "Admins",
      "policy": {
        "type": 1,
        "value": {
          "identities": [
            {
              "principal": {
                "msp_identifier": "Org3MSP",
                "role": "ADMIN"
              },
              "principal_classification": "ROLE"
            }
          ],
          ... ...
      "version": "0"
    },
    "Readers": {
      ... ...
    },
    "Writers": {
      ... ...
    }
  },
  "values": {
    "MSP": {
      "mod_policy": "Admins",
      "value": {
        "config": {
          "FabricNodeOUs": {
            "Enable": true,
            "clientOUIdentifier": {
              "certificate": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS00... ....FURS0tLS0tCg==",
              "organizational_unit_identifier": "client"
            },
            "peerOUIdentifier": {
              "certificate": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS00... ....FURS0tLS0tCg==",
              "organizational_unit_identifier": "peer"
            }
          },
          "admins": [
            "certificate": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS00... ....FURS0tLS0tCg==",
          ],
          "crypto_config": {
            "identity_identifier_hash_function": "SHA256",
            "signature_hash_family": "SHA2"
          },
          "name": "Org3MSP",
          "root_certs": [
            "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS00... ....FURS0tLS0tCg=="
          ],
          "tls_root_certs": [
            "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS00... ....FURS0tLS0tCg=="
          ]
        },
        "type": 0
      },
      "version": "0"
    }
  },
  "version": "0"
}


將 orderer 的證書和密鑰拷貝至 org3 的 crypto-config 目錄下

cp -r ../crypto-config/ordererOrganizations crypto-config/


step3: 生成和提交新 org 的配置

通過 step 1~2杉编,已經(jīng)生成了 Org3 的證書和配置超全,但這僅僅是在本地文件系統(tǒng),還未于區(qū)塊鏈網(wǎng)絡(luò)產(chǎn)生關(guān)聯(lián)邓馒。

為 channel 新加 Org嘶朱,對(duì) Fabric 而言,是以一筆交易的形式提交的光酣。

因此要使得這筆交易能順利完成疏遏,需要提交 org3 的配置,獲得權(quán)限認(rèn)證救军;然后于網(wǎng)絡(luò)中發(fā)起更新的交易

登錄 cli 節(jié)點(diǎn)

docker exec -it cli bash


為 cli 節(jié)點(diǎn)新增配置

export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem


安裝 jq 工具

jq 是 Linux 下命令行處理 JSON 的工具财异,可以對(duì) JSON 進(jìn)行過濾、格式化唱遭、修改等等操作宝当。

apt-get -y update && apt-get -y install jq


獲取當(dāng)前 channel 的配置

peer channel fetch config config_block.pb -o orderer.example.com:7050 -c mychannel --tls --cafile $ORDERER_CA

參數(shù) --tls 根據(jù)區(qū)塊鏈網(wǎng)絡(luò)配置添加,若區(qū)塊鏈網(wǎng)絡(luò)配置需要 tls胆萧,沒有 tls 會(huì)報(bào)

2018-04-09 07:34:00.783 UTC [channelCmd] getNewestBlock -> ERRO 00c Received error: rpc error: code = Unavailable desc = transport is closing
Error: rpc error: code = Unavailable desc = transport is closing 錯(cuò)誤


若成功庆揩,會(huì)輸出

2018-04-09 07:34:40.358 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-04-09 07:34:40.358 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-04-09 07:34:40.363 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-04-09 07:34:40.363 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-04-09 07:34:40.363 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-04-09 07:34:40.363 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-04-09 07:34:40.363 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-04-09 07:34:40.363 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AED060A1508021A060890AFACD60522...52D6438017E412080A020A0012020A00
2018-04-09 07:34:40.364 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: DC1DEEDD462E9009BF249B5B0481D06333B699DF58764FDA9312B63144C443AE
2018-04-09 07:34:40.367 UTC [channelCmd] readBlock -> DEBU 00a Received block: 4
2018-04-09 07:34:40.368 UTC [msp] GetLocalMSP -> DEBU 00b Returning existing local MSP
2018-04-09 07:34:40.368 UTC [msp] GetDefaultSigningIdentity -> DEBU 00c Obtaining default signing identity
2018-04-09 07:34:40.368 UTC [msp] GetLocalMSP -> DEBU 00d Returning existing local MSP
2018-04-09 07:34:40.368 UTC [msp] GetDefaultSigningIdentity -> DEBU 00e Obtaining default signing identity
2018-04-09 07:34:40.368 UTC [msp/identity] Sign -> DEBU 00f Sign: plaintext: 0AED060A1508021A060890AFACD60522...2C68120C0A041A02080212041A020802
2018-04-09 07:34:40.368 UTC [msp/identity] Sign -> DEBU 010 Sign: digest: 15C3B41F571FCCAE261C280B4C3EB8A4F73DB7FA0A1E15FF11AE08072808D8A2
2018-04-09 07:34:40.371 UTC [channelCmd] readBlock -> DEBU 011 Received block: 2
2018-04-09 07:34:40.371 UTC [main] main -> INFO 012 Exiting.....


修改原配置文件,新增 org3 配置

1. 解碼原有網(wǎng)絡(luò)的配置文件 config_block.pb跌穗。

configtxlator proto_decode 命令將 protobuf 內(nèi)容轉(zhuǎn)為 JSON 格式订晌。

然后通過 jq 命令行將其中部分取出,輸出至 config.json

configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > config.json

config_block.pb 內(nèi)容是一堆配置和證書信息蚌吸,部分如下:

 M?Ui??????
??F_z??'k?4?_O ??hy??#"??_?G?g?o?????????k?z
?z
?y
?
???"    mychannel?
?

OrdererMSP?-----BEGIN CERTIFICATE-----
MIICCzCCAbKgAwIBAgIQV2YjEb05t8NkbNvOF1xylDAKBggqhkjOPQQDAjBpMQsw
CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy
YW5jaXNjbzEUMBIGA1UEChMLZXhhbXBsZS5jb20xFzAVBgNVBAMTDmNhLmV4YW1w
bGUuY29tMB4XDTE4MDQwOTA2MDkxNloXDTI4MDQwNjA2MDkxNlowWDELMAkGA1UE
BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lz
Y28xHDAaBgNVBAMTE29yZGVyZXIuZXhhbXBsZS5jb20wWTATBgcqhkjOPQIBBggq
hkjOPQMBBwNCAAQMxQEdNLTLIU1paNblHQl9US27di5RXYu3cO0sdpjT58/l1eUP
5lNzneKx6Qg4iS/oZfJfX7mQhISKusLiyNnko00wSzAOBgNVHQ8BAf8EBAMCB4Aw
DAYDVR0TAQH/BAIwADArBgNVHSMEJDAigCAQY5DwOeZLuo8fL/jgwbf3b0OafLoE
6laY/dMS6N1mcjAKBggqhkjOPQQDAgNHADBEAiAl1yE4iRkX/OKKeNrwj3ZG/Zml
nWEF4ULvNh17oH5ZTQIgIHnp7cEZ2fSMBGE1gObW/ADBfXau2VCcLEwA2I0wWFo=
-----END CERTIFICATE-----
?u?z??K 14?8Y??"v|??s
??b?H

Application??#
Org2MSP??!
MSP?!?!?!
Org2MSP?-----BEGIN CERTIFICATE-----
... ...
... ...

輸出的 config.json 格式類似 step2 生成的 org3.json锈拨。


2. 修改 config.json,新增 org3

jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./channel-artifacts/org3.json > modified_config.json


3. 將 config.json 和 modified_config.json 轉(zhuǎn)為 protobuf 格式

configtxlator proto_encode --input config.json --type common.Config > original_config.pb
configtxlator proto_encode --input modified_config.json --type common.Config > modified_config.pb


4. 根據(jù) config.pb 和 modified_config.pb 計(jì)算出 org3_update.pb
類似于 diff 操作羹唠,但是針對(duì) protobuf 格式奕枢,因此會(huì)多出好多操作。蛋疼

configtxlator compute_update --channel_id mychannel --original original_config.pb --updated modified_config.pb > config_update.pb


5. 解碼 config_update.pb 為 json佩微,然后用 jq 修改缝彬,然后在編碼為 protobuf 格式,最終輸出 org3_update_in_envelope.pb

configtxlator proto_decode --input config_update.pb  --type common.ConfigUpdate > config_update.json
echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . > config_update_in_envelope.json
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope > org3_update_in_envelope.pb


為 Org3 新配置簽名

為配置交易簽名哺眯,需要 channel 中的大多數(shù) Org 對(duì)其進(jìn)行簽名谷浅。

對(duì)于 mychannel 而言,已有了 org1,org2一疯,因此新增 org3 時(shí)需要 org1撼玄、org2 都簽名。

簽名操作于 cli 中完成墩邀,通過更改環(huán)境變量掌猛,改變簽名者的身份。


切換至 Org1 進(jìn)行簽名眉睹,Org1 有兩個(gè) peer荔茬,需采用 Anchor Peer,即 peer0.org1.example.com

export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=peer0.org1.example.com:7051

切換至 Org2 進(jìn)行簽名辣往,Org2 有兩個(gè) peer兔院,需采用 Anchor Peer,即 peer0.org2.example.com

export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
export CORE_PEER_ADDRESS=peer0.org2.example.com:7051


peer channel signconfigtx 命令是由 admin 為配置交易(configuration transaction)簽名站削。

需要分別于 org1 環(huán)境變量坊萝、org2 環(huán)境變量下分別執(zhí)行一次。

peer channel signconfigtx -f org3_update_in_envelope.pb

若成功许起,以下為 Org1 簽名后的輸出:

2018-04-09 08:28:52.786 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-04-09 08:28:52.786 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-04-09 08:28:52.786 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-04-09 08:28:52.786 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-04-09 08:28:52.786 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-04-09 08:28:52.786 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-04-09 08:28:52.786 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-04-09 08:28:52.786 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AB6060A074F7267314D535012AA062D...72697465727312002A0641646D696E73
2018-04-09 08:28:52.787 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: 7CC3CB504C7AC5588E1C347305262066757B45E8F99F39D18836B4A60EB22901
2018-04-09 08:28:52.787 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-04-09 08:28:52.787 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-04-09 08:28:52.787 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-04-09 08:28:52.787 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-04-09 08:28:52.787 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AED060A1508021A0608C4C8ACD60522...DBB67FA8B0E04B91898888F898CA2EF5
2018-04-09 08:28:52.787 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 8FCE6B4E8A5A9E89D1CE6F624D1CA0AE04EEC1448ACC3B67F294241DB7A96960
2018-04-09 08:28:52.787 UTC [main] main -> INFO 010 Exiting.....


提交簽名后的配置交易至 orderer

export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer channel update -f org3_update_in_envelope.pb -c mychannel -o orderer.example.com:7050 --tls --cafile $ORDERER_CA


驗(yàn)證 orderer 是否完成排序十偶,并于 peer 入鏈

于宿主機(jī)下,查看 docker 內(nèi)輸出

docker logs -ft peer0.org1.example.com
docker logs -ft peer0.org2.example.com

若入鏈园细,可以看到以下輸出:

2018-04-09T09:06:21.465870592Z 2018-04-09 09:06:21.465 UTC [kvledger] CommitWithPvtData -> INFO 03d Channel [mychannel]: Committed block [5] with 1 transaction(s)

輸出顯示惦积,當(dāng)前提交的塊號(hào)是 5。

塊 0 是創(chuàng)世塊猛频;1~2 是一些初始化狮崩;3~4 是實(shí)例化與調(diào)用 chaincode ,更新配置鹿寻。


step4: 將新 org 添加入 channel

啟動(dòng)新 org 集群

Org3 集群包含一個(gè) org3cli 和 2 個(gè) peer

docker-compose -f docker-compose-org3.yaml up -d

輸出

Creating volume "net_peer0.org3.example.com" with default driver
Creating volume "net_peer1.org3.example.com" with default driver
WARNING: Found orphan containers (cli, peer1.org1.example.com, peer1.org2.example.com, peer0.org2.example.com, peer0.org1.example.com, orderer.example.com) for this project. If you removed or renamed this service in your compose file, youCreating peer1.org3.example.com ... done
Creating Org3cli ... done
Creating peer1.org3.example.com ...
Creating Org3cli ...

docker ps 查看新啟動(dòng)的鏡像睦柴,比之前會(huì)多出以下三個(gè)

CONTAINER ID        IMAGE                                                                                                  COMMAND                  CREATED             STATUS              PORTS                                              NAMES
7b80ce329182        hyperledger/fabric-tools:latest                                                                        "/bin/bash"              35 seconds ago      Up 33 seconds                                                          Org3cli
f7990009b206        hyperledger/fabric-peer:latest                                                                         "peer node start"        35 seconds ago      Up 34 seconds       0.0.0.0:12051->7051/tcp, 0.0.0.0:12053->7053/tcp   peer1.org3.example.com
9bff0310d237        hyperledger/fabric-peer:latest                                                                         "peer node start"        35 seconds ago      Up 34 seconds       0.0.0.0:11051->7051/tcp, 0.0.0.0:11053->7053/tcp   peer0.org3.example.com

docker-compose-org3.yaml 配置如下:

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

version: '2'

volumes:
  peer0.org3.example.com:
  peer1.org3.example.com:

networks:
  byfn:

services:

  peer0.org3.example.com:
    container_name: peer0.org3.example.com
    extends:
      file: base/peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org3.example.com
      - CORE_PEER_ADDRESS=peer0.org3.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org3.example.com:7051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
        - /var/run/:/host/var/run/
        - ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp:/etc/hyperledger/fabric/msp
        - ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls:/etc/hyperledger/fabric/tls
        - peer0.org3.example.com:/var/hyperledger/production
    ports:
      - 11051:7051
      - 11053:7053
    networks:
      - byfn

  peer1.org3.example.com:
    container_name: peer1.org3.example.com
    extends:
      file: base/peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org3.example.com
      - CORE_PEER_ADDRESS=peer1.org3.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org3.example.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org3.example.com:7051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
        - /var/run/:/host/var/run/
        - ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/msp:/etc/hyperledger/fabric/msp
        - ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/tls:/etc/hyperledger/fabric/tls
        - peer1.org3.example.com:/var/hyperledger/production
    ports:
      - 12051:7051
      - 12053:7053
    networks:
      - byfn


  Org3cli:
    container_name: Org3cli
    image: hyperledger/fabric-tools:$IMAGE_TAG
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      #- CORE_LOGGING_LEVEL=INFO
      - CORE_LOGGING_LEVEL=DEBUG
      - CORE_PEER_ID=Org3cli
      - CORE_PEER_ADDRESS=peer0.org3.example.com:7051
      - CORE_PEER_LOCALMSPID=Org3MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
        - /var/run/:/host/var/run/
        - ./../chaincode/:/opt/gopath/src/github.com/chaincode
        - ./org3-artifacts/crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
        - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
    depends_on:
      - peer0.org3.example.com
      - peer1.org3.example.com
    networks:
      - byfn


登錄新 org 集群,獲取當(dāng)前 channel 配置

1. 登錄 Org3Cli

docker exec -it Org3cli bash


2. 添加環(huán)境變量

export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
export CHANNEL_NAME=mychannel


3. 獲取當(dāng)前 channel 的配置

Org3Cli 從 orderer 中獲取 channel 創(chuàng)世塊配置

peer channel fetch 0 mychannel.block -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA

輸出:

2018-04-09 09:40:57.475 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-04-09 09:40:57.475 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-04-09 09:40:57.479 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-04-09 09:40:57.479 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-04-09 09:40:57.479 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-04-09 09:40:57.480 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-04-09 09:40:57.480 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-04-09 09:40:57.480 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AED060A1508021A0608A9EAACD60522...460550DD7A5812080A021A0012021A00
2018-04-09 09:40:57.480 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: 4A8C7BC724EEDA0B6D132395D371938BA7328D8E7F8C49B34F765FE3859AC106
2018-04-09 09:40:57.485 UTC [channelCmd] readBlock -> DEBU 00a Received block: 0
2018-04-09 09:40:57.485 UTC [main] main -> INFO 00b Exiting.....


將 Org 所有 Peer 加入 channel

Org3 下?lián)碛?2 個(gè) Peer毡熏,peer0 和 peer1坦敌,其下所有 peer 均需要執(zhí)行加入 channel 操作。

切換至 Peer0痢法,即 peer0.org3.example.com狱窘,將其加入 channel

export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
export CORE_PEER_ADDRESS=peer0.org3.example.com:7051

切換至 Peer1,即 peer1.org3.example.com财搁,將其加入 channel

export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/tls/ca.crt
export CORE_PEER_ADDRESS=peer1.org3.example.com:7051

需要分別于 peer0 環(huán)境變量蘸炸、peer1 環(huán)境變量下分別執(zhí)行一次。

peer channel join -b mychannel.block

peer0 與 peer1 輸出差不多妇拯,如下:

2018-04-09 09:43:22.968 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-04-09 09:43:22.968 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-04-09 09:43:22.972 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-04-09 09:43:22.974 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AB4070A5C08011A0C08BAEBACD60510...21BD37B89AAE1A080A000A000A000A00
2018-04-09 09:43:22.974 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 00E3992EDAC99AC1FCAD1181FFE1993435C02EEAF8A5311CBEB935A8A0F9A68A
2018-04-09 09:43:23.007 UTC [channelCmd] executeJoin -> INFO 006 Successfully submitted proposal to join channel
2018-04-09 09:43:23.008 UTC [main] main -> INFO 007 Exiting.....


step5: 升級(jí)chaincode和背書策略

最后一步幻馁,是增加 chaincode 版本號(hào)并更新背書策略洗鸵。

為 Org3 安裝 2.0 版本的 chaincode

當(dāng)前 Org1 和 Org2 的 chaincode 版本號(hào)是 1越锈,Org3 需要更新此版本的 chaincode仗嗦,因此為 Org3 直接安裝版本為 2 的 chaincode,省得先安裝再升級(jí)甘凭。

peer chaincode install -n mycc -v 2.0 -p github.com/chaincode/chaincode_example02/go/

輸出如下:

2018-04-09 10:24:46.493 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-04-09 10:24:46.493 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-04-09 10:24:46.493 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-04-09 10:24:46.493 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-04-09 10:24:46.493 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode enabled
2018-04-09 10:24:46.543 UTC [golang-platform] getCodeFromFS -> DEBU 006 getCodeFromFS github.com/chaincode/chaincode_example02/go/
2018-04-09 10:24:46.661 UTC [golang-platform] func1 -> DEBU 007 Discarding GOROOT package fmt
2018-04-09 10:24:46.661 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2018-04-09 10:24:46.662 UTC [golang-platform] func1 -> DEBU 009 Discarding provided package github.com/hyperledger/fabric/protos/peer
2018-04-09 10:24:46.662 UTC [golang-platform] func1 -> DEBU 00a Discarding GOROOT package strconv
2018-04-09 10:24:46.662 UTC [golang-platform] GetDeploymentPayload -> DEBU 00b done
2018-04-09 10:24:46.662 UTC [container] WriteFileToPackage -> DEBU 00c Writing file to tarball: src/github.com/chaincode/chaincode_example02/go/chaincode_example02.go
2018-04-09 10:24:46.664 UTC [msp/identity] Sign -> DEBU 00d Sign: plaintext: 0AB4070A5C08031A0C08EEFEACD60510...CAF857000000FFFF354C5FFC001C0000
2018-04-09 10:24:46.664 UTC [msp/identity] Sign -> DEBU 00e Sign: digest: 0E27BFDD36A93200D1519FFACF65F1813491E3FAADD90AD5227245C6A4A1445A
2018-04-09 10:24:46.667 UTC [chaincodeCmd] install -> DEBU 00f Installed remotely response:<status:200 payload:"OK" >
2018-04-09 10:24:46.667 UTC [main] main -> INFO 010 Exiting.....


為 Org1 的 peer0稀拐、Org2 的 peer0 安裝 2.0 版本 chaincode

登錄原 cli,對(duì) org1丹弱,org2 進(jìn)行管理德撬。

docker exec -it cli bash


切換至 Org1 進(jìn)行環(huán)境

export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=peer0.org1.example.com:7051

切換至 Org2 進(jìn)行環(huán)境

export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
export CORE_PEER_ADDRESS=peer0.org2.example.com:7051

需執(zhí)行兩次,分別于 org1躲胳,org2 環(huán)境下

peer chaincode install -n mycc -v 2.0 -p github.com/chaincode/chaincode_example02/go


升級(jí)背書策略

升級(jí)背書策略蜓洪,-v 2.0 指明版本號(hào),-P "OR ('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')" 指明新的背書策略(添加了 Org3)坯苹。

peer chaincode upgrade -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --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 -v 2.0 -c '{"Args":["init","a","90","b","210"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')"

若成功隆檀,輸出如下:

2018-04-09 10:45:30.132 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-04-09 10:45:30.132 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-04-09 10:45:30.136 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-04-09 10:45:30.136 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-04-09 10:45:30.136 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode enabled
2018-04-09 10:45:30.136 UTC [chaincodeCmd] upgrade -> DEBU 006 Get upgrade proposal for chaincode <name:"mycc" version:"2.0" >
2018-04-09 10:45:30.136 UTC [msp/identity] Sign -> DEBU 007 Sign: plaintext: 0AC2070A6608031A0B08CA88ADD60510...535010030A04657363630A0476736363
2018-04-09 10:45:30.137 UTC [msp/identity] Sign -> DEBU 008 Sign: digest: 4C4F7827359FBEA37BF97D2BAD15FC9762360DF414BF277A22869CBF7A605DB8
2018-04-09 10:45:39.103 UTC [chaincodeCmd] upgrade -> DEBU 009 endorse upgrade proposal, get response <status:200 message:"OK" payload:"\n\004mycc\022\0032.0\032\004escc\"\004vscc*?\022\020\022\016\010\001\022\002\010\000\022\002\010\001\022\002\010\002\032\r\022\013\n\007Org1MSP\020\003\032\r\022\013\n\007Org2MSP\020\003\032\r\022\013\n\007Org3MSP\020\0032D\n \222G\373\202N!\320\207\017\376y<\360`$\346^\206\361\340\345\213d\351\014[\031On74\000\022 g\357,\324!\221P`u\035X\006\327\257\037\324\334\003\003\251\2628\321\345\262$\360\r\351\220^\\: \235\322J\005\214V\273\257\340\244\273$y\325\215iP\365\211\266'\267<p)\340\020\364`\247\307\323B?\022\020\022\016\010\001\022\002\010\000\022\002\010\001\022\002\010\002\032\r\022\013\n\007Org1MSP\020\001\032\r\022\013\n\007Org2MSP\020\001\032\r\022\013\n\007Org3MSP\020\001" >
2018-04-09 10:45:39.103 UTC [msp/identity] Sign -> DEBU 00a Sign: plaintext: 0AC2070A6608031A0B08CA88ADD60510...430D37D0D4AE72A17EB35E2DA134DA99
2018-04-09 10:45:39.103 UTC [msp/identity] Sign -> DEBU 00b Sign: digest: 23A320F7C7E644FBA5D097D472246F47FD33B7C6A077AFE50F60B36E8ECDC7DC
2018-04-09 10:45:39.103 UTC [chaincodeCmd] upgrade -> DEBU 00c Get Signed envelope
2018-04-09 10:45:39.104 UTC [chaincodeCmd] chaincodeUpgrade -> DEBU 00d Send signed envelope to orderer
2018-04-09 10:45:39.105 UTC [main] main -> INFO 00e Exiting.....


peer chaincode upgrade 命令將為區(qū)塊鏈新增一個(gè)塊,可以在 peer 的輸出中查看

docker logs -ft peer0.org1.example.com

可以看到粹湃,塊號(hào)已經(jīng)升至 6.

2018-04-09T10:45:41.113103936Z 2018-04-09 10:45:41.112 UTC [committer/txvalidator] validateTx -> INFO 203 Find chaincode upgrade transaction for chaincode mycc on channel mychannel with new version 2.0
2018-04-09T10:45:41.113566483Z 2018-04-09 10:45:41.113 UTC [cceventmgmt] HandleStateUpdates -> INFO 204 Channel [mychannel]: Handling LSCC state update for chaincode [mycc]
2018-04-09T10:45:41.115440650Z 2018-04-09 10:45:41.115 UTC [kvledger] CommitWithPvtData -> INFO 205 Channel [mychannel]: Committed block [6] with 1 transaction(s)


step6: 測(cè)試是否成功

發(fā)起一筆查詢

peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'

得到以下結(jié)果恐仑,Query Result: 90

2018-04-09 10:46:56.063 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-04-09 10:46:56.063 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-04-09 10:46:56.063 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-04-09 10:46:56.063 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-04-09 10:46:56.063 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode enabled
2018-04-09 10:46:56.064 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AC2070A6608031A0B08A089ADD60510...6D7963631A0A0A0571756572790A0161
2018-04-09 10:46:56.064 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 5C801C9C2085286736CEEDB46B6E7FDBB83C4B6C472E81BDF2A31E07FE76DAB5
Query Result: 90
2018-04-09 10:46:56.072 UTC [main] main -> INFO 008 Exiting.....

然后,發(fā)起一筆調(diào)用为鳄,調(diào)用是將 a 轉(zhuǎn) 10b

peer chaincode invoke -o orderer.example.com:7050  --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}'

輸出如下:

2018-04-09 10:47:21.151 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-04-09 10:47:21.151 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-04-09 10:47:21.155 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-04-09 10:47:21.155 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-04-09 10:47:21.155 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode enabled
2018-04-09 10:47:21.155 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AC2070A6608031A0B08B989ADD60510...696E766F6B650A01610A01620A023130
2018-04-09 10:47:21.155 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 69ABEEFD6EC7327C6C6FA36F4302965F2C8DC69AD388634A5737726A6C2E8EE8
2018-04-09 10:47:21.163 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AC2070A6608031A0B08B989ADD60510...0EEC6E3A64572217C0ECC4FA2AF449FE
2018-04-09 10:47:21.163 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: E4191E37ED4A0D742CF3C969E348350BA3BC68292A474B64D7B1F71104E5DC59
2018-04-09 10:47:21.165 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 00a ESCC invoke result: version:1 response:<status:200 message:"OK" > payload:"\n \240\361-\006{d\325!\321\017\323Y\254l\303\351\222W\226\275T\255\002\333\260\201\350\230Z<\234\320\022Y\nE\022\024\n\004lscc\022\014\n\n\n\004mycc\022\002\010\006\022-\n\004mycc\022%\n\007\n\001a\022\002\010\006\n\007\n\001b\022\002\010\006\032\007\n\001a\032\00280\032\010\n\001b\032\003220\032\003\010\310\001\"\013\022\004mycc\032\0032.0" endorsement:<endorser:"\n\007Org2MSP\022\246\006-----BEGIN CERTIFICATE-----\nMIICJzCCAc6gAwIBAgIQSt8xNetxpTvWnh7QS9Z9ojAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMi5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu\nb3JnMi5leGFtcGxlLmNvbTAeFw0xODA0MDkwODUzNDRaFw0yODA0MDYwODUzNDRa\nMGoxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMQ0wCwYDVQQLEwRwZWVyMR8wHQYDVQQDExZwZWVyMC5vcmcy\nLmV4YW1wbGUuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEK3WWG/HkydkW\nZ8tjS+WEfEKbn7+O82akp5ckzEKsbN6ucK3rCCM9hUGizEikSXSnxGQ/thB1vkPU\nEZtwjlL+w6NNMEswDgYDVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0j\nBCQwIoAgLw9SFcdoizgo4xv+OMJoM5Ev5gnvDSXI+0AoQGjfXmowCgYIKoZIzj0E\nAwIDRwAwRAIgcsLdt9YS3xkyZ3w+7CPepULC9ScpvPjgbzhQJdWGt34CIHa1fDJp\nSpfEYkXxZVpKsAFDP/+TZ1CR/BipvZj6Ucvc\n-----END CERTIFICATE-----\n" signature:"0E\002!\000\340X\274\360\215\367\304\032\261e\351\225\026C9\262\177\037I\327\000.}\317.\016\245\223\026\374h\211\002 1\202\362\344IU\010\250=\364A\320\235\n\\H\016\354n:dW\"\027\300\354\304\372*\364I\376" >
2018-04-09 10:47:21.165 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00b Chaincode invoke successful. result: status:200
2018-04-09 10:47:21.165 UTC [main] main -> INFO 00c Exiting.....

peer chaincode invoke 會(huì)生成一個(gè)新塊裳仆,同上,可以通過 docker logs -ft peer0.org1.example.com 查看孤钦,此時(shí)塊號(hào)將變?yōu)?7歧斟。

再次調(diào)用查詢命令peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}', 得到以下輸出∑危可以看到 Query Result: 80静袖,說明調(diào)用已經(jīng)成功。

2018-04-09 10:47:40.210 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-04-09 10:47:40.210 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-04-09 10:47:40.210 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-04-09 10:47:40.210 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-04-09 10:47:40.210 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode enabled
2018-04-09 10:47:40.211 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AC2070A6608031A0B08CC89ADD60510...6D7963631A0A0A0571756572790A0161
2018-04-09 10:47:40.211 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: E0206FCC932E0928EBB8D980C0A485AB34FD3F31CCD01F433606DD76F57C5854
Query Result: 80
2018-04-09 10:47:40.219 UTC [main] main -> INFO 008 Exiting.....


參考資料

[1] Hyperledger Fabric 官方手冊(cè)壳猜, http://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html
[2] Fabric學(xué)習(xí)筆記(八) - cli動(dòng)態(tài)添加Org, 作者 mumubin勾徽,https://segmentfault.com/a/1190000013521785

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市统扳,隨后出現(xiàn)的幾起案子喘帚,更是在濱河造成了極大的恐慌,老刑警劉巖咒钟,帶你破解...
    沈念sama閱讀 206,482評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件吹由,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡朱嘴,警方通過查閱死者的電腦和手機(jī)倾鲫,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,377評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門粗合,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人乌昔,你說我怎么就攤上這事隙疚。” “怎么了磕道?”我有些...
    開封第一講書人閱讀 152,762評(píng)論 0 342
  • 文/不壞的土叔 我叫張陵供屉,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我溺蕉,道長(zhǎng)伶丐,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,273評(píng)論 1 279
  • 正文 為了忘掉前任疯特,我火速辦了婚禮哗魂,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘漓雅。我一直安慰自己录别,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,289評(píng)論 5 373
  • 文/花漫 我一把揭開白布故硅。 她就那樣靜靜地躺著庶灿,像睡著了一般。 火紅的嫁衣襯著肌膚如雪吃衅。 梳的紋絲不亂的頭發(fā)上往踢,一...
    開封第一講書人閱讀 49,046評(píng)論 1 285
  • 那天,我揣著相機(jī)與錄音徘层,去河邊找鬼峻呕。 笑死,一個(gè)胖子當(dāng)著我的面吹牛趣效,可吹牛的內(nèi)容都是我干的瘦癌。 我是一名探鬼主播,決...
    沈念sama閱讀 38,351評(píng)論 3 400
  • 文/蒼蘭香墨 我猛地睜開眼跷敬,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼讯私!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起西傀,我...
    開封第一講書人閱讀 36,988評(píng)論 0 259
  • 序言:老撾萬榮一對(duì)情侶失蹤斤寇,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后拥褂,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體娘锁,經(jīng)...
    沈念sama閱讀 43,476評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,948評(píng)論 2 324
  • 正文 我和宋清朗相戀三年饺鹃,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了莫秆。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片间雀。...
    茶點(diǎn)故事閱讀 38,064評(píng)論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖镊屎,靈堂內(nèi)的尸體忽然破棺而出惹挟,到底是詐尸還是另有隱情,我是刑警寧澤杯道,帶...
    沈念sama閱讀 33,712評(píng)論 4 323
  • 正文 年R本政府宣布匪煌,位于F島的核電站责蝠,受9級(jí)特大地震影響党巾,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜霜医,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,261評(píng)論 3 307
  • 文/蒙蒙 一齿拂、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧肴敛,春花似錦署海、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,264評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至镀梭,卻和暖如春刀森,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背报账。 一陣腳步聲響...
    開封第一講書人閱讀 31,486評(píng)論 1 262
  • 我被黑心中介騙來泰國(guó)打工研底, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人透罢。 一個(gè)月前我還...
    沈念sama閱讀 45,511評(píng)論 2 354
  • 正文 我出身青樓榜晦,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親羽圃。 傳聞我的和親對(duì)象是個(gè)殘疾皇子乾胶,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,802評(píng)論 2 345

推薦閱讀更多精彩內(nèi)容