0

我正在研究 Hyperledger Fabric v1.4.6 和 node sdk v1.4.8,并尝试使用 Docker Swarm 和 Compose 在多个主机上配置它。我的网络由 2 个频道、3 个 org 和一个 raft Orderer 组成。锚节点已在频道上成功更新。

  • 主机 1:channel1 有 peer0org1 和 peer0org2 + CA-org1 和 CA-org2 一个 Cli 和一个 Orderer
  • 主机 2:channel2 有 peer0org1 和 peer0org3 + CA-org1 和 CA-org3。

我的背书政策是“ AND ('Org1MSP.peer','Org2MSP.peer') ”通道1,通道2 是“ AND ('Org1MSP.peer','Org3MSP.peer')

我能够通过 cli 成功构建网络并调用/查询事务,但是当我尝试通过节点 sdk 调用链代码时,错误就开始了。

尝试使用 invoke.js 调用时出现 Node sdk 错误

 - warn: [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G1:1 - endorsement failed - Error: failed 
    to execute transaction 3b8eb8fe01815c3dd03e1fb840f35a3092974de83694e83a0ec13e548682458d: error sending: txid: 3b8eb8fe01815c3dd03e1fb840f35a3092974de83694e83a0ec13e548682458d(channel1) exists
 - error: [DiscoveryEndorsementHandler]: _endorse - endorsement failed::Error: Endorsement has failed
    at DiscoveryEndorsementHandler._endorse (/home/ubuntu/utils/node_modules/fabric-network/node_modules/fabric-client/lib/impl/DiscoveryEndorsementHandler.js:185:19)

当我使用单个组织背书策略"AND('Org1MSP.peer')"时,此错误得到解决。

此外,我的网关有发现:{ enabled: true, asLocalhost: true } });

org1 yaml 文件:

org1peer0:
    image: hyperledger/fabric-peer:$IMAGE_TAG
    environment:
      # couchdb params
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock

      # the following setting starts chaincode containers on the same
      # bridge network as the peers
      # https://docs.docker.com/compose/networking/
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
      #- CORE_LOGGING_LEVEL=INFO
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      - CORE_PEER_ID=peer0.org1.example.com
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_VM_DOCKER_ATTACHSTDOUT=true
      - CORE_CHAINCODE_STARTUPTIMEOUT=1200s
      - CORE_CHAINCODE_EXECUTETIMEOUT=800s

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start

    volumes:
        - /var/run/:/host/var/run/
        - ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
        - ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
        - peer0.org1.example.com:/var/hyperledger/production

    deploy:
            mode: replicated
            replicas: 1
            restart_policy:
              condition: on-failure
            placement:
                constraints:
                    - node.hostname == $WORKER1_HOSTNAME

    ports:
            - published: 7051
              target: 7051
              mode: host

此外,节点 sdk 应用程序在 docker 网络之外运行。

4

0 回答 0