peerAddresses 的目的是什么

What's the purpose of peerAddresses

我正在使用 the test network

peer chaincode invoke 可以选择 --peerAddresses 我选择一个或多个节点来执行链代码。 (ref)

the test network tutorial 之后,如果我 运行 InitLedger 在两个对等点上,该命令会抛出错误。

$ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
--peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
--peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
-C mychannel -n basic -c '{"function":"InitLedger","Args":[]}'

Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction 2b3d3a615c2fd99e2503779cc25f923a54103997883548a92184423e67df93a2: error sending: txid: 2b3d3a615c2fd99e2503779cc25f923a54103997883548a92184423e67df93a2(mychannel) exists"

我什么时候可以 运行 在两个对等点上执行命令?

看起来网络将“compares the proposal responses to determine if the proposal responses are the same”。那么为什么我需要指定一个节点,因为其他节点会再次执行命令来验证?

您正在向同一个节点发送同一个交易两次 localhost:7051。删除其中 peerAddresses/tlsRootCertFiles 对。

每笔交易都必须满足链码的endorsement policies。如果在链代码实例化期间未指定,在 Fabric 2.X(具有常规 configtx.yaml)中,默认背书策略需要来自 N/2 + 1 个组织(其中 N 是组织的数量)的节点的背书在频道中)。

客户有责任通过交易提案要求这些背书,并在一次交易中收集所有提案。使用 peerAddresses 您的客户指定在此过程中使用的对等方。

背书后,客户端将交易发送到排序服务以嵌入到一个块中,并将该块传递给所有加入通道的节点以提交到分类帐中。 Committing peers 再次检查提案是否匹配(因为现在它只被客户检查过)并且所有交易都包含所需的签名。但他们不会再次 execute/simulate 链代码操作,这在背书期间已经完成。然后,更新分类帐。在 https://hyperledger-fabric.readthedocs.io/en/release/txflow.html.

中有很好的解释

在你的例子中,问题是你将交易发送到 localhost:7051 两次。您必须只向每个节点发送一次您的交易。例如,一次到 localhost:7051,一次到 localhost:9051。查看此命令中从原始 post.

复制而来的 粗体 文本

$ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example .com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca .crt -C mychannel -n basic -c '{"function":"InitLedger","Args":[]}'

简而言之,您的命令 --peerAddresses 出现了三次而不是两次。