hyperledger-fabric2.0 相关命令

目录

fabrci-docker清除环境

生成所需的证书文件,执行完成之后会在当前目录下产生crypto-config文件

根据configtx.yaml 生成创世区块和频道认证文件

生成Orderer服务启动的初始区块(即系统通道的创世区块文件) genesis.block

生成新建应用通道的配置交易(即用于创建应用通道的配置交易文件) channel.tx

生成org1锚节点配置更新文件  Org1MSPanchors.tx

生成org2锚节点配置更新文件 Org2MSPanchors.tx

//同步指定节点(提取指定区块并写入文件)

//创建通道(生成了加入通道所需要的mychannel.block)

//加入通道

//update anchor peers

//打包合约

//安装合约到节点

//验证合约是否安装到节点

//当前组织同意合约定义

//检查合约定义是否满足策略

//提交合约

//查看节点已提交合约

//初始化合约,执行init方法,设置a:100 b:100

//查询a的余额

//做一笔交易,a账户向b账户转移10个知产

//查看区块信息


 

 

fabrci-docker清除环境

./byfn.sh down

docker-compose -f docker-compose-cli.yaml down --volumes --remove-orphans

docker volume prune

 

生成所需的证书文件,执行完成之后会在当前目录下产生crypto-config文件

cryptogen generate --config=./crypto-config.yaml

 

根据configtx.yaml 生成创世区块和频道认证文件

生成Orderer服务启动的初始区块(即系统通道的创世区块文件) genesis.block

configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block

 

生成新建应用通道的配置交易(即用于创建应用通道的配置交易文件) channel.tx

configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel

 

生成org1锚节点配置更新文件  Org1MSPanchors.tx

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP

 

生成org2锚节点配置更新文件 Org2MSPanchors.tx

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP

 

//同步指定节点(提取指定区块并写入文件)

peer channel fetch 0 mychannel.block -o orderer.example.com:7050 -c mychannel --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

 

//创建通道(生成了加入通道所需要的mychannel.block)

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

 

//加入通道

peer channel join -b mychannel.block

 

//update anchor peers

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

 

//打包合约

peer lifecycle chaincode package mycc.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/abstore/go/ --lang golang --label mycc_1

 

//安装合约到节点

peer lifecycle chaincode install mycc.tar.gz

 

//验证合约是否安装到节点

peer lifecycle chaincode queryinstalled

 

//当前组织审批合约 //谁代表组织?里面的机制是什么 需要研究审批的流程是什么

peer lifecycle chaincode approveformyorg --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 --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:4622fb602aa60c6368716a70474dc9d9ba2776200f70eccca07a4df4360eaff3 --sequence 1 —waitForEvent

 

//检查合约定义是否满足策略#检查指定的链码是否可以向通道提交 (不同合约进来之后也可以满足策略?)

peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 2 --output json --init-required

 

//提交合约(是不是有可能有两个合约在跑,修改同一份数据??)

peer lifecycle chaincode commit -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 --channelID mychannel --name 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 --version 1 --sequence 1 --init-required

 

//查看节点已提交合约

peer lifecycle chaincode querycommitted --channelID mychannel --name mycc

 

//初始化合约,执行init方法,设置a:100 b:100

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 --isInit -c '{"Args":["Init","a","100","b","100"]}'

 

 

//查询a的余额

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

 

//做一笔交易,a账户向b账户转移10个知产(chaincode 代码(a b 账目转移逻辑修改后测试一下)

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"]}'

 

//查看区块信息 cli客户端的权限??

peer channel getinfo -c mychannel

 

org==》channel==》chaincode的相互关系

用户的权限和身份认证的流程

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
由于 Hyperledger-Fabric 是一个底层的区块链框架,它的系统架构比较复杂,包括了多个组件和模块。下面是一个简化的 Hyperledger-Fabric 系统架构图: ![Hyperledger-Fabric 系统架构图](https://i.imgur.com/A8I6NuL.png) 从图中可以看出,Hyperledger-Fabric 的系统架构主要包括以下组件和模块: - 客户端(Client):客户端是区块链系统的使用者,可以通过 SDK 与区块链网络进行交互,包括提交交易、查询数据等操作。客户端可以是 Web 应用程序、移动应用程序、IoT 设备等。 - 区块链网络(Blockchain Network):区块链网络由多个 Peer 和一个 Ordering Service 组成,每个 Peer 都有自己的账本,用于保存区块链上的交易记录和状态数据。 - Peer 节点(Peer Node):Peer 节点是区块链网络的核心,它可以执行智能合约、验证交易,并将交易记录和状态数据保存到自己的账本中。Peer 节点之间可以相互通信和交互数据,还可以进行背书(Endorsement)操作,即对交易进行签名,用于确保交易的真实性和合法性。 - Ordering Service 节点(Ordering Service Node):Ordering Service 节点是区块链网络的一部分,负责将交易打包成区块,并将区块传播到所有的 Peer 节点。Ordering Service 节点可以使用不同的共识算法来处理交易,例如 Kafka、Raft 等。 - 智能合约(Smart Contract):智能合约是 Hyperledger-Fabric 的核心概念,它是一段可编程的代码,用于对交易进行处理和执行。智能合约可以使用不同的编程语言编写,例如 Go、Java、JavaScript 等。 - 认证和授权服务(Authentication and Authorization Service):认证和授权服务是用于验证客户端和 Peer 节点身份的服务,它可以使用不同的身份验证协议和技术,例如 TLS、PKI 等。 - 数据库(Database):Hyperledger-Fabric 使用不同的数据库系统来保存交易记录和状态数据,例如 LevelDB、CouchDB 等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值