0

大家好,我正在尝试使用节点 js 客户端的服务发现来生成交易提案,我遇到的问题是,当发现生成背书计划时,它会将提案发送给同一个对等方并且无法背书,这是其中之一生成了背书计划,不知道为什么,但是同行的名字都是错误的

{
  "chaincode": "auditoria-cc",
  "groups": {
    "G0": {
      "peers": [
        {
          "mspid": "Org1MSP",
          "endpoint": "peer0.org1.autentia-bchain.com:7051",
          "ledger_height": {
            "low": 11,
            "high": 0,
            "unsigned": true
          },
          "chaincodes": [
            {
              "name": "auditoria-cc",
              "version": "1.0"
            }
          ],
          "name": "peer0.org1.autentia-bchain.com"
        }
      ]
    },
    "G1": {
      "peers": [
        {
          "mspid": "Org2MSP",
          "endpoint": "peer0.org2.autentia-bchain.com:7051",
          "ledger_height": {
            "low": 11,
            "high": 0,
            "unsigned": true
          },
          "chaincodes": [
            {
              "name": "auditoria-cc",
              "version": "1.0"
            }
          ],
          "name": "peer0.org1.autentia-bchain.com"
        }
      ]
    },
    "G2": {
      "peers": [
        {
          "mspid": "Org3MSP",
          "endpoint": "peer0.org3.autentia-bchain.com:7051",
          "ledger_height": {
            "low": 11,
            "high": 0,
            "unsigned": true
          },
          "chaincodes": [
            {
              "name": "auditoria-cc",
              "version": "1.0"
            }
          ],
          "name": "peer0.org1.autentia-bchain.com"
        }
      ]
    },
    "G3": {
      "peers": [
        {
          "mspid": "Org4MSP",
          "endpoint": "peer0.org4.autentia-bchain.com:7051",
          "ledger_height": {
            "low": 11,
            "high": 0,
            "unsigned": true
          },
          "chaincodes": [
            {
              "name": "auditoria-cc",
              "version": "1.0"
            }
          ],
          "name": "peer0.org1.autentia-bchain.com"
        }
      ]
    }
  },
  "layouts": [
    {
      "G1": 1,
      "G2": 1,
      "G0": 1
    },
    {
      "G3": 1,
      "G0": 1,
      "G1": 1
    },
    {
      "G2": 1,
      "G3": 1,
      "G0": 1
    },
    {
      "G2": 1,
      "G3": 1,
      "G1": 1
    }
  ],
  "plan_id": "{\"chaincodes\":[{\"name\":\"auditoria-cc\"}]}",
  "endorsements": {

  }
}

这是发送提案时的日志

[2019-05-13 12:39:39.894] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _endorse - starting layout plan 0
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _endorse_layout - start
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G2:0 - start
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G2:0 - send endorsement to peer0.org1.autentia-bchain.com
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G3:1 - start
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G3:1 - send endorsement to peer0.org1.autentia-bchain.com
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:2 - start
[2019-05-13 12:39:39.896] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:2 - send endorsement to peer0.org1.autentia-bchain.com
[2019-05-13 12:39:39.902] [WARN] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:2 - endorsement failed - Error: failed to execute transaction fe2fb28959f06b693e5b834ecfe5fab3aabe8e393f4cc1b2376db7b5aed9f096: error sending: txid: fe2fb28959f06b693e5b834ecfe5fab3aabe8e393f4cc1b2376db7b5aed9f096(auditoria-channel) exists
[2019-05-13 12:39:39.902] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:2 - not able to get a completed endorsement
[2019-05-13 12:39:39.902] [WARN] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G3:1 - endorsement failed - Error: failed to execute transaction fe2fb28959f06b693e5b834ecfe5fab3aabe8e393f4cc1b2376db7b5aed9f096: error sending: txid: fe2fb28959f06b693e5b834ecfe5fab3aabe8e393f4cc1b2376db7b5aed9f096(auditoria-channel) exists
[2019-05-13 12:39:39.902] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G3:1 - not able to get a completed endorsement
[2019-05-13 12:39:39.965] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G2:0 - endorsement completed to peer0.org1.autentia-bchain.com - 200

编辑 1:初始化日志

[2019-05-13 17:31:18.543] [DEBUG] Helper - getClientForOrg - ****** END Org1 test1 


