开发环境

安装

git clone https://github.com/hyperledger/fabric
cd fabric/devenv
vagrant up

也就是通过vagrant安装虚拟机,然后执行setup.sh。

启动Peer

进入虚拟机,查看信息

vagrant ssh
ip add

启动第一个 validating peer

docker run --rm -it \
 -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 \
 -e CORE_PEER_ID=vp0 \
 -e CORE_PEER_ADDRESSAUTODETECT=true \
 hyperledger/fabric-peer peer node start

启动第二个 validating peer

docker run --rm -it \
 -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 \
 -e CORE_PEER_ID=vp1 \
 -e CORE_PEER_ADDRESSAUTODETECT=true \
 -e CORE_PEER_DISCOVERY_ROOTNODE=172.17.0.2:30303 \
 hyperledger/fabric-peer peer node start

CORE_PEER_DISCOVERY_ROOTNODE为第一个peer的地址

Chaincode

deploy

CORE_PEER_ADDRESS=172.17.0.2:30303 peer chaincode deploy \
-p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 \
-c '{"Function":"init", "Args": ["a","100", "b", "200"]}'

2016/07/13 07:43:19 Load docker HostConfig: &{Binds:[] CapAdd:[] CapDrop:[] ContainerIDFile: LxcConf:[] Privileged:false PortBindings:map[] Links:[] PublishAllPorts:false DNS:[] DNSSearch:[] ExtraHosts:[] VolumesFrom:[] NetworkMode:host IpcMode: PidMode: UTSMode: RestartPolicy:{Name: MaximumRetryCount:0} Devices:[] LogConfig:{Type: Config:map[]} ReadonlyRootfs:false SecurityOpt:[] CgroupParent: Memory:0 MemorySwap:0 MemorySwappiness:0 OOMKillDisable:false CPUShares:0 CPUSet: CPUSetCPUs: CPUSetMEMs: CPUQuota:0 CPUPeriod:0 BlkioWeight:0 Ulimits:[]}
07:43:19.374 [crypto] main -> INFO 002 Log level recognized 'info', set to INFO
a5389f7dfb9efae379900a41db1503fea2199fe400272b61ac5fe7bd0c6b97cf10ce3aa8dd00cd7626ce02f18accc7e5f2059dae6eb0786838042958352b89fb

invoke

CORE_PEER_ADDRESS=172.17.0.2:30303 peer chaincode invoke \
-n <name_value_returned_from_deploy_command> \
-c '{"Function": "invoke", "Args": ["a", "b", "10"]}'

2016/07/13 07:50:18 Load docker HostConfig: &{Binds:[] CapAdd:[] CapDrop:[] ContainerIDFile: LxcConf:[] Privileged:false PortBindings:map[] Links:[] PublishAllPorts:false DNS:[] DNSSearch:[] ExtraHosts:[] VolumesFrom:[] NetworkMode:host IpcMode: PidMode: UTSMode: RestartPolicy:{Name: MaximumRetryCount:0} Devices:[] LogConfig:{Type: Config:map[]} ReadonlyRootfs:false SecurityOpt:[] CgroupParent: Memory:0 MemorySwap:0 MemorySwappiness:0 OOMKillDisable:false CPUShares:0 CPUSet: CPUSetCPUs: CPUSetMEMs: CPUQuota:0 CPUPeriod:0 BlkioWeight:0 Ulimits:[]}
07:50:18.416 [crypto] main -> INFO 002 Log level recognized 'info', set to INFO
1eb895ec-0f57-4c81-af95-d01d742ea22c

query

CORE_PEER_ADDRESS=172.17.0.2:30303 peer chaincode query \
-l golang \
-n <name_value_returned_from_deploy_command> \
-c '{"Function": "query", "Args": ["a"]}'


2016/07/13 07:52:29 Load docker HostConfig: &{Binds:[] CapAdd:[] CapDrop:[] ContainerIDFile: LxcConf:[] Privileged:false PortBindings:map[] Links:[] PublishAllPorts:false DNS:[] DNSSearch:[] ExtraHosts:[] VolumesFrom:[] NetworkMode:host IpcMode: PidMode: UTSMode: RestartPolicy:{Name: MaximumRetryCount:0} Devices:[] LogConfig:{Type: Config:map[]} ReadonlyRootfs:false SecurityOpt:[] CgroupParent: Memory:0 MemorySwap:0 MemorySwappiness:0 OOMKillDisable:false CPUShares:0 CPUSet: CPUSetCPUs: CPUSetMEMs: CPUQuota:0 CPUPeriod:0 BlkioWeight:0 Ulimits:[]}
07:52:29.284 [crypto] main -> INFO 002 Log level recognized 'info', set to INFO90

Membership

membersrvc

./build/bin/membersrvc

2016/07/14 03:17:40 Log level not recognized '', defaulting to DEBUG: logger: invalid log level
2016/07/14 03:17:40 Working at security level [256]
INFO: 2016/07/14 03:17:40 CA Server (0.1)
INFO: 2016/07/14 03:17:40 Fresh start; creating databases, key pairs, and certificates.
INFO: 2016/07/14 03:17:41 ACA started.
INFO: 2016/07/14 03:17:41 ECA started.
INFO: 2016/07/14 03:17:41 TCA started.
INFO: 2016/07/14 03:17:41 TLSCA started.

启动vp

docker run --rm -it \
-e CORE_VM_ENDPOINT=http://172.17.0.1:2375 \
-e CORE_PEER_ID=vp4 \
-e CORE_PEER_ADDRESSAUTODETECT=true \
-e CORE_SECURITY_ENABLED=true \
-e CORE_SECURITY_PRIVACY=true \
-e CORE_PEER_PKI_ECA_PADDR=172.17.0.1:50051 \
-e CORE_PEER_PKI_TCA_PADDR=172.17.0.1:50051 \
-e CORE_PEER_PKI_TLSCA_PADDR=172.17.0.1:50051 \
-e CORE_SECURITY_ENROLLID=test_vp4 \
-e CORE_SECURITY_ENROLLSECRET=Pqh90CEW5juZ \
hyperledger/fabric-peer peer node start

enroll

# lukas: 1 NPKYL39uKbkj
CORE_PEER_ADDRESS=172.17.0.2:30303 peer network login lukas

03:23:17.785 [crypto] Login -> INFO 02e Registering client [lukas] with name [lukas]...
03:23:17.874 [crypto] register -> INFO 02f [client.lukas] Register crypto engine...
03:23:17.874 [crypto] register -> INFO 030 [client.lukas] Register crypto engine...done.
03:23:17.874 [crypto] Login -> INFO 031 Registering client [lukas] with name [lukas]...done!

密码相关的信息在membersrvc/membersrvc.yaml中配置

results matching ""

    No results matching ""