Fabric0.6中有pbft实现,但是在1.0共识算法只支持Solo、Kafka、Raft三种。在写毕业论文时,需要用到Pbft,本文档将PBFT加进Fabric1.4中。
Fabric1.4搭建
Fabric2.X搭建
Fabric0.6 PBFT测试
install go
wget -c https://studygolang.com/dl/golang/go1.16.3.linux-amd64.tar.gz
sudo tar -xz -f ./go1.16.3.linux-amd64.tar.gz -C /usr/local
sudo gedit ~/.bashrc
# 把下面这 4 行加入到文件末尾
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$GOPATH:$GOBIN:$GOROOT/bin:$PATH
source ~/.bashrc
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
install docker
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux /ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
sudo groupadd docker
sudo gpasswd -a $USER docker
newgrp docker
docker ps
sudo systemctl daemon-reload
sudo systemctl restart docker
4.测试 docker 是否安装成功, 返回 Hello from Docker!则成功!
docker run hello-world
5. images
https://cr.console.aliyun.com/cn-hangzhou/instances
install docker-compose
sudo apt install docker-compose
Download source code
mkdir -p ~/go/src/github.com/hyperledger && cd ~/go/src/github.com/hyperledger
git clone https://github.com/hyperledger/fabric.git
git clone https://github.com/hyperledger/fabric-samples.git
Download Images
https://cr.console.aliyun.com/?spm=5176.10695662.1362911.3.789c262cY82210
cd ~/go/src/github.com/hyperledger/
git clone https://gitee.com/iceriverdog/fabric-pbft.git
Steps
#生成证书
cryptogen generate --config ./crypto-config.yaml
#生成配置文件
mkdir channel-artifacts
configtxgen --profile Genesis -outputBlock ./channel-artifacts/genesis.block
configtxgen --profile Channel -outputCreateChannelTx ./channel-artifacts/mychannel.tx -channelID mychannel
#启动网络
docker-compose -f docker-compose-cli.yaml up -d
docker ps -a
测试
docker exec -it cli bash
#创建通道
peer channel create \
-o order0.mypbft.com:6051 \
-c mychannel \
-f ./channel-artifacts/mychanel.tx
#加入通道
peer channel join -b mychannel.block
#链码安装
peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
#链码实例化
peer chaincode instantiate \
-o order0.mypbft.com:6050 \
-C mychannel \
-n mycc \
-v 1.0 \
-c '{"Args":["init","a","100","b","100"]}' \
-P "OR ('Org1MSP.peer')"
#链码查询
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
#链码调用
peer chaincode invoke \
-o order0.mypbft.com:6050 \
-C mychannel \
-n mycc \
-c '{"Args":["invoke","a","b","10"]}'
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
#链码升级
peer chaincode install -n mycc -v 2.0 -l golang -p github.com/chaincode_example02/go/
peer chaincode upgrade \
-o order0.pbft.com:6050 \
-C mychannel \
-n mycc \
-v 2.0 \
-c '{"Args":["init","a","100","b","100"]}' \
-P "OR ('Org1MSP.peer')"
成功!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)