1.获得channel高度:
peer channel getinfo -c $CHANNEL_NAME
可得到返回结果类似如下:
Blockchain info: {"height":6,"currentBlockHash":"cUJls9tYyVfJ6nENRMmRzYgXEwNhSBeSpbXSQSibkJU=","previousBlockHash":"M5er0eSSxwcSDk6xNoG4keykTB/OEg9vOiYXFtOh698="}
2.获取特定的 Block 的详细内容:
2.1设置当前环境:
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.wisedu.com/users/[email protected]/msp
export CORE_PEER_ADDRESS=peer0.org1.wisedu.com:7051
2.2使用peer channel fetch
peer channel fetch newest mychannel.block -o orderer.wisedu.com:7050 -c mychannel
获取最新的区块,并保存为以mychannel.block命名的区块(若省略,则自动保存为mychannel_newest.block)。
peer channel fetch newest -o orderer.wisedu.com:7050 -c mychannel
peer channel fetch [newest|oldest|config|(block number)] [<outputFile>] [Flags]
即fetch后可以跟newest、oldest、config(最近的配置信息)、区块号(如5),输出文件名可以省略(默认为mychannel_newest.block、mychannel_oldest.block、mychannel_config.block、mychannel_(block number).block)。
2.3将mychannel_newest.block从cli容器中拷贝之本地路径(在e2e_standalone下输入):
sudo docker cp e707f6b649a3:/opt/gopath/src/github.com/hyperledger/fabric/peer/mychannel_newest.block /home/matrix/e2e_standalone
2.4将其转换为json文件(在e2e_standalone下输入),即可查看具体信息:
configtxgen --inspectBlock mychannel_newest.block > mychannel_newest.json