首页 文章

Composer与Fabric默认网络(BYFN)交互

提问于
浏览
0

(1)您好我安装了默认的Hyperledger Fabric网络(./byfn.sh up)(2)然后我安装了Composer CLI(3)创建的PeerAdmin @hlfv1卡(检查代码如下:createPeerAdminCard.sh)(4)我安装了一个.BNA文件与'composer network install'命令(5)然后我尝试启动业务网络(即作曲家网络启动),我收到以下错误:

启动业务网络定义 . 这可能需要一分钟......错误:尝试启动业务网络时出错 . 错误:无法初始化 Channels . 尝试联系4个Peers.Last错误是错误:错误:REQUEST_TIMEOUT命令失败

我的目标是使用Composer与默认的Fabric网络进行交互并加载BNA .

createPeerAdminCard.sh

#!/bin/bash

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
# http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Usage() {
    echo ""
    echo "Usage: ./createPeerAdminCard.sh [-h host] [-n]"
    echo ""
    echo "Options:"
    echo -e "\t-h or --host:\t\t(Optional) name of the host to specify in the connection profile"
    echo -e "\t-n or --noimport:\t(Optional) don't import into card store"
    echo ""
    echo "Example: ./createPeerAdminCard.sh"
    echo ""
    exit 1
}

Parse_Arguments() {
    while [ $# -gt 0 ]; do
        case $1 in
            --help)
                HELPINFO=true
                ;;
            --host | -h)
                shift
                HOST="$1"
                ;;
            --noimport | -n)
                NOIMPORT=true
                ;;
        esac
        shift
    done
}

HOST=localhost
Parse_Arguments $@

if [ "${HELPINFO}" == "true" ]; then
    Usage
fi

# Grab the current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ -z "${HL_COMPOSER_CLI}" ]; then
  HL_COMPOSER_CLI=$(which composer)
fi

echo
# check that the composer command exists at a version >v0.16
COMPOSER_VERSION=$("${HL_COMPOSER_CLI}" --version 2>/dev/null)
COMPOSER_RC=$?

if [ $COMPOSER_RC -eq 0 ]; then
    AWKRET=$(echo $COMPOSER_VERSION | awk -F. '{if ($2<19) print "1"; else print "0";}')
    if [ $AWKRET -eq 1 ]; then
        echo Cannot use $COMPOSER_VERSION version of composer with fabric 1.1, v0.19 or higher is required
        exit 1
    else
        echo Using composer-cli at $COMPOSER_VERSION
    fi
else
    echo 'No version of composer-cli has been detected, you need to install composer-cli at v0.19 or higher'
    exit 1
fi

cat << EOF > DevServer_connection.json
{
    "name": "hlfv1",
    "x-type": "hlfv1",
    "x-commitTimeout": 300,
    "version": "1.0.0",
    "client": {
        "organization": "Org1",
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "300",
                    "eventHub": "300",
                    "eventReg": "300"
                },
                "orderer": "300"
            }
        }
    },
    "channels": {
        "mychannel": {
            "orderers": [
                "orderer.example.com"
            ],
            "peers": {
                "peer0.org1.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "ledgerQuery": true,
                    "eventSource": true
                },
                "peer1.org1.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "ledgerQuery": true,
                    "eventSource": true
                },
                "peer0.org2.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "ledgerQuery": true,
                    "eventSource": true
                },
                "peer1.org2.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "ledgerQuery": true,
                    "eventSource": true
                }
            }

        }
    },
    "organizations": {
        "Org1": {
            "mspid": "Org1MSP",
            "peers": [
                "peer0.org1.example.com",
                "peer1.org1.example.com"
            ],
            "certificateAuthorities": [
                "ca.org1.example.com"
            ]
        },
        "Org2": {
            "mspid": "Org2MSP",
            "peers": [
                "peer0.org2.example.com",
                "peer1.org2.example.com"
            ],
            "certificateAuthorities": [
                "ca.org2.example.com"
            ]
        }
    },
    "orderers": {
        "orderer.example.com": {
            "url": "grpc://orderer.example.com:7050"
        }
    },
    "peers": {
        "peer0.org1.example.com": {
            "url": "grpc://peer0.org1.example.com:7051",
            "eventUrl": "grpc://peer0.org1.example.com:7053"
        },
        "peer1.org1.example.com": {
            "url": "grpc://peer1.org1.example.com:7051",
            "eventUrl": "grpc://peer0.org1.example.com:7053"
        },
        "peer0.org2.example.com": {
            "url": "grpc://peer0.org2.example.com:7051",
            "eventUrl": "grpc://peer0.org2.example.com:7053"
        },
        "peer1.org2.example.com": {
            "url": "grpc://peer1.org2.example.com:7051",
            "eventUrl": "grpc://peer1.org2.example.com:7053"
        }
    },
    "certificateAuthorities": {
        "ca.org1.example.com": {
            "url": "http://ca.org1.example.com:7054",
            "caName": "ca.org1.example.com"
        },
        "ca.org2.example.com": {
            "url": "http://ca.org2.example.com:7054",
            "caName": "ca.org2.example.com"
        }
    }
}
EOF

PRIVATE_KEY="${DIR}"/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/fd5a91d23b5607ee968bac994858850d25b6b2903b2c62a3a5532baad4203c9d_sk
CERT="${DIR}"/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem

if [ "${NOIMPORT}" != "true" ]; then
    CARDOUTPUT=/tmp/PeerAdmin@hlfv1.card
else
    CARDOUTPUT=PeerAdmin@hlfv1.card
fi

"${HL_COMPOSER_CLI}"  card create -p DevServer_connection.json -u PeerAdmin -c "${CERT}" -k "${PRIVATE_KEY}" -r PeerAdmin -r ChannelAdmin --file $CARDOUTPUT

if [ "${NOIMPORT}" != "true" ]; then
    if "${HL_COMPOSER_CLI}"  card list -c PeerAdmin@hlfv1 > /dev/null; then
        "${HL_COMPOSER_CLI}"  card delete -c PeerAdmin@hlfv1
    fi

    "${HL_COMPOSER_CLI}"  card import --file /tmp/PeerAdmin@hlfv1.card 
    "${HL_COMPOSER_CLI}"  card list
    echo "Hyperledger Composer PeerAdmin card has been imported, host of fabric specified as '${HOST}'"
    rm /tmp/PeerAdmin@hlfv1.card
else
    echo "Hyperledger Composer PeerAdmin card has been created, host of fabric specified as '${HOST}'"
fi

2 回答

  • 0

    确保正确安装开发环境和先决条件,编写器版本和结构版本也应该是最新版本 . 然后按照本教程逐步在多对等多组织结构网络中部署业务网络,您应该没问题 .

    https://hyperledger.github.io/composer/latest/tutorials/deploy-to-fabric-multi-org

  • 0

    由于缺少系统资源或网络连接不良,在5分钟的默认超时时间内无法为所有对等体构建Chaincode容器,因此可能会出现REQUEST_TIMEOUT . 这可能是Multi-Org教程的问题,也可能是单个对等体的问题安装 . 作为Composer Network Start的一部分,Fabric尝试构建一个新的链代码Container,其中包含npm install命令 . 更基本的错误表明您的Fabric未正确配置,甚至是对等方已加入您定义连接配置文件的通道 .

    请参阅答案第2部分Error in starting hyperledger fabric network with hyperledger composer,并建议阅读Composer Wiki中的信息(向下滚动到/搜索'REQUEST_TIMEOUT')以获取有关故障排除的更多信息和提示 .

相关问题