如何查看创世区块 Genesis Block和channel.tx文件

查看Block文件:

1.生成创世区块:

configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

生成的文件位于目录 channel-artifacts 下

2.将 Block 详细内容导入到 json 文件查看

configtxgen -inspectBlock channel-artifacts/genesis.block > genesis.block.json

如何查看创世区块 Genesis Block和channel.tx文件_第1张图片

其结构大概如下:

如何查看创世区块 Genesis Block和channel.tx文件_第2张图片 

在 genesis.block 中也包含了相关的证书内容,如下面这段内容:

"values": 
       { "MSP": { 
                 "mod_policy": "Admins", 
                 "value": { 
                         "config": {
                                  "admins": [ 
                                             "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNKekNDQWM2Z0F3SUJBZ0lSQUpjZ0FZVWFUZVRxQml2NWNFVzlVZE13Q2dZSUtvWkl6ajBFQXdJd2NURUwKTUFrR0ExVUVCaE1DVlZNeEV6QVJCZ05WQkFnVENrTmhiR2xtYjNKdWFXRXhGakFVQmdOVkJBY1REVk5oYmlCRwpjbUZ1WTJselkyOHhHREFXQmdOVkJBb1REMjl5WnpFdWQybHpaV1IxTG1OdmJURWJNQmtHQTFVRUF4TVNZMkV1CmIzSm5NUzUzYVhObFpIVXVZMjl0TUI0WERURTVNREl5T0RBeE16VTFPVm9YRFRJNU1ESXlOVEF4TXpVMU9Wb3cKYXpFTE1Ba0dBMVVFQmhNQ1ZWTXhFekFSQmdOVkJBZ1RDa05oYkdsbWIzSnVhV0V4RmpBVUJnTlZCQWNURFZOaApiaUJHY21GdVkybHpZMjh4RHpBTkJnTlZCQXNUQm1Oc2FXVnVkREVlTUJ3R0ExVUVBd3dWUVdSdGFXNUFiM0puCk1TNTNhWE5sWkhVdVkyOXRNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUVJOXVkWFZEVFZ4ejAKaUVWTnJlR3FnWnk1N2ZNUlRiT1dyb3g4ajBtZmkwbTByU2xDaVMvSHlHejR2V0FwRGd3Rnk3U0c2YnZibE5nOApzWW44RWdmMWthTk5NRXN3RGdZRFZSMFBBUUgvQkFRREFnZUFNQXdHQTFVZEV3RUIvd1FDTUFBd0t3WURWUjBqCkJDUXdJb0FnREhLRXRhSHZ2OHB0UXl4TEVlR0JrWjlPek5iVGdjcWFpMjl5TEZ5ZXJWWXdDZ1lJS29aSXpqMEUKQXdJRFJ3QXdSQUlnS1liQmd5RitjZEJpUnp6dUpnNnRuUXRUS1d1NVA4SktrbkFlbWN2TFZCa0NJR0tPdElMWgpWWXFxKy9ibkNSYWhyUHlwRmNRM1BSVXpzRFViL25PVkhvL1kKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo="
                                           ],

"admins" 对应的字符串即为经过 base64 编码的 [email protected] 证书。我们可以通过以下命令查看它:

echo LS0tLS1CRUdJTi<省略>tLS0tLQo=| base64 -d > test.pem 
openssl x509 -in test.pem -text -noout

 查看交易(tx)文件:

1.生成文件,具体查看generateArtifacts.sh中的步骤

2.将 transaction 导出到 JSON 文件进行查看:

configtxgen -inspectChannelCreateTx channel-artifacts/channel.tx > channel.tx.json
configtxgen -inspectChannelCreateTx channel-artifacts/Org1MSPanchors.tx > Org1MSPanchors.tx.json
configtxgen -inspectChannelCreateTx channel-artifacts/Org2MSPanchors.tx > Org2MSPanchors.tx.json

(注意cifigtxgen只能在e2e_cli目录下运行)

你可能感兴趣的:(如何查看创世区块 Genesis Block和channel.tx文件)