【问题标题】:Fabric-Sample: Cannot create ledger from genesis block, due to LedgerID already existsFabric-Sample:由于 LedgerID 已经存在,无法从创世块创建分类帐
【发布时间】:2021-03-31 16:28:57
【问题描述】:
我正在尝试fabric-samples balance-transfer 示例,我尝试使用以下命令创建一个新频道。频道已创建,但是当我尝试将对等方加入频道时,出现以下错误。任何人都可以建议我错过或出错的步骤
[client-utils.js]:sendPeersProposal - 承诺被拒绝:错误:
链码错误(状态:500,消息:无法从
创世块,由于 LedgerID 已经存在)
我用来创建新频道配置的命令
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx
./channel.tx -channelID 频道1
我用来创建频道的 REST 调用
curl -s -X POST http://localhost:4000/channels -H
"授权:承载 XXXXXX" -H "内容类型:应用程序/json"
-d'{“频道名称”:“频道1”,
"channelConfigPath":"../artifacts/channel/channel.tx" }'
我用来加入频道的 REST 调用
curl -s -X POST http://localhost:4000/channels/channel1/peers
-H "授权: Bearer XXXXX" -H "content-type: application/json" -d '{ "peers": ["peer1","peer2"] }'
【问题讨论】:
标签:
hyperledger-fabric
hyperledger
【解决方案1】:
在大多数情况下,Cannot create ledger from genesis block, due to LedgerID already exists 表示对等方已加入频道。
如果您在对等点上实例化了链码,那么一种快速测试方法是使用其中一个对等点对账本进行查询。
【解决方案2】:
此错误发生在两种不同的情况下:
如果对等方已经加入了频道,而您正在再次加入。您可以运行 peer channel list 并检查 peer 是否已经加入频道。
当您停止、删除 docker 容器并在 docker-compose.yaml 中再次启动容器时,容器中的对等卷将存储以前的数据。因此,即使您认为您没有创建通道,由于对等容器中的先前卷,此通道信息仍然可用。因此,您还需要通过运行 docker system prune --volumes -f 来删除这些卷。这将删除未使用的卷和网络。
【解决方案3】:
如果遇到类似问题,请检查是否设置了以下环境变量:
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=localhost:7051