即使在所有组织批准后也无法提交链码

Unable to commit chaincode even after approving from all the orgs

我已经批准了频道所有组织的链代码。由于以下 checkcommiterreadiness 命令输出 json 批准。

#peer lifecycle chaincode checkcommitreadiness -o localhost:9050 --channelID supplychain-channel --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/freight.example.com/orderers/orderer0.freight.example.com/msp/tlscacerts/tlsca.freight.example.com-cert.pem --name supplychain --version 1.0 --sequence 1 --output json --init-required --signature-policy "AND ('ShipperMSP.peer','FreightMSP.peer','CarrierMSP.peer','CustomMSP.peer','ConsigneeMSP.peer')"
{
    "approvals": {
        "CarrierMSP": true,
        "ConsigneeMSP": true,
        "CustomMSP": true,
        "FreightMSP": true,
        "ShipperMSP": true
    }
}

但是在提交时出现以下错误

#peer lifecycle chaincode commit -o orderer0.freight.example.com:9050 --ordererTLSHostnameOverride orderer0.freight.example.com --tls --version 1.0 --sequence 1 --init-required --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/freight.example.com/orderers/orderer0.freight.example.com/msp/tlscacerts/tlsca.freight.example.com-cert.pem --channelID supplychain-channel --name supplychain

Error: proposal failed with status: 500 - failed to invoke backing implementation of 'CommitChaincodeDefinition': chaincode definition not agreed to by this org (FreightMSP)

这是一个多主机结构网络,使用 docker swarm 托管。尽管我能够在主机本身的链代码生命周期中提交命令之前执行所有命令。但是我收到了这个错误

Error: failed to retrieve endorser client for commit: endorser client failed to connect to localhost:7051: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 127.0.0.1:7051: connect: connection refused"

为了与 swarm 网络中的所有节点通信,我尝试从 CLI 容器执行提交命令,但出现“无法调用 'CommitChaincodeDefinition' 的支持实现”错误。

只需要为提交添加 --signature-policy 即可解决:

peer lifecycle chaincode commit -o orderer0.freight.example.com:9050 --ordererTLSHostnameOverride orderer0.freight.example.com --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/freight.example.com/orderers/orderer0.freight.example.com/msp/tlscacerts/tlsca.freight.example.com-cert.pem --channelID supplychain-channel --name supplychain --peerAddresses peer0.shipper.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/shipper.example.com/peers/peer0.shipper.example.com/tls/ca.crt --peerAddresses peer0.freight.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/freight.example.com/peers/peer0.freight.example.com/tls/ca.crt --peerAddresses peer0.carrier.example.com:11051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/carrier.example.com/peers/peer0.carrier.example.com/tls/ca.crt --peerAddresses peer0.custom.example.com:13051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/custom.example.com/peers/peer0.custom.example.com/tls/ca.crt --peerAddresses peer0.consignee.example.com:15051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/consignee.example.com/peers/peer0.consignee.example.com/tls/ca.crt --version 1 --sequence 1 --init-required --signature-policy "AND ('ShipperMSP.peer','FreightMSP.peer','CarrierMSP.peer','CustomMSP.peer','ConsigneeMSP.peer')"