[2019-05-13 17:31:18.544] [DEBUG] invoke-chaincode - Successfully got the fabric client for the organization "Org1"
[2019-05-13 17:31:18.544] [DEBUG] Helper - [NetworkConfig101.js]: getChannel - name auditoria-channel
[2019-05-13 17:31:18.544] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.546] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-05-13 17:31:18.546] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.546] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org1.autentia-bchain.com
[2019-05-13 17:31:18.547] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-05-13 17:31:18.547] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org1.autentia-bchain.com
[2019-05-13 17:31:18.547] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: _addPeersToChannel - peer0.org1.autentia-bchain.com - grpcs://localhost:7051
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org2.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-05-13 17:31:18.548] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org1.autentia-bchain.com
[2019-05-13 17:31:18.548] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org2
[2019-05-13 17:31:18.548] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org2.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org2.autentia-bchain.com
[2019-05-13 17:31:18.549] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.549] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org2
[2019-05-13 17:31:18.549] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.549] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org2.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.549] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org2.autentia-bchain.com
[2019-05-13 17:31:18.549] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.549] [DEBUG] Helper - [NetworkConfig101.js]: _addPeersToChannel - peer0.org2.autentia-bchain.com - grpcs://localhost:8051
[2019-05-13 17:31:18.550] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org3.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.553] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-05-13 17:31:18.553] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.554] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.554] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org1.autentia-bchain.com
[2019-05-13 17:31:18.554] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.555] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org2
[2019-05-13 17:31:18.555] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.555] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org2.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.555] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org2.autentia-bchain.com
[2019-05-13 17:31:18.555] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.555] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org3
[2019-05-13 17:31:18.555] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.555] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org3.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org3.autentia-bchain.com
[2019-05-13 17:31:18.556] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org3
[2019-05-13 17:31:18.556] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org3.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org3.autentia-bchain.com
[2019-05-13 17:31:18.556] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: _addPeersToChannel - peer0.org3.autentia-bchain.com - grpcs://localhost:9051
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org4.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.557] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-05-13 17:31:18.557] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.557] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.557] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org1.autentia-bchain.com
[2019-05-13 17:31:18.558] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.558] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org2
[2019-05-13 17:31:18.559] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.559] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org2.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.559] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org2.autentia-bchain.com
[2019-05-13 17:31:18.559] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.559] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org3
[2019-05-13 17:31:18.559] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.559] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org3.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.559] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org3.autentia-bchain.com
[2019-05-13 17:31:18.559] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org4
[2019-05-13 17:31:18.560] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org4.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org4.autentia-bchain.com
[2019-05-13 17:31:18.560] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org4
[2019-05-13 17:31:18.560] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org4.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org4.autentia-bchain.com
[2019-05-13 17:31:18.560] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.561] [DEBUG] Helper - [NetworkConfig101.js]: _addPeersToChannel - peer0.org4.autentia-bchain.com - grpcs://localhost:10051
[2019-05-13 17:31:18.561] [DEBUG] Helper - [NetworkConfig101.js]: getOrderer - name orderer.autentia-bchain.com
[2019-05-13 17:31:18.563] [DEBUG] Helper - [DiscoveryEndorsementHandler]: initialize - 

当我执行 channel.getChannelPeers() 时,我会得到一个包含同行的列表,其中包含正确的名称。

