如何检查hyperledger-fabric中的区块链高度

sar*_*iss 4 hyperledger hyperledger-fabric

我正在玩hyperledger-fabric v.1.0 - 实际上是一个新手.如何检查链条高度?是否有命令或其他东西我可以用来"询问"区块链高度?提前致谢.

Art*_*ger 7

那么,您可以选择如何做到这一点:

  1. 您可以利用peer cli命令行工具通过运行获取最新的可用块

    peer channel fetch newest -o ordererIP:7050 -c mychannel  last.block
    
    Run Code Online (Sandbox Code Playgroud)

接下来,您可以利用configtxlator以下内容解码块的内容:

curl -X POST --data-binary @last.block http://localhost:7059/protolator/decode/common.Block
Run Code Online (Sandbox Code Playgroud)

(注意你需要先开始configtxlator)

  1. 备用路径假定您将使用可用的SDK之一来使用GetChainInfo命令调用QSCC(查询系统链代码).这将返回以下结构:

    type BlockchainInfo struct {
         Height            uint64 `protobuf:"varint,1,opt,name=height" json:"height,omitempty"`
         CurrentBlockHash  []byte `protobuf:"bytes,2,opt,name=currentBlockHash,proto3" json:"currentBlockHash,omitempty"`
         PreviousBlockHash []byte `protobuf:"bytes,3,opt,name=previousBlockHash,proto3" json:"previousBlockHash,omitempty"`
    }
    
    Run Code Online (Sandbox Code Playgroud)

其中包含有关当前分类帐高度的信息.


小智 6

另一种选择。使用cli peer命令行(例如docker exec -it cli bash),您可以执行以下操作:

peer channel getinfo -c mychannel