crypto-config.yaml 内容如下
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# ---------------------------------------------------------------------------
# "OrdererOrgs" - Definition of organizations managing orderer nodes
# ---------------------------------------------------------------------------
OrdererOrgs:
# ---------------------------------------------------------------------------
# Orderer
# ---------------------------------------------------------------------------
- Name: Orderer
Domain: example.com
# ---------------------------------------------------------------------------
# "Specs" - See PeerOrgs below for complete description
# ---------------------------------------------------------------------------
Specs:
- Hostname: orderer
# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
# ---------------------------------------------------------------------------
# Org1
# ---------------------------------------------------------------------------
- Name: Org1
Domain: org1.example.com
EnableNodeOUs: true
# ---------------------------------------------------------------------------
# "Specs"
# ---------------------------------------------------------------------------
# Uncomment this section to enable the explicit definition of hosts in your
# configuration. Most users will want to use Template, below
#
# Specs is an array of Spec entries. Each Spec entry consists of two fields:
# - Hostname: (Required) The desired hostname, sans the domain.
# - CommonName: (Optional) Specifies the template or explicit override for
# the CN. By default, this is the template:
#
# "{{.Hostname}}.{{.Domain}}"
#
# which obtains its values from the Spec.Hostname and
# Org.Domain, respectively.
# ---------------------------------------------------------------------------
# Specs:
# - Hostname: foo # implicitly "foo.org1.example.com"
# CommonName: foo27.org5.example.com # overrides Hostname-based FQDN set above
# - Hostname: bar
# - Hostname: baz
# ---------------------------------------------------------------------------
# "Template"
# ---------------------------------------------------------------------------
# Allows for the definition of 1 or more hosts that are created sequentially
# from a template. By default, this looks like "peer%d" from 0 to Count-1.
# You may override the number of nodes (Count), the starting index (Start)
# or the template used to construct the name (Hostname).
#
# Note: Template and Specs are not mutually exclusive. You may define both
# sections and the aggregate nodes will be created for you. Take care with
# name collisions
# ---------------------------------------------------------------------------
Template:
Count: 2
# Start: 5
# Hostname: {{.Prefix}}{{.Index}} # default
# ---------------------------------------------------------------------------
# "Users"
# ---------------------------------------------------------------------------
# Count: The number of user accounts _in addition_ to Admin
# ---------------------------------------------------------------------------
Users:
Count: 1
# ---------------------------------------------------------------------------
# Org2: See "Org1" for full specification
# ---------------------------------------------------------------------------
- Name: Org2
Domain: org2.example.com
EnableNodeOUs: true
Template:
Count: 2
Users:
Count: 1
cryptogen generate --config=./crypto-config.yaml
configtx.yaml 文件内容如下
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
---
################################################################################
#
# Profile
#
# - Different configuration profiles may be encoded here to be specified
# as parameters to the configtxgen tool
#
################################################################################
Profiles:
TwoOrgsOrdererGenesis:
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
TwoOrgsChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
Capabilities:
<<: *ApplicationCapabilities
################################################################################
#
# Section: Organizations
#
# - This section defines the different organizational identities which will
# be referenced later in the configuration.
#
################################################################################
Organizations:
# SampleOrg defines an MSP using the sampleconfig. It should never be used
# in production but may be used as a template for other definitions
- &OrdererOrg
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: OrdererOrg
# ID to load the MSP definition as
ID: OrdererMSP
# MSPDir is the filesystem path which contains the MSP configuration
MSPDir: crypto-config/ordererOrganizations/example.com/msp
- &Org1
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org1MSP
# ID to load the MSP definition as
ID: Org1MSP
MSPDir: crypto-config/peerOrganizations/org1.example.com/msp
AnchorPeers:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer0.org1.example.com
Port: 7051
- &Org2
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org2MSP
# ID to load the MSP definition as
ID: Org2MSP
MSPDir: crypto-config/peerOrganizations/org2.example.com/msp
AnchorPeers:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer0.org2.example.com
Port: 7051
################################################################################
#
# SECTION: Orderer
#
# - This section defines the values to encode into a config transaction or
# genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults
# Orderer Type: The orderer implementation to start
# Available types are "solo" and "kafka"
OrdererType: solo
Addresses:
- orderer.example.com:7050
# Batch Timeout: The amount of time to wait before creating a batch
BatchTimeout: 2s
# Batch Size: Controls the number of messages batched into a block
BatchSize:
# Max Message Count: The maximum number of messages to permit in a batch
MaxMessageCount: 10
# Absolute Max Bytes: The absolute maximum number of bytes allowed for
# the serialized messages in a batch.
AbsoluteMaxBytes: 99 MB
# Preferred Max Bytes: The preferred maximum number of bytes allowed for
# the serialized messages in a batch. A message larger than the preferred
# max bytes will result in a batch larger than preferred max bytes.
PreferredMaxBytes: 512 KB
Kafka:
# Brokers: A list of Kafka brokers to which the orderer connects
# NOTE: Use IP:port notation
Brokers:
- 127.0.0.1:9092
# Organizations is the list of orgs which are defined as participants on
# the orderer side of the network
Organizations:
################################################################################
#
# SECTION: Application
#
# - This section defines the values to encode into a config transaction or
# genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults
# Organizations is the list of orgs which are defined as participants on
# the application side of the network
Organizations:
################################################################################
#
# SECTION: Capabilities
#
# - This section defines the capabilities of fabric network. This is a new
# concept as of v1.1.0 and should not be utilized in mixed networks with
# v1.0.x peers and orderers. Capabilities define features which must be
# present in a fabric binary for that binary to safely participate in the
# fabric network. For instance, if a new MSP type is added, newer binaries
# might recognize and validate the signatures from this type, while older
# binaries without this support would be unable to validate those
# transactions. This could lead to different versions of the fabric binaries
# having different world states. Instead, defining a capability for a channel
# informs those binaries without this capability that they must cease
# processing transactions until they have been upgraded. For v1.0.x if any
# capabilities are defined (including a map with all capabilities turned off)
# then the v1.0.x peer will deliberately crash.
#
################################################################################
Capabilities:
# Channel capabilities apply to both the orderers and the peers and must be
# supported by both. Set the value of the capability to true to require it.
Global: &ChannelCapabilities
# V1.1 for Global is a catchall flag for behavior which has been
# determined to be desired for all orderers and peers running v1.0.x,
# but the modification of which would cause incompatibilities. Users
# should leave this flag set to true.
V1_1: true
# Orderer capabilities apply only to the orderers, and may be safely
# manipulated without concern for upgrading peers. Set the value of the
# capability to true to require it.
Orderer: &OrdererCapabilities
# V1.1 for Order is a catchall flag for behavior which has been
# determined to be desired for all orderers running v1.0.x, but the
# modification of which would cause incompatibilities. Users should
# leave this flag set to true.
V1_1: true
# Application capabilities apply only to the peer network, and may be safely
# manipulated without concern for upgrading orderers. Set the value of the
# capability to true to require it.
Application: &ApplicationCapabilities
# V1.1 for Application is a catchall flag for behavior which has been
# determined to be desired for all peers running v1.0.x, but the
# modification of which would cause incompatibilities. Users should
# leave this flag set to true.
V1_1: true
export FABRIC_CFG_PATH=$PWD
mkdir dir channel-artifacts
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/mychannel.tx -channelID mychannel
命令成功执行后,进入channel-artifacts 文件夹,会看到生成的创世区块文件和创建频道交易数据文件
genesis.block
mychannel.tx
docker-orderer.yaml 文件内容如下
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
version: '2'
services:
orderer.example.com:
container_name: orderer.example.com
image: hyperledger/fabric-orderer:latest
environment:
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=steven_default - ORDERER_GENERAL_LOGLEVEL=DEBUG - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 - ORDERER_GENERAL_LISTENPORT=7050 - ORDERER_GENERAL_GENESISMETHOD=file - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block - ORDERER_GENERAL_LOCALMSPID=OrdererMSP - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp # enabled TLS
- ORDERER_GENERAL_TLS_ENABLED=TRUE - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: orderer
volumes:
- ./channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block - ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp - ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls networks:
default:
aliases:
- steven ports:
- 7050:7050
启动orderer容器
docker-compose -f docker-orderer.yaml up -d
KEY文件
cd ./crypto-config/peerOrganizations/org1.example.com/ca
这个路径下有一个文件名以 _sk 结尾的文件
FABRIC_CA_SERVER_TLS_KEYFILE
command
配置项替换成实际的_sk文件
- FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/e1f396671ed85eb422a1cf8f596cc68fabb00d902b6a51c238e933a181795ae7_sk
command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/e1f396671ed85eb422a1cf8f596cc68fabb00d902b6a51c238e933a181795ae7_sk -b admin:adminpw -d'
配置文件内容如下
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
version: '2'
services:
couchdb:
container_name: couchdb
image: hyperledger/fabric-couchdb:latest
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
# environment:
# - COUCHDB_USER=
# - COUCHDB_PASSWORD=
# Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
# for example map it to utilize Fauxton User Interface in dev environments.
ports:
- "5984:5984"
ca:
container_name: ca
image: hyperledger/fabric-ca:latest
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server - FABRIC_CA_SERVER_CA_NAME=ca - FABRIC_CA_SERVER_TLS_ENABLED=TRUE - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/e1f396671ed85eb422a1cf8f596cc68fabb00d902b6a51c238e933a181795ae7_sk ports:
- "7054:7054" command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/e1f396671ed85eb422a1cf8f596cc68fabb00d902b6a51c238e933a181795ae7_sk -b admin:adminpw -d'
volumes:
- ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
peer0.org1.example.com:
container_name: peer0.org1.example.com
image: hyperledger/fabric-peer:latest
environment:
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
- CORE_PEER_ID=peer0.org1.example.com - CORE_PEER_NETWORKID=steven - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 - CORE_PEER_CHAINCODELISTENADDRESS=peer0.org1.example.com:7052 - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 - CORE_PEER_LOCALMSPID=Org1MSP
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock # the following setting starts chaincode containers on the same
# bridge network as the peers
# https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=steven_default # - CORE_LOGGING_LEVEL=INFO
- CORE_LOGGING_LEVEL=DEBUG - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true - CORE_PEER_GOSSIP_USELEADERELECTION=true - CORE_PEER_GOSSIP_ORGLEADER=false - CORE_PEER_PROFILE_ENABLED=false - CORE_PEER_TLS_ENABLED=TRUE - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt volumes:
- /var/run/:/host/var/run/ - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start
ports:
- 7051:7051 - 7052:7052 - 7053:7053 depends_on:
- couchdb networks:
default:
aliases:
- steven
cli:
container_name: cli
image: hyperledger/fabric-tools:latest
tty: true
stdin_open: true
environment:
- GOPATH=/opt/gopath - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock - CORE_LOGGING_LEVEL=DEBUG # - CORE_LOGGING_LEVEL=INFO
- CORE_PEER_ID=cli - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 - CORE_PEER_LOCALMSPID=Org1MSP - CORE_PEER_TLS_ENABLED=TRUE - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key - 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 - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run/ - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric/steven/chaincode/go - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts depends_on:
# - orderer.example.com
- peer0.org1.example.com # - peer1.org1.example.com
# - peer0.org2.example.com
# - peer1.org2.example.com
networks:
default:
aliases:
- steven
启动peer0.org1 节点容器
docker-compose -f docker-peer.yaml up -d
登入cli容器
docker exec -it cli bash
创建频道
peer channel create -o orderer.example.com:7050 -c mychannel -t 50 -f ./channel-artifacts/mychannel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
日志中可以看到
[channelCmd] readBlock -> INFO 020 Received block: 0
0号区块,即频道里的创世区块,已经被正常创建了。
在当前路径下执行ls,可以看到生成了 mychannel.block 文件,这个文件保存了创世区块的内容,说明创建频道成功。
环境变量 CORE_PEER_ADDRESS 定义了要操作的目标节点
查看这个环境变量的值,
echo $CORE_PEER_ADDRESS
peer0.org1.example.com:7051
可以看到目前要操作的目标节点是peer0.org1
加入频道
peer channel join -b mychannel.block
查看频道信息
root@7fdedcc1183b:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel list
2018-08-14 03:52:28.753 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-08-14 03:52:28.753 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-08-14 03:52:28.754 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-08-14 03:52:28.755 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AB4070A5C08031A0C08FCA3C9DB0510...631A0D0A0B4765744368616E6E656C73
2018-08-14 03:52:28.755 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 99844B080D2E7B509EDD67B6DC7F5898AF1562D4AAC3A3593010844922AA0304
Channels peers has joined:
mychannel
2018-08-14 03:52:28.757 UTC [main] main -> INFO 006 Exiting.....
可以看到 节点已经成功加入了mychannel频道
root@7fdedcc1183b:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel getinfo -c mychannel
2018-08-14 03:54:32.992 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-08-14 03:54:32.992 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-08-14 03:54:32.993 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-08-14 03:54:32.993 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AB4070A5C08031A0C08F8A4C9DB0510...6E496E666F0A096D796368616E6E656C
2018-08-14 03:54:32.993 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: D19350DDC8B2042CB89C5F8A1EE06B7A196916B29BB44B82E51CEA3703448F25
Blockchain info: {"height":1,"currentBlockHash":"VbnvfMzMoQ3Bvbdf6BZcvtEj41W2657lQTptDsGTii0="}
2018-08-14 03:54:32.995 UTC [main] main -> INFO 006 Exiting.....
root@7fdedcc1183b:/opt/gopath/src/github.com/hyperledger/fabric/peer#
在这个频道里区块链的高度为1,也就是说目前只有1个区块,也就是0号创世区块
cd chaincode/go/chaincode_example02/go
go get -u --tags nopkcs11 github.com/hyperledger/fabric/core/chaincode/shim
go build --tags nopkcs11 -o chaincode_example02
编译完成后,在当前目录会生成名为 chaincode_example02 的可执行文件
在peer节点的docker-peer.yaml 文件中
volumes:
- /var/run/:/host/var/run/ - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric/steven/chaincode/go
peer chaincode install -n mycc -p github.com/hyperledger/fabric/steven/chaincode/go/chaincode_example02/go -v 1.0
-p 参数定义chaincode所在路径
因为
chaincode所在的完整路径为
/opt/gopath/src/github.com/hyperledger/fabric/steven/chaincode/go/chaincode_example02/go
因为定义了环境变量 GOPATH=/opt/gopath
所以 -p 参数只需要提供 github.com/hyperledger/fabric/steven/chaincode/go/chaincode_example02/go
peer channel install 命令会自动到 $GOPATH/src/ github.com/hyperledger/fabric/steven/chaincode/go/chaincode_example02/go
找chaincode
peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mycc -c '{"Args":["init","A","10","B","10"]}' -P "OR ('Org1MSP.member')" -v 1.0 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer chaincode query -C mychannel -n mycc -c '{"Args":["query", "A"]}'
2018-08-14 06:24:31.987 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-08-14 06:24:31.987 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-08-14 06:24:31.987 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-08-14 06:24:31.987 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-08-14 06:24:31.987 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-08-14 06:24:31.987 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AC4070A6C08031A0C089FEBC9DB0510...6E6E656C1A0A0A0571756572790A0141
2018-08-14 06:24:31.987 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: D3D6DBE27AF65A95CD956D28F79DD1E3BD9E2B18E2DD13B5CE8217F72A86FF12
Query Result: 10
2018-08-14 06:24:31.999 UTC [main] main -> INFO 008 Exiting.....
peer chaincode query -C mychannel -n mychannel -c '{"Args":["query", "B"]}'
2018-08-14 06:24:57.225 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-08-14 06:24:57.225 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-08-14 06:24:57.225 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-08-14 06:24:57.225 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-08-14 06:24:57.225 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-08-14 06:24:57.225 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AC3070A6B08031A0B08B9EBC9DB0510...6E6E656C1A0A0A0571756572790A0142
2018-08-14 06:24:57.225 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 6A27E793D0F7E6CD473137EC984FB9D5803F66F80B64D2FF47034F705A7DE699
Query Result: 10
2018-08-14 06:24:57.242 UTC [main] main -> INFO 008 Exiting.....
分别查询A 和 B的值,目前都是 10,
peer chaincode invoke -C mychannel -n mycc -c '{"Args":["invoke", "A", "B", "3"]}' --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
再次query A和B
root@7fdedcc1183b:/opt/gopath/src/github.com/hyperledger/fabric/steven/chaincode# peer chaincode query -C mychannel -n mycc -c '{"Args":["query", "A"]}'
2018-08-14 06:28:10.210 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-08-14 06:28:10.210 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-08-14 06:28:10.210 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-08-14 06:28:10.210 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-08-14 06:28:10.211 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-08-14 06:28:10.211 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AC3070A6B08031A0B08FAECC9DB0510...6E6E656C1A0A0A0571756572790A0141
2018-08-14 06:28:10.211 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 946CB5FE517D93FEC27065BB3534B69E5FD73AA5E8C08E2A56FC6C071F549DD3
Query Result: 7
2018-08-14 06:28:10.222 UTC [main] main -> INFO 008 Exiting.....
root@7fdedcc1183b:/opt/gopath/src/github.com/hyperledger/fabric/steven/chaincode# peer chaincode query -C mychannel -n mycc -c '{"Args":["query", "B"]}'
2018-08-14 06:28:14.821 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-08-14 06:28:14.821 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-08-14 06:28:14.821 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-08-14 06:28:14.821 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-08-14 06:28:14.821 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-08-14 06:28:14.822 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AC4070A6C08031A0C08FEECC9DB0510...6E6E656C1A0A0A0571756572790A0142
2018-08-14 06:28:14.822 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 81FC2A154BAE944DFB58FC8B2E7BA3E9A10820BCA74EBB93658030027A34904A
Query Result: 13
2018-08-14 06:28:14.830 UTC [main] main -> INFO 008 Exiting.....
A减去了3变成了7
B加上了3变成了13