[ ChannelPeer {
    _mspid: 'Org1MSP',
    _channel: 
     Channel {
       _name: 'auditoria-channel',
       _channel_peers: [Object],
       _anchor_peers: [],
       _orderers: [Object],
       _kafka_brokers: [],
       _clientContext: [Object],
       _msp_manager: [Object],
       _discovery_interests: [Object],
       _discovery_results: [Object],
       _last_discover_timestamp: 1557779840912,
       _use_discovery: true,
       _as_localhost: true,
       _endorsement_handler: [Object],
       _commit_handler: [Object],
       _last_refresh_request: [Object] },
    _name: 'peer0.org1.autentia-bchain.com',
    _peer: 
     Peer {
       _options: [Object],
       clientCert: undefined,
       _url: 'grpcs://localhost:7051',
       _endpoint: [Object],
       _name: 'peer0.org1.autentia-bchain.com',
       _request_timeout: 45000,
       _grpc_wait_for_ready_timeout: 3000,
       _endorserClient: [Object],
       _discoveryClient: [Object] },
    _roles: 
     { endorsingPeer: true,
       chaincodeQuery: true,
       ledgerQuery: true,
       eventSource: true } },
  ChannelPeer {
    _mspid: 'Org2MSP',
    _channel: 
     Channel {
       _name: 'auditoria-channel',
       _channel_peers: [Object],
       _anchor_peers: [],
       _orderers: [Object],
       _kafka_brokers: [],
       _clientContext: [Object],
       _msp_manager: [Object],
       _discovery_interests: [Object],
       _discovery_results: [Object],
       _last_discover_timestamp: 1557779840912,
       _use_discovery: true,
       _as_localhost: true,
       _endorsement_handler: [Object],
       _commit_handler: [Object],
       _last_refresh_request: [Object] },
    _name: 'peer0.org2.autentia-bchain.com',
    _peer: 
     Peer {
       _options: [Object],
       clientCert: undefined,
       _url: 'grpcs://localhost:8051',
       _endpoint: [Object],
       _name: 'peer0.org2.autentia-bchain.com',
       _request_timeout: 45000,
       _grpc_wait_for_ready_timeout: 3000,
       _endorserClient: [Object],
       _discoveryClient: [Object] },
    _roles: 
     { endorsingPeer: true,
       chaincodeQuery: true,
       ledgerQuery: true,
       eventSource: true } },
  ChannelPeer {
    _mspid: 'Org3MSP',
    _channel: 
     Channel {
       _name: 'auditoria-channel',
       _channel_peers: [Object],
       _anchor_peers: [],
       _orderers: [Object],
       _kafka_brokers: [],
       _clientContext: [Object],
       _msp_manager: [Object],
       _discovery_interests: [Object],
       _discovery_results: [Object],
       _last_discover_timestamp: 1557779840912,
       _use_discovery: true,
       _as_localhost: true,
       _endorsement_handler: [Object],
       _commit_handler: [Object],
       _last_refresh_request: [Object] },
    _name: 'peer0.org3.autentia-bchain.com',
    _peer: 
     Peer {
       _options: [Object],
       clientCert: undefined,
       _url: 'grpcs://localhost:9051',
       _endpoint: [Object],
       _name: 'peer0.org3.autentia-bchain.com',
       _request_timeout: 45000,
       _grpc_wait_for_ready_timeout: 3000,
       _endorserClient: [Object],
       _discoveryClient: [Object] },
    _roles: 
     { endorsingPeer: true,
       chaincodeQuery: true,
       ledgerQuery: true,
       eventSource: true } },
  ChannelPeer {
    _mspid: 'Org4MSP',
    _channel: 
     Channel {
       _name: 'auditoria-channel',
       _channel_peers: [Object],
       _anchor_peers: [],
       _orderers: [Object],
       _kafka_brokers: [],
       _clientContext: [Object],
       _msp_manager: [Object],
       _discovery_interests: [Object],
       _discovery_results: [Object],
       _last_discover_timestamp: 1557779840912,
       _use_discovery: true,
       _as_localhost: true,
       _endorsement_handler: [Object],
       _commit_handler: [Object],
       _last_refresh_request: [Object] },
    _name: 'peer0.org4.autentia-bchain.com',
    _peer: 
     Peer {
       _options: [Object],
       clientCert: undefined,
       _url: 'grpcs://localhost:10051',
       _endpoint: [Object],
       _name: 'peer0.org4.autentia-bchain.com',
       _request_timeout: 45000,
       _grpc_wait_for_ready_timeout: 3000,
       _endorserClient: [Object],
       _discoveryClient: [Object] },
    _roles: 
4

2 回答 2

1

当 NodeSDK 应用程序运行第一级并在本地虚拟环境中使用结构网络时,其中对等地址被视为“localhost”,虚拟环境中的端口地址也必须是唯一的。在 docker-compose 中,将虚拟端口映射到真实端口时,最容易使用相同的地址。请注意,在以下示例中,定义虚拟环境的端口地址与主机映射相同。

    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_PEER_ID=peer0.org2.example.com
      - CORE_PEER_ADDRESS=peer0.org2.example.com:8051
      - CORE_PEER_LISTENADDRESS=peer0.org2.example.com:8051
      - CORE_PEER_GOSSIP_ENDPOINT=peer0.org2.example.com:8051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:8051
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/peerOrg2/msp
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:8051

    ports:
      - 8051:8051

请记住,主机名也必须从虚拟名称映射到“localhost”,这是通过在通道初始化时使用连接选项“aslocalhost:true”来完成的。

await channel.initialize({discover:true, asLocalhost:true})

希望以下内容会有所帮助

https://fabric-sdk-node.github.io/release-1.4/tutorial-discovery.html

于 2019-05-14T16:22:33.287 回答
0

我们能否看到通道初始化时的调试日志。查看从 Peer's Discovery Service 读取的 Discovery 结果会很有帮助。背书计划中看到的 Peer 的名称不是来自 Discovery Service,这是 NodeSDK 分配的名称,这些名称应该是唯一的,并且包含主机和端口。由于它们不是唯一的,因此确实使用了相同的 Peer。

于 2019-05-13T21:23:05.910 回答