在对等方上安装chaincode时如何解决“ chaincode的路径不存在”的问题?

时间:2019-10-20 10:57:33

标签: hyperledger-fabric hyperledger-chaincode

我正在尝试将用打字稿编写的链式代码安装在网络中的一个对等点上,该对等点具有单个对等点,couch DB,结构CA和一个订购者以独占模式运行。在运行脚本时,打字稿已成功编译为javascript。

稍后出现错误消息

  

错误:获取链码代码miqlavecc时出错:链码路径   不存在:/opt/gopath/src/github.com/chaincode

Error message while chaincode install 我使用了这个脚本文件deploycontract.sh:

CC_SRC_LANGUAGE = "typescript"
CC_RUNTIME_LANGUAGE=node # chaincode runtime language is node.js
    CC_SRC_PATH=/opt/gopath/src/github.com/chaincode #/fabcar/typescript
    echo Compiling TypeScript code into JavaScript ...
    pushd ../SmartContract/typescript/
    npm install
    npm run build
    popd
    echo Finished compiling TypeScript code into JavaScript

CONFIG_ROOT=/opt/gopath/src/github.com/hyperledger/fabric/peer
ORG1_MSPCONFIGPATH=${CONFIG_ROOT}/crypto-config/peerOrganizations/suja.miqlave.com/users/Admin@suja.miqlave.com/msp
ORG1_TLS_ROOTCERT_FILE=${CONFIG_ROOT}/crypto-config/peerOrganizations/suja.miqlave.com/peers/peer0.suja.miqlave.com/tls/ca.crt
ORDERER_TLS_ROOTCERT_FILE=${CONFIG_ROOT}/crypto-config/ordererOrganizations/miqlave.com/orderers/orderer.miqlave.com/msp/tlscacerts/tlsca.miqlave.com-cert.pem

echo "Installing smart contract on peer0.suja.miqlave.com"
docker exec \
  -e CORE_PEER_LOCALMSPID=SujaMSP \
  -e CORE_PEER_ADDRESS=peer0.suja.miqlave.com:7051 \
  -e CORE_PEER_TLS_ROOTCERT_FILE=${ORG1_TLS_ROOTCERT_FILE} \
  peer0.suja.miqlave.com \
  peer chaincode install \
    -n miqlavecc \
    -v 1.0 \
    -p "$CC_SRC_PATH" \
    -l "$CC_RUNTIME_LANGUAGE"

docker- compose.yaml:

version: "2"

networks:
  miqlave:

services:
  ca.miqlave.com:
    image: hyperledger/fabric-ca
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca.miqlave.com
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.suja.miqlave.com-cert.pem
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/7173c628839f14e9b1e4dbf6f73e60798c8fcf4a38cf9a6453080b0363d6a0cc_sk
    ports:
      - "7054:7054"
    command: sh -c 'fabric-ca-server start -b admin:adminpw'
    volumes:
      - ./crypto-config/peerOrganizations/suja.miqlave.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca.miqlave.com
    networks:
      - miqlave

  orderer.miqlave.com:
    container_name: orderer.miqlave.com
    image: hyperledger/fabric-orderer
    environment:
      - FABRIC_LOGGING_SPEC=info
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
    command: orderer
    ports:
      - 7050:7050
    volumes:
      - ./config/:/etc/hyperledger/configtx
      - ./crypto-config/ordererOrganizations/miqlave.com/orderers/orderer.miqlave.com/:/etc/hyperledger/msp/orderer
      - ./crypto-config/peerOrganizations/suja.miqlave.com/peers/peer0.suja.miqlave.com/:/etc/hyperledger/msp/peerOrg1
    networks:
      - miqlave

  peer0.suja.miqlave.com:
    container_name: peer0.suja.miqlave.com
    image: hyperledger/fabric-peer
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_PEER_ID=peer0.suja.miqlave.com
      - FABRIC_LOGGING_SPEC=info
      - CORE_CHAINCODE_LOGGING_LEVEL=info
      - CORE_PEER_LOCALMSPID=SujaMSP
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
      - CORE_PEER_ADDRESS=peer0.suja.miqlave.com:7051 
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_miqlave
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: peer node start
    # command: peer node start --peer-chaincodedev=true
    ports:
      - 7051:7051
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/suja.miqlave.com/peers/peer0.suja.miqlave.com/msp:/etc/hyperledger/msp/peer
      - ./crypto-config/peerOrganizations/suja.miqlave.com/users:/etc/hyperledger/msp/users
      - ./config:/etc/hyperledger/configtx
      # - ./SmartContract:/opt/gopath/src/github.com/
    depends_on:
      - orderer.miqlave.com
      - couchdb
    networks:
      - miqlave

  couchdb:
    container_name: couchdb
    image: hyperledger/fabric-couchdb
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - 5984:5984
    networks:
      - miqlave

  cli:
    container_name: cli
    image: hyperledger/fabric-tools
    tty: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=info
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.suja.miqlave.com:7051
      - CORE_PEER_LOCALMSPID=SujaMSP
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/suja.miqlave.com/users/Admin@suja.miqlave.com/msp
      - CORE_CHAINCODE_KEEPALIVE=10
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./../chaincode/:/opt/gopath/src/github.com/
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
    networks:
      - miqlave

1 个答案:

答案 0 :(得分:2)

@Ravi

您必须提及链码卷的完整路径并删除src,然后从github.com/开始提及

批量更新如下

volumes:
  - ./../chaincode/:/opt/gopath/src/github.com/chaincode/fabcar/typescript

和CC_SRC_PATH如下

CC_SRC_PATH=github.com/chaincode/fabcar/typescript