主頁 > 區塊鏈 > [Fabric] First-NetWork(byfn.sh檔案分析)

[Fabric] First-NetWork(byfn.sh檔案分析)

2022-01-02 09:03:56 區塊鏈

瀏覽順序:

直接看最下面的輸出日志資訊,

文章目錄

      • 瀏覽順序:
      • 一、前言
    • 二、介紹
    • 三、詳細部分
        • 1. 配置環境變數
        • 2. 幫助資訊
        • 3. 是否執行腳本
        • 4. 洗掉容器
        • 5. 洗掉鏡像
        • 6. 版本是否沖突
        • 7. 啟動網路
        • 8. 升級網網路
        • 9. 停止網路
        • 10. 替換私鑰
        • 11. 生成組織證書
        • 12. 呼叫configtxgen工具
        • 13. 一些配置資訊
    • 四、輸出的日志資訊
        • 1. generate
        • 2. up
        • 執行程序
        • 3. down

一、前言

這個主要寫的是腳本里面的一些方法主要是做什么的,其實不看也好,只要看日志資訊,就足夠了,我這里主要想了解一下運行程序,熟悉一下腳本檔案的撰寫,

有的地方直接用的翻譯出來的結果,我吃的也不是很透,

希望可以幫助到一些啟動網路時,看不懂報錯記錄的同學,
日志記錄寫的沒有特別詳細,洗掉了一些東西,可以看自己的日志檔案

我看的是fabric 1.4.6的版本,地址就不貼了,

因為我用的筆記塊內不能放太多,這里直接全部替換成中文的,使用全文翻譯也可以,

二、介紹

啟動first-network的重要的腳本檔案

end-to-end網路,這個記一下,別的貼子大部分這樣寫的 ,

這個測驗案例提供了 兩個order節點,每個order下面有兩個peer節點 ,而且是單機節點模式

這里面使用了兩個重要的工具 cryptogenconfigtxgen,這兩個就是搭建網路是解壓出來的工具類檔案bin目錄下的東西,

  • cryptogen:用來產生加密證書的和秘鑰的,用于傳輸加密和身份驗證,生成的檔案再crypto-config中,
  • configtxgen: 創建通道必要的工具 、

這兩個工具都有自己依賴得yaml檔案,

里面執行了兩個sh 腳本檔案,ccp-generate.sh(byfn.sh同目錄),scripts.sh(scripts目錄下的檔案)
scripts.sh檔案詳解

另外寫了貼子的,詳情看主頁,

三、詳細部分

1. 配置環境變數

#!/bin/bash

#PWD 的地址就是你在的這個 /first-network目錄
# 配置環境變數,讓子shell也可以訪問到
export PATH=${PWD}/../bin:${PWD}:$PATH
export FABRIC_CFG_PATH=${PWD}
export VERBOSE=false

2. 幫助資訊

# 這就是幫助資訊,起始好多都有help命令的,只是大家不注意罷了, ./byfn.sh -help
function printHelp() {
  echo "Usage: "
  echo "  byfn.sh <mode> [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>] [-l <language>] [-o <consensus-type>] [-i <imagetag>] [-a] [-n] [-v]"
  # 就是后面可以加 up down restart generate upgrade
  echo "    <mode> - one of 'up', 'down', 'restart', 'generate' or 'upgrade'"
  # 使用docker-compose up 啟動網路
  echo "      - 'up' - bring up the network with docker-compose up"
  # 使用docker-compose down 停止網路
  echo "      - 'down' - clear the network with docker-compose down"
  # 重啟網路
  echo "      - 'restart' - restart the network"
  # 生成所需的證書和創世塊
  echo "      - 'generate' - generate required certificates and genesis block"
  # 升級fabric網路版本
  echo "      - 'upgrade'  - upgrade the network from version 1.3.x to 1.4.0"
  # -c 后面加channel name 通道名,默認為 mychannel
  echo "    -c <channel name> - channel name to use (defaults to \"mychannel\")"
  # 下面這倆我也沒整太明白,
  # -t 設定cli鏈接超時時間(s為單位,默認為10s)
  echo "    -t <timeout> - CLI timeout duration in seconds (defaults to 10)"
  # -d 設定延遲(s為單位,默認為3s)
  echo "    -d <delay> - delay duration in seconds (defaults to 3)"
  # -f 指定docker-compose.yaml檔案(默認為docker-compose-cli.yaml)
  #    等我跑起來,這個貼子也出了,
  echo "    -f <docker-compose-file> - specify which docker-compose file use (defaults to docker-compose-cli.yaml)"
  # -s 指定資料庫型別,默認是goleveldb 可以指定為couchdb
  echo "    -s <dbtype> - the database backend to use: goleveldb (default) or couchdb"
  # -l 指定鏈碼默認的語言,目前不就是 go node.js java
  echo "    -l <language> - the chaincode language: golang (default) or node"
  # -o 指定共識型別(consensus-共識),order服務的模式:單機,kafka集群,etcdraft(是用于共享配置和服務發現的分布式,一致性的KV存盤系統,)
  echo "    -o <consensus-type> - the consensus-type of the ordering service: solo (default), kafka, or etcdraft"
  # -i 啟動網路的鏡像用的配置,默認是最新的鏡像
  echo "    -i <imagetag> - the tag to be used to launch the network (defaults to \"latest\")"
  # -a 啟動ca 證書辦法機構,默認啥都不啟動
  echo "    -a - launch certificate authorities (no certificate authorities are launched by default)"
  # -n 不部署鏈碼,默認是abstore鏈碼
  echo "    -n - do not deploy chaincode (abstore chaincode is deployed by default)"
  # -v 詳細模式(我也沒試呢,試了寫出來)
  echo "    -v - verbose mode"
  # -h 就是-help
  echo "  byfn.sh -h (print this message)"
  echo
  #下面就是官方說的正常人會執行的啟動命令
  # 1. 先生成需要的證書和創世區塊
  # 2. 然后開啟網路

  echo "Typically, one would first generate the required certificates and "
  echo "genesis block, then bring up the network. e.g.:"
  echo "  上面寫了"
  echo "  byfn.sh generate -c mychannel"
  echo "  byfn.sh up -c mychannel -s couchdb"
  echo "  byfn.sh up -c mychannel -s couchdb -i 1.4.0"
  echo "  byfn.sh up -l node"
  echo "  byfn.sh down -c mychannel"
  echo "  byfn.sh upgrade -c mychannel"
  echo "使用默認的就夠了"
  echo "Taking all defaults:"
  echo "  byfn.sh generate"
  echo "  byfn.sh up"
  echo "  byfn.sh down"
}

3. 是否執行腳本

# Ask user for confirmation to proceed
# 客戶確認了才進行
function askProceed() {
  read -p "Continue? [Y/n] " ans
  case "$ans" in
  y | Y | "")
    echo "proceeding ..."
    ;;
  n | N)
    echo "exiting..."
    exit 1
    ;;
  *)
    echo "invalid response"
    askProceed
    ;;
  esac
}

4. 洗掉容器

# 洗掉容器,默認全部洗掉的,也可以自己指定
function clearContainers() {
  #可以傳參,awk https://www.cnblogs.com/cap-rq/p/11411415.html
  CONTAINER_IDS=$(docker ps -a | awk '($2 ~ /dev-peer.*/) {print $1}')
  if [ -z "$CONTAINER_IDS" -o "$CONTAINER_IDS" == " " ]; then
    #沒有可以洗掉的容器
    echo "---- No containers available for deletion ----"
  else
    docker rm -f $CONTAINER_IDS
  fi
}

5. 洗掉鏡像

# 洗掉作為此設定的一部分生成的鏡像
function removeUnwantedImages() {
  DOCKER_IMAGE_IDS=$(docker images | awk '($1 ~ /dev-peer.*/) {print $3}')
  if [ -z "$DOCKER_IMAGE_IDS" -o "$DOCKER_IMAGE_IDS" == " " ]; then
    echo "---- No images available for deletion ----"
  else
    docker rmi -f $DOCKER_IMAGE_IDS
  fi
}

6. 版本是否沖突

# Versions of fabric known not to work with this release of first-network
# 不可以配置這個版本使用的fabric的版本
BLACKLISTED_VERSIONS="^1\.0\. ^1\.1\.0-preview ^1\.1\.0-alpha"

# 判斷configtxlator的版本和docker鏡像的版本是否有沖突
# Do some basic sanity checking to make sure that the appropriate versions of fabric
# binaries/images are available.  In the future, additional checking for the presence
# of go or other items could be added.
function checkPrereqs() {
  # note, we check configtxlator externally because it does not require a config file, and peer in the
  # docker image because of fab-8551 that makes configtxlator return 'development version' in docker

  # 這里我也不太懂,希望大佬指點

  #本地的版本
  LOCAL_VERSION=$(configtxlator version | sed -ne 's/ Version: //p')
  # docker鏡像的版本
  DOCKER_IMAGE_VERSION=$(docker run --rm hyperledger/fabric-tools:$IMAGETAG peer version | sed -ne 's/ Version: //p' | head -1)

  echo "LOCAL_VERSION=$LOCAL_VERSION"
  echo "DOCKER_IMAGE_VERSION=$DOCKER_IMAGE_VERSION"

  #判斷兩個版本,如果不一致可能出問題
  if [ "$LOCAL_VERSION" != "$DOCKER_IMAGE_VERSION" ]; then
    echo "=================== WARNING ==================="
    echo "  Local fabric binaries and docker images are  "
    echo "  out of  sync. This may cause problems.       "
    echo "==============================================="
  fi

  #   不支持的版本               列入黑名單的版本
  for UNSUPPORTED_VERSION in $BLACKLISTED_VERSIONS; do
    echo "$LOCAL_VERSION" | grep -q $UNSUPPORTED_VERSION
    if [ $? -eq 0 ]; then
      echo "ERROR! Local Fabric binary version of $LOCAL_VERSION does not match this newer version of BYFN and is unsupported. Either move to a later version of Fabric or checkout an earlier version of fabric-samples."
      exit 1
    fi

    echo "$DOCKER_IMAGE_VERSION" | grep -q $UNSUPPORTED_VERSION
    if [ $? -eq 0 ]; then
      echo "ERROR! Fabric Docker image version of $DOCKER_IMAGE_VERSION does not match this newer version of BYFN and is unsupported. Either move to a later version of Fabric or checkout an earlier version of fabric-samples."
      exit 1
    fi
  done
}

7. 啟動網路

# 生成所需的證書、創世塊并啟動網路,
function networkup() {
  checkPrereqs
  # generate artifacts if they don't exist
  # crypto-config不是一個目錄
  if [ ! -d "crypto-config" ]; then
    # 使用cryptogen工具生成證書
    generateCerts
    # 生成私鑰
    replacePrivateKey
    # 生成通道檔案
    generateChannelArtifacts
  fi
  # compose 的檔案們
  COMPOSE_FILES="-f ${COMPOSE_FILE}"
  # 認證機構
  if [ "${CERTIFICATE_AUTHORITIES}" == "true" ]; then
                                    # -f 檢查后面的是不是普通檔案
    COMPOSE_FILES="${COMPOSE_FILES} -f ${COMPOSE_FILE_CA}"
    # ca1 的 私鑰 _sk 結尾的檔案
    export BYFN_CA1_PRIVATE_KEY=$(cd crypto-config/peerOrganizations/org1.example.com/ca && ls *_sk)
    export BYFN_CA2_PRIVATE_KEY=$(cd crypto-config/peerOrganizations/org2.example.com/ca && ls *_sk)
  fi
  # 判斷共識型別
  if [ "${CONSENSUS_TYPE}" == "kafka" ]; then
    COMPOSE_FILES="${COMPOSE_FILES} -f ${COMPOSE_FILE_KAFKA}"
  elif [ "${CONSENSUS_TYPE}" == "etcdraft" ]; then
    COMPOSE_FILES="${COMPOSE_FILES} -f ${COMPOSE_FILE_RAFT2}"
  fi
  # 設定資料庫型別
  if [ "${IF_COUCHDB}" == "couchdb" ]; then
    COMPOSE_FILES="${COMPOSE_FILES} -f ${COMPOSE_FILE_COUCH}"
  fi
  # docker 鏡像版本   docker-compose 啟動
  IMAGE_TAG=$IMAGETAG docker-compose ${COMPOSE_FILES} up -d 2>&1
  docker ps -a
  if [ $? -ne 0 ]; then
    echo "ERROR !!!! Unable to start network"
    exit 1
  fi

  # 設定休眠時間,讓集群有足夠的時間啟動
  if [ "$CONSENSUS_TYPE" == "kafka" ]; then
    sleep 1
    echo "Sleeping 10s to allow $CONSENSUS_TYPE cluster to complete booting"
    sleep 9
  fi

  if [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
    sleep 1
    echo "Sleeping 15s to allow $CONSENSUS_TYPE cluster to complete booting"
    sleep 14
  fi

  # cli 執行 script.sh腳本 后面是接入的引數,后面會整理這個腳本執行的內容的
  docker exec cli scripts/script.sh $CHANNEL_NAME $CLI_DELAY $LANGUAGE $CLI_TIMEOUT $VERBOSE $NO_CHAINCODE
  if [ $? -ne 0 ]; then
    echo "ERROR !!!! Test failed"
    exit 1
  fi
} 

8. 升級網網路

#將版本 1.3.x 的網路組件升級到 1.4.x
# 停止orderer和peer,備份orderer和peer的賬本,清理鏈碼容器和鏡像,
# 并使用最新標版本重新啟動order節點和peer節點
function upgradeNetwork() {
  if [[ "$IMAGETAG" == *"1.4"* ]] || [[ $IMAGETAG == "latest" ]]; then
    docker inspect -f '{{.Config.Volumes}}' orderer.example.com | grep -q '/var/hyperledger/production/orderer'
    if [ $? -ne 0 ]; then
      # 這個網路似乎不是從fabric-samples >= v1.3.x 開始的
      echo "ERROR !!!! This network does not appear to start with fabric-samples >= v1.3.x?"
      exit 1
    fi

    LEDGERS_BACKUP=./ledgers-backup

    # create ledger-backup directory
    mkdir -p $LEDGERS_BACKUP

    export IMAGE_TAG=$IMAGETAG
    COMPOSE_FILES="-f ${COMPOSE_FILE}"
    # 判斷是否需要認證
    if [ "${CERTIFICATE_AUTHORITIES}" == "true" ]; then
      COMPOSE_FILES="${COMPOSE_FILES} -f ${COMPOSE_FILE_CA}"
      # 匯入生成的私鑰
      export BYFN_CA1_PRIVATE_KEY=$(cd crypto-config/peerOrganizations/org1.example.com/ca && ls *_sk)
      export BYFN_CA2_PRIVATE_KEY=$(cd crypto-config/peerOrganizations/org2.example.com/ca && ls *_sk)
    fi
    # 判斷共識型別
    if [ "${CONSENSUS_TYPE}" == "kafka" ]; then
      COMPOSE_FILES="${COMPOSE_FILES} -f ${COMPOSE_FILE_KAFKA}"
    elif [ "${CONSENSUS_TYPE}" == "etcdraft" ]; then
      COMPOSE_FILES="${COMPOSE_FILES} -f ${COMPOSE_FILE_RAFT2}"
    fi
    # 判斷資料庫型別
    if [ "${IF_COUCHDB}" == "couchdb" ]; then
      COMPOSE_FILES="${COMPOSE_FILES} -f ${COMPOSE_FILE_COUCH}"
    fi

    # 移除Cli容器
    docker-compose $COMPOSE_FILES stop cli
    docker-compose $COMPOSE_FILES up -d --no-deps cli

    # 升級orderer和Peer
    echo "Upgrading orderer"
    docker-compose $COMPOSE_FILES stop orderer.example.com
    docker cp -a orderer.example.com:/var/hyperledger/production/orderer $LEDGERS_BACKUP/orderer.example.com
    docker-compose $COMPOSE_FILES up -d --no-deps orderer.example.com

    for PEER in peer0.org1.example.com peer1.org1.example.com peer0.org2.example.com peer1.org2.example.com; do
      echo "Upgrading peer $PEER"

      # 停止容器,備份賬本
      docker-compose $COMPOSE_FILES stop $PEER
      docker cp -a $PEER:/var/hyperledger/production $LEDGERS_BACKUP/$PEER/

      # Remove any old containers and images for this peer
      CC_CONTAINERS=$(docker ps | grep dev-$PEER | awk '{print $1}')
      if [ -n "$CC_CONTAINERS" ]; then
        docker rm -f $CC_CONTAINERS
      fi
      CC_IMAGES=$(docker images | grep dev-$PEER | awk '{print $1}')
      if [ -n "$CC_IMAGES" ]; then
        docker rmi -f $CC_IMAGES
      fi

      # Start the peer again
      docker-compose $COMPOSE_FILES up -d --no-deps $PEER
    done

    # cli容器中 運行升級腳本
    docker exec cli sh -c "SYS_CHANNEL=$CH_NAME && scripts/upgrade_to_v14.sh $CHANNEL_NAME $CLI_DELAY $LANGUAGE $CLI_TIMEOUT $VERBOSE"    
    if [ $? -ne 0 ]; then
      echo "ERROR !!!! Test failed"
      exit 1
    fi
  else
    echo "ERROR !!!! Pass the v1.4.x image tag"
  fi
}

9. 停止網路

# 停止網路
function networkDown() {
  # 除了 org1 和 org2 之外,還停止 org3 容器,以防我們正在運行示例以添加 org3
  # 停止 kafka 和 zookeeper 容器,以防我們使用 kafka 共識型別運行
  docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_CA -f $COMPOSE_FILE_ORG3 down --volumes --remove-orphans

  # Don't remove the generated artifacts -- note, the ledgers are always removed
  if [ "$MODE" != "restart" ]; then

    # 停止網路,洗掉掛載,洗掉所有的賬本備份
    docker run -v $PWD:/tmp/first-network --rm hyperledger/fabric-tools:$IMAGETAG rm -Rf /tmp/first-network/ledgers-backup
    # 呼叫上面的清除容器
    clearContainers
    # 呼叫上面的清除鏡像
    removeUnwantedImages
    # 洗掉 orderer 塊和其他通道配置交易和證書
    rm -rf channel-artifacts/*.block channel-artifacts/*.tx crypto-config ./org3-artifacts/crypto-config/ channel-artifacts/org3.json
    # 洗掉為示例定制的 docker-compose yaml 檔案 就是下面這個
    rm -f docker-compose-e2e.yaml
  fi
}

10. 替換私鑰

# 使用 docker-compose-e2e-template.yaml,
# 將常量替換為由 cryptogen 工具生成的私鑰檔案名,
# 并輸出特定于此配置的 docker-compose.yaml
#替換私鑰
function replacePrivateKey() {

# MacOSX 上的 sed 不支持帶有空擴展名的 -i 標志,
# 我們將使用 't' 作為我們備份的擴展名,并在函式結束時將其洗掉
  ARCH=$(uname -s | grep Darwin)
  if [ "$ARCH" == "Darwin" ]; then
    OPTS="-it"
  else
    OPTS="-i"
  fi

  # 拷貝檔案模板
  cp docker-compose-e2e-template.yaml docker-compose-e2e.yaml

# 接下來的步驟將使用兩個 CA 的私鑰檔案名的實際值替換模板的內容
  # 當前目錄
  CURRENT_DIR=$PWD
  cd crypto-config/peerOrganizations/org1.example.com/ca/
  PRIV_KEY=$(ls *_sk)
  cd "$CURRENT_DIR"
  sed $OPTS "s/CA1_PRIVATE_KEY/${PRIV_KEY}/g" docker-compose-e2e.yaml
  cd crypto-config/peerOrganizations/org2.example.com/ca/
  PRIV_KEY=$(ls *_sk)
  cd "$CURRENT_DIR"
  sed $OPTS "s/CA2_PRIVATE_KEY/${PRIV_KEY}/g" docker-compose-e2e.yaml
 # 如果是MacOSX,洗掉docker-compose檔案的臨時備份
  if [ "$ARCH" == "Darwin" ]; then
    rm docker-compose-e2e.yamlt
  fi
}

11. 生成組織證書

# 使用 cryptogen 工具生成組織證書
function generateCerts() {
  # 查找crytogen工具
  which cryptogen
  if [ "$?" -ne 0 ]; then
    echo "cryptogen tool not found. exiting"
    exit 1
  fi
  echo
  echo "##########################################################"
  echo "##### Generate certificates using cryptogen tool #########"
  echo "##########################################################"


  if [ -d "crypto-config" ]; then
    rm -Rf crypto-config
  fi
  set -x
  # 執行工具的命令
  cryptogen generate --config=./crypto-config.yaml
  res=$?
  set +x
  if [ $res -ne 0 ]; then
    echo "Failed to generate certificates..."
    exit 1
  fi
  echo
  echo "Generate CCP files for Org1 and Org2"
  # 執行另一個腳本,檔案目錄里可以看到的,里面放了一寫組織的資訊 pem檔案的位置,啟動節點占用的埠
  ./ccp-generate.sh
}

12. 呼叫configtxgen工具

# 生成通道工具組態檔,order 塊 錨節點配置
# 主要使用configtxgen
# 然后將這些檔案輸出到“channel-artifacts”檔案夾中,
function generateChannelArtifacts() {
  which configtxgen
  if [ "$?" -ne 0 ]; then
    echo "configtxgen tool not found. exiting"
    exit 1
  fi

  # 生成order 創世塊
  echo "##########################################################"
  echo "#########  Generating Orderer Genesis block ##############"
  echo "##########################################################"
# 注意:由于某些未知原因(至少現在),塊檔案不能命名為 orderer.genesis.block 否則排序器將無法啟動!
  echo "CONSENSUS_TYPE="$CONSENSUS_TYPE
  set -x
  # 根據公式型別 -profile 定了了公式型別,這是 configtx.yaml里面配置的
  if [ "$CONSENSUS_TYPE" == "solo" ]; then
    configtxgen -profile TwoOrgsOrdererGenesis -channelID $SYS_CHANNEL -outputBlock ./channel-artifacts/genesis.block
  elif [ "$CONSENSUS_TYPE" == "kafka" ]; then
    configtxgen -profile SampleDevModeKafka -channelID $SYS_CHANNEL -outputBlock ./channel-artifacts/genesis.block
  elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
    configtxgen -profile SampleMultiNodeEtcdRaft -channelID $SYS_CHANNEL -outputBlock ./channel-artifacts/genesis.block
  else
    set +x
    # 無法識別共識型別
    echo "unrecognized CONSESUS_TYPE='$CONSENSUS_TYPE'. exiting"
    exit 1
  fi
  res=$?
  set +x
  if [ $res -ne 0 ]; then
    echo "Failed to generate orderer genesis block..."
    exit 1
  fi
  # 生成通道組態檔 channel.tx
  echo
  echo "#################################################################"
  echo "### Generating channel configuration transaction 'channel.tx' ###"
  echo "#################################################################"
  set -x
  configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
  res=$?
  set +x
  if [ $res -ne 0 ]; then
    echo "Failed to generate channel configuration transaction..."
    exit 1
  fi
  
  # 生成錨節點
  echo
  echo "#################################################################"
  echo "#######    Generating anchor peer update for Org1MSP   ##########"
  echo "#################################################################"
  set -x
  configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
  res=$?
  set +x
  if [ $res -ne 0 ]; then
    echo "Failed to generate anchor peer update for Org1MSP..."
    exit 1
  fi

  echo
  echo "#################################################################"
  echo "#######    Generating anchor peer update for Org2MSP   ##########"
  echo "#################################################################"
  set -x
  configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate \
    ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
  res=$?
  set +x
  if [ $res -ne 0 ]; then
    echo "Failed to generate anchor peer update for Org2MSP..."
    exit 1
  fi
  echo
}

13. 一些配置資訊

# 獲取將用于為您的平臺選擇正確本機二進制檔案的作業系統和架構字串,例如 darwin-amd64 或 linux-amd64
OS_ARCH=$(echo "$(uname -s | tr '[:upper:]' '[:lower:]' | sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}')
# timeout duration - CLI 在放棄之前應該等待來自另一個容器的回應的持續時間
CLI_TIMEOUT=10
# 命令之間的默認延遲
CLI_DELAY=3
# 系統通道名稱默認為“byfn-sys-channel”
SYS_CHANNEL="byfn-sys-channel"
# 通道默認名
CHANNEL_NAME="mychannel"
# 默認使用的docker-compose.yaml檔案
COMPOSE_FILE=docker-compose-cli.yaml
#
COMPOSE_FILE_COUCH=docker-compose-couch.yaml
# org3 docker compose file
COMPOSE_FILE_ORG3=docker-compose-org3.yaml
# kafka and zookeeper compose file
COMPOSE_FILE_KAFKA=docker-compose-kafka.yaml
# two additional etcd/raft orderers
COMPOSE_FILE_RAFT2=docker-compose-etcdraft2.yaml
# certificate authorities compose file
COMPOSE_FILE_CA=docker-compose-ca.yaml
#
# use golang as the default language for chaincode
LANGUAGE=golang
# default image tag
IMAGETAG="latest"
# default consensus type
CONSENSUS_TYPE="solo"


# Parse commandline args
# 檢驗 byfn.sh 后面的引數
if [ "$1" = "-m" ]; then # supports old usage, muscle memory is powerful!
  shift
fi
MODE=$1
shift
# Determine whether starting, stopping, restarting, generating or upgrading
if [ "$MODE" == "up" ]; then
  EXPMODE="Starting"
elif [ "$MODE" == "down" ]; then
  EXPMODE="Stopping"
elif [ "$MODE" == "restart" ]; then
  EXPMODE="Restarting"
elif [ "$MODE" == "generate" ]; then
  EXPMODE="Generating certs and genesis block"
elif [ "$MODE" == "upgrade" ]; then
  EXPMODE="Upgrading the network"
else
  printHelp
  exit 1
fi

# 輸入不同引數的操作
while getopts "h?c:t:d:f:s:l:i:o:anv" opt; do
  case "$opt" in
  h | \?)
    printHelp
    exit 0
    ;;
  c)
    CHANNEL_NAME=$OPTARG
    ;;
  t)
    CLI_TIMEOUT=$OPTARG
    ;;
  d)
    CLI_DELAY=$OPTARG
    ;;
 
  f)
    COMPOSE_FILE=$OPTARG
    ;;
  s)
    IF_COUCHDB=$OPTARG
    ;;
  l)
    LANGUAGE=$OPTARG
    ;;
  i)
    IMAGETAG=$(go env GOARCH)"-"$OPTARG
    ;;
  o)
    CONSENSUS_TYPE=$OPTARG
    ;;
  a)
    CERTIFICATE_AUTHORITIES=true
    ;;
  n)
    NO_CHAINCODE=true
    ;;
  v)
    VERBOSE=true
    ;;
  esac
done

# 選了couchdb 會呼叫上面的是否確認

if [ "${IF_COUCHDB}" == "couchdb" ]; then
  echo
  echo "${EXPMODE} for channel '${CHANNEL_NAME}' with CLI timeout of '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${IF_COUCHDB}'"
else
  echo "${EXPMODE} for channel '${CHANNEL_NAME}' with CLI timeout of '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds"
fi
# ask for confirmation to proceed
 askProceed
 
 #使用docker-compose 構建網路
 if [ "${MODE}" == "up" ]; then
  networkUp
elif [ "${MODE}" == "down" ]; then ## Clear the network
  networkDown
elif [ "${MODE}" == "generate" ]; then ## Generate Artifacts
  generateCerts
  replacePrivateKey
  generateChannelArtifacts
elif [ "${MODE}" == "restart" ]; then ## Restart the network
  networkDown
  networkUp
elif [ "${MODE}" == "upgrade" ]; then ## Upgrade the network from version 1.2.x to 1.3.x
  upgradeNetwork
else
  printHelp
  exit 1
fi

四、輸出的日志資訊

1. generate

gengerate 作用為生成網路初始化配置,包括MSP證書、私鑰、創世區塊和配置交易等檔案,MSP相關的資訊在crypto-config檔案夾中,創世區塊在channel-artifacts檔案夾中,MSP證書和私鑰用于不同的網路物體,創世塊用于啟動排序服務,配置交易檔案用于配置通道,

  • 日志資訊
root@VM-0-17-ubuntu:/opt/gopath/src/github.com/hyperledger/fabric-samples/first-network# ./byfn.sh -m generate
Generating certs and genesis block for with channel 'mychannel' and CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue (y/n)? y
proceeding ...
/opt/gopath/src/github.com/hyperledger/fabric-samples/first-network/../bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########(1)創建證書
##########################################################
org1.example.com
org2.example.com

/opt/gopath/src/github.com/hyperledger/fabric-samples/first-network/../bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############(2)生成創世塊
##########################################################
2018-04-17 00:41:28.412 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-04-17 00:41:28.454 CST [common/configtx/tool] doOutputBlock -> INFO 002 Generating genesis block
2018-04-17 00:41:28.455 CST [common/configtx/tool] doOutputBlock -> INFO 003 Writing genesis block

#################################################################
### Generating channel configuration transaction 'channel.tx' ###(3)生成通道配置交易檔案
#################################################################
2018-04-17 00:41:28.463 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-04-17 00:41:28.467 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-04-17 00:41:28.467 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 003 Writing new channel tx

#################################################################
####### Generating anchor peer update for Org1MSP ##########(4)在通道上為Org1定義一個錨節點
#################################################################
2018-04-17 00:41:28.475 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-04-17 00:41:28.479 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-04-17 00:41:28.479 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

#################################################################
####### Generating anchor peer update for Org2MSP ##########(5)在通道上為Org2定義一個錨節點
#################################################################
2018-04-17 00:41:28.487 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-04-17 00:41:28.490 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-04-17 00:41:28.491 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

在byfn.sh腳本上,依次執行了 generateCerts、 replacePrivateKey、 generateChannelArtifacts三個函式,其中:

generateCerts執行上述(1)中操作;replacePrivateKey將Org1、Org2的證書私鑰檔案配置到docker-compose-e2e.yaml檔案中,以便于后續網路啟動時候使用;generateChannelArtifacts執行上述中(2)-(5)中的操作,

2. up

up的功能為啟動fabric網路,在啟動之前會先檢查本地是否有crypto-config檔案夾,若沒有則會執行generate操作,有則直接根IF_COUCHDB和COMPOSE_FILE變數來選擇對應的docker compose組態檔,進而啟動網路,默認的goleveldb資料庫對應的組態檔為docker-compose-cli.yaml,若啟動引數設定為couchdb則對應的組態檔為docker-compose-couch.yaml,docker compose啟動docker-compose-cli.yaml 后最后創建的為cli容器,并執行了fabric-samples/first-network/scripts/script.sh腳本,srcipt.sh腳本完成創建通道、加入通道、更新錨節點、安裝-初始化-執行鏈碼等一系列的操作,

  • 日志資訊
root@VM-0-17-ubuntu:/opt/gopath/src/github.com/hyperledger/fabric-samples/first-network# ./byfn.sh -m up
Starting with channel 'mychannel' and CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue (y/n)? y
proceeding ... #(1)配置容器網路,創建各類容器
Creating peer1.org1.example.com ... done
Creating cli ... done
Creating orderer.example.com ...
Creating peer0.org1.example.com ...
Creating peer1.org1.example.com ...
Creating peer1.org2.example.com ...
Creating cli ...

____ _____ _ ____ _____
/ ___| |_ _| / \ | _ \ |_ _|
\___ \ | | / _ \ | |_) | | |
___) | | | / ___ \ | _ < | |
|____/ |_| /_/ \_\ |_| \_\ |_|

Build your first network (BYFN) end-to-end test
Channel name : mychannel
Creating channel... #(2)創建通道
#核心 peer 節點 的 TLS 證書 檔案
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
#核心 peer 節點 的 TLS 的 key 檔案
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key

CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
#peer tls 啟用
CORE_PEER_TLS_ENABLED=true
#MSP 配置環境/位置
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
#日志級別
CORE_LOGGING_LEVEL=DEBUG
#peer 的埠
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
#日志省略
2018-04-16 16:49:44.134 UTC [channelCmd] readBlock -> DEBU 024 Received block:0
2018-04-16 16:49:44.135 UTC [main] main -> INFO 025 Exiting.....
===================== Channel "mychannel" is created successfully =====================
Having all peers join the channel... #(3)將所有的節點加入到該通道中
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
2018-04-16 16:49:44.272 UTC [channelCmd] executeJoin -> INFO 00a Peer joined the channel!
2018-04-16 16:49:44.272 UTC [main] main -> INFO 00b Exiting.....
===================== PEER0 joined on the channel "mychannel" ===================== #(3-1)PEER0(orgt1的peer0)加入到通道中
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer1.org1.example.com:7051
2018-04-16 16:49:47.450 UTC [channelCmd] executeJoin -> INFO 00a Peer joined the channel!
2018-04-16 16:49:47.450 UTC [main] main -> INFO 00b Exiting.....
===================== PEER1 joined on the channel "mychannel" ===================== #(3-2)PEER1(org1的peer1)加入通道
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
2018-04-16 16:49:50.595 UTC [channelCmd] executeJoin -> INFO 00a Peer joined the channel!
2018-04-16 16:49:50.595 UTC [main] main -> INFO 00b Exiting.....
===================== PEER2 joined on the channel "mychannel" ===================== #(3-3)PEER2(org2的peer0)加入通道
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
2018-04-16 16:49:53.765 UTC [channelCmd] executeJoin -> INFO 00a Peer joined the channel!
2018-04-16 16:49:53.765 UTC [main] main -> INFO 00b Exiting.....
===================== PEER3 joined on the channel "mychannel" =====================# (3-4)PEER3(org2的peer1)加入通道
Updating anchor peers for org1...#(4)配置錨節點 (4-1)為org1配置錨節點  配置通訊節點
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
2018-04-16 16:49:56.858 UTC [main] main -> INFO 014 Exiting.....
===================== Anchor peers for org "Org1MSP" on "mychannel" is updated successfully =====================
Updating anchor peers for org2...(4-2)為org2配置錨節點
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
2018-04-16 16:49:59.971 UTC [main] main -> INFO 014 Exiting.....
===================== Anchor peers for org "Org2MSP" on "mychannel" is updated successfully =====================
Installing chaincode on org1/peer0...#(5)鏈碼操作 (5-1)在PEER0上安裝鏈碼
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051

2018-04-16 16:50:03.064 UTC [msp] GetLocalMSP -> DEBU 005 Returning existing local MSP
2018-04-16 16:50:03.064 UTC [msp] GetDefaultSigningIdentity -> DEBU 006 Obtaining default signing identity
#使用默認的背書系統鏈碼
2018-04-16 16:50:03.064 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 007 Using default escc
#使用默認的驗證系統鏈碼 根據背書策略驗證交易
2018-04-16 16:50:03.064 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 008 Using default vscc
#go 平臺 鏈碼
2018-04-16 16:50:03.160 UTC [golang-platform] getCodeFromFS -> DEBU 009 getCodeFromFS github.com/chaincode/chaincode_example02/go/
#丟棄
2018-04-16 16:50:03.323 UTC [golang-platform] func1 -> DEBU 00a Discarding GOROOT package fmt
2018-04-16 16:50:03.323 UTC [golang-platform] func1 -> DEBU 00b Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2018-04-16 16:50:03.323 UTC [golang-platform] func1 -> DEBU 00c Discarding provided package github.com/hyperledger/fabric/protos/peer
2018-04-16 16:50:03.323 UTC [golang-platform] func1 -> DEBU 00d Discarding GOROOT package strconv
2018-04-16 16:50:03.323 UTC [golang-platform] GetDeploymentPayload -> DEBU 00e done
2018-04-16 16:50:03.325 UTC [msp/identity] Sign -> DEBU 00f Sign: plaintext: 0A8A070A5C08031A0C08BBA8D3D60510...F619FF0E0000FFFFACD4020D001C0000
2018-04-16 16:50:03.325 UTC [msp/identity] Sign -> DEBU 010 Sign: digest: 25E15A5C9A37538928052AF2557C4D5093FAB5C8E6D77095A08CE076F01C1EE6
#遠程安裝 獲取回應
2018-04-16 16:50:03.331 UTC [chaincodeCmd] install -> DEBU 011 Installed remotely response:<status:200 payload:"OK" >
2018-04-16 16:50:03.331 UTC [main] main -> INFO 012 Exiting.....
===================== Chaincode is installed on remote peer PEER0 =====================
Install chaincode on org2/peer2...#(5-2)在PEER2上安裝鏈碼
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
2018-04-16 16:50:03.388 UTC [msp] GetLocalMSP -> DEBU 005 Returning existing local MSP
2018-04-16 16:50:03.388 UTC [msp] GetDefaultSigningIdentity -> DEBU 006 Obtaining default signing identity
2018-04-16 16:50:03.388 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 007 Using default escc
2018-04-16 16:50:03.388 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 008 Using default vscc
2018-04-16 16:50:03.476 UTC [golang-platform] getCodeFromFS -> DEBU 009 getCodeFromFS github.com/chaincode/chaincode_example02/go/
2018-04-16 16:50:03.635 UTC [golang-platform] func1 -> DEBU 00a Discarding GOROOT package fmt
2018-04-16 16:50:03.635 UTC [golang-platform] func1 -> DEBU 00b Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2018-04-16 16:50:03.635 UTC [golang-platform] func1 -> DEBU 00c Discarding provided package github.com/hyperledger/fabric/protos/peer
2018-04-16 16:50:03.635 UTC [golang-platform] func1 -> DEBU 00d Discarding GOROOT package strconv
2018-04-16 16:50:03.635 UTC [golang-platform] GetDeploymentPayload -> DEBU 00e done
2018-04-16 16:50:03.636 UTC [msp/identity] Sign -> DEBU 00f Sign: plaintext: 0A8A070A5C08031A0C08BBA8D3D60510...F619FF0E0000FFFFACD4020D001C0000
2018-04-16 16:50:03.636 UTC [msp/identity] Sign -> DEBU 010 Sign: digest: 52F065F4A5A31D2737E6A380AFD5FC302A15C3976B809F560627B1EECC0FA0BD
2018-04-16 16:50:03.644 UTC [chaincodeCmd] install -> DEBU 011 Installed remotely response:<status:200 payload:"OK" >
2018-04-16 16:50:03.644 UTC [main] main -> INFO 012 Exiting.....
===================== Chaincode is installed on remote peer PEER2 =====================
Instantiating chaincode on org2/peer2...#(5-3)在PEER2上初始化鏈碼
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
2018-04-16 16:50:03.721 UTC [msp] GetLocalMSP -> DEBU 005 Returning existing local MSP
2018-04-16 16:50:03.721 UTC [msp] GetDefaultSigningIdentity -> DEBU 006 Obtaining default signing identity
2018-04-16 16:50:03.725 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 007 Using default escc
2018-04-16 16:50:03.725 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 008 Using default vscc
2018-04-16 16:50:03.726 UTC [msp/identity] Sign -> DEBU 009 Sign: plaintext: 0A95070A6708031A0C08BBA8D3D60510...324D53500A04657363630A0476736363
2018-04-16 16:50:03.726 UTC [msp/identity] Sign -> DEBU 00a Sign: digest: A28ADB7847779748A9D2C017443F44EC040E6B4C5AD5A65A1BD2E177346037A8
2018-04-16 16:50:33.340 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A95070A6708031A0C08BBA8D3D60510...F643949B1AAD248D2662B19249FB451B
2018-04-16 16:50:33.340 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: 230E103BE1059EB3764AD6EAC0CE6C785063A5A597CA04535FA91A751A693534
2018-04-16 16:50:33.344 UTC [main] main -> INFO 00d Exiting.....
===================== Chaincode Instantiation on PEER2 on channel 'mychannel' is successful =====================
Querying chaincode on org1/peer0... #(5-4)執行query操作 在org1的peer0上查詢
===================== Querying on PEER0 on channel 'mychannel'... =====================
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
#正在嘗試查詢
Attempting to Query PEER0 ...3 secs
#未在以下檔案找到證書檔案
2018-04-16 16:50:36.412 UTC [msp] getMspConfig -> WARN 001 Intermediate certs folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/intermediatecerts]. Skipping. [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/intermediatecerts: no such file or directory]
2018-04-16 16:50:36.412 UTC [msp] getMspConfig -> WARN 002 TLS intermediate certs folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/tlsintermediatecerts]. Skipping. [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/tlsintermediatecerts: no such file or directory]
2018-04-16 16:50:36.412 UTC [msp] getMspConfig -> WARN 003 crls folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/crls]. Skipping. [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/crls: no such file or directory]
2018-04-16 16:50:36.412 UTC [msp] getMspConfig -> INFO 004 MSP configuration file not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/config.yaml]: [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/config.yaml: no such file or directory]
2018-04-16 16:50:36.444 UTC [msp] GetLocalMSP -> DEBU 005 Returning existing local MSP
2018-04-16 16:50:36.444 UTC [msp] GetDefaultSigningIdentity -> DEBU 006 Obtaining default signing identity
2018-04-16 16:50:36.444 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 007 Using default escc
2018-04-16 16:50:36.444 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 008 Using default vscc
2018-04-16 16:50:36.444 UTC [msp/identity] Sign -> DEBU 009 Sign: plaintext: 0A95070A6708031A0C08DCA8D3D60510...6D7963631A0A0A0571756572790A0161
2018-04-16 16:50:36.444 UTC [msp/identity] Sign -> DEBU 00a Sign: digest: 79AD20D743C6A88C998AC1C4C77C704AE1D2D1267F05D7D32595F3D2F63E644C
Query Result: 100
2018-04-16 16:50:59.876 UTC [main] main -> INFO 00b Exiting.....
===================== Query on PEER0 on channel 'mychannel' is successful =====================
Sending invoke transaction on org1/peer0...#(5-5)執行invoke操作  發送 invoke  事務
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
2018-04-16 16:51:00.085 UTC [msp] GetLocalMSP -> DEBU 005 Returning existing local MSP
2018-04-16 16:51:00.085 UTC [msp] GetDefaultSigningIdentity -> DEBU 006 Obtaining default signing identity
2018-04-16 16:51:00.088 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 007 Using default escc
2018-04-16 16:51:00.088 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 008 Using default vscc
2018-04-16 16:51:00.089 UTC [msp/identity] Sign -> DEBU 009 Sign: plaintext: 0A94070A6608031A0B08F4A8D3D60510...696E766F6B650A01610A01620A023130
2018-04-16 16:51:00.089 UTC [msp/identity] Sign -> DEBU 00a Sign: digest: 4641A54D852486C075129E3F19CB7777DB38AA1BAB2652C3CFD92B5AFDB97C54
2018-04-16 16:51:00.107 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A94070A6608031A0B08F4A8D3D60510...3BE1BF33CC319B542AE9E5147739325E
2018-04-16 16:51:00.107 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: 6245296F4A4DAAB60986EEAE31420B6A1163818AE62BE8D4DFEA913AD45E5BBB
#鏈碼 呼叫 或 查詢 背書系統鏈碼 呼叫 結果
2018-04-16 16:51:00.110 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 00d ESCC invoke result: version:1 response:<status:200 message:"OK" >
#負擔
payload:"\n \306\232\"\260\244,\234\324\263\021\376\325\312\370\002\030\221 \212R.q\246\007\001\307\271rV\237\334\005\022Y\nE\022\024\n\004lscc\022\014\n\n\n\004mycc\022\002\010\003\022-\n\004mycc\022%\n\007\n\001a\022\002\010\003\n\007\n\001b\022\002\010\003\032\007\n\001a\032\00290\032\010\n\001b\032\003210\032\003\010\310\001\"\013\022\004mycc\032\0031.0" 
#背書 代言人
endorsement:<endorser:"\n\007Org1MSP\022\374\005-----BEGIN -----\nMIICGDCCAb+gAwIBAgIQNMk/6oe9nv59nfY5UqOrGjAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu\nb3JnMS5leGFtcGxlLmNvbTAeFw0xODA0MTYxNjQ5MzlaFw0yODA0MTMxNjQ5Mzla\nMFsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMR8wHQYDVQQDExZwZWVyMC5vcmcxLmV4YW1wbGUuY29tMFkw\nEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEsJcLt2s0ZxSrHyMcgCXe9os8plqTtdX5\nfYNd61IZJ1Fv4a5rHMnXFPJ9NemoIDZjENGDX+pFFeEA3bj2QffVbKNNMEswDgYD\nVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQwIoAg2zNFuR8577Mf\neYc49BNvW7pZ6iR/h4WkhxU799509E4wCgYIKoZIzj0EAwIDRwAwRAIgerYUzXci\nyxW1S3/N3B+KelJmdpDp2YlhgPg00BAyCZoCIA/m0Ya3v559KucqOpd1havAw5T6\nsyg2wAVDlbtS7QUG\n-----END -----\n" 
#簽名
signature:"0E\002!\000\3225\000K\t\\\2374\356ueu\244\032~\251\254ph\332\030+\222vG\327/\2506\337\032L\002 \005r\362\346\231u\355g\337z\221\005e\341\033o;\341\2773\3141\233T*\351\345\024w92^" >
2018-04-16 16:51:00.110 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00e Chaincode invoke successful. result: status:200
2018-04-16 16:51:00.110 UTC [main] main -> INFO 00f Exiting.....
===================== Invoke transaction on PEER0 on channel 'mychannel' is successful ===================== 、
Installing chaincode on org2/peer3...#5(5-6)在PEER3上安裝鏈碼
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
2018-04-16 16:51:00.168 UTC [msp] GetLocalMSP -> DEBU 005 Returning existing local MSP
2018-04-16 16:51:00.168 UTC [msp] GetDefaultSigningIdentity -> DEBU 006 Obtaining default signing identity
2018-04-16 16:51:00.168 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 007 Using default escc
2018-04-16 16:51:00.168 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 008 Using default vscc
2018-04-16 16:51:00.223 UTC [golang-platform] getCodeFromFS -> DEBU 009 getCodeFromFS github.com/chaincode/chaincode_example02/go/
2018-04-16 16:51:00.402 UTC [golang-platform] func1 -> DEBU 00a Discarding GOROOT package fmt
2018-04-16 16:51:00.402 UTC [golang-platform] func1 -> DEBU 00b Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2018-04-16 16:51:00.402 UTC [golang-platform] func1 -> DEBU 00c Discarding provided package github.com/hyperledger/fabric/protos/peer
2018-04-16 16:51:00.402 UTC [golang-platform] func1 -> DEBU 00d Discarding GOROOT package strconv
2018-04-16 16:51:00.402 UTC [golang-platform] GetDeploymentPayload -> DEBU 00e done
2018-04-16 16:51:00.403 UTC [msp/identity] Sign -> DEBU 00f Sign: plaintext: 0A8A070A5C08031A0C08F4A8D3D60510...F619FF0E0000FFFFACD4020D001C0000
2018-04-16 16:51:00.403 UTC [msp/identity] Sign -> DEBU 010 Sign: digest: 315459862B61D5E51AB94A20DB7734951AC57913FA0D2DE6597C82778ACA88AA
2018-04-16 16:51:00.409 UTC [chaincodeCmd] install -> DEBU 011 Installed remotely response:<status:200 payload:"OK" >
2018-04-16 16:51:00.409 UTC [main] main -> INFO 012 Exiting.....
===================== Chaincode is installed on remote peer PEER3 =====================
Querying chaincode on org2/peer3...# (5-7)執行query操作 查詢org2的 peer3節點
===================== Querying on PEER3 on channel 'mychannel'... =====================
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
Attempting to Query PEER3 ...3 secs
2018-04-16 16:51:03.497 UTC [msp] GetDefaultSigningIdentity -> DEBU 006 Obtaining default signing identity
2018-04-16 16:51:03.497 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 007 Using default escc
2018-04-16 16:51:03.497 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 008 Using default vscc
2018-04-16 16:51:03.497 UTC [msp/identity] Sign -> DEBU 009 Sign: plaintext: 0A95070A6708031A0C08F7A8D3D60510...6D7963631A0A0A0571756572790A0161
2018-04-16 16:51:03.497 UTC [msp/identity] Sign -> DEBU 00a Sign: digest: 71796FF598D19E3901EE73B08DBF550D8EA6FBFE8FE087B60EDEEA819BAA9306
Query Result: 90
2018-04-16 16:51:25.547 UTC [main] main -> INFO 00b Exiting.....
===================== Query on PEER3 on channel 'mychannel' is successful =====================
#一切正常,執行完畢
========= All GOOD, BYFN execution completed ===========


_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/

在這里插入圖片描述

執行程序

  1. 配置容器網路,創建各類容器

    docker-compose 根據 docker-compose-cli.yaml 配置容器網路和相應的容器

  2. 創建通道

    script.sh執行createChannel函式創建一個通道

  3. 將所有的節點加入到該通道中

    script.sh執行joinChannel函式依次將4個節點加入到通道中

    • PEER0 (org1的peer0)加入通道
    • PEER1 (org1的peer1)加入通道
    • PEER2(org2的peer0)加入通道
    • PEER3(org2的peer1)加入通道
  4. 配置錨節點

    scrip.sh腳本執行updateAnchorPeers函式依次為org1、Org2配置錨節點

    • 為org1配置錨節點
    • 為org2配置錨節點
  5. 鏈碼操作

    script.sh 腳本執行installChainCode、instantiateChainCode、 chaincodeQuery、chaincodeInvoke等函式安裝、實體化、查詢、呼叫等操作

    • 在PEER0上安裝鏈碼
    • 在PEER2上安裝鏈碼
    • 在PEER2上初始化鏈碼
    • 執行query操作
    • 執行invoke操作
    • 在PEER3上安裝鏈碼
    • 執行query操作

3. down

down的功能為關閉超級賬本網路,具體包括洗掉容器和不必要的鏡像檔案,其主調函式為byfn.sh的networkDown,該函式會執行clearContainers、removeUnwantedImages函式,然后在洗掉generate產生的一系列檔案和目錄,

  • 日志資訊
root@VM-0-17-ubuntu:/opt/gopath/src/github.com/hyperledger/fabric-samples/first-network# ./byfn.sh -m down
Stopping with channel 'mychannel' and CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue (y/n)? y
proceeding ...#(1)洗掉相關的容器
WARNING: The CHANNEL_NAME variable is not set. Defaulting to a blank string.
WARNING: The DELAY variable is not set. Defaulting to a blank string.
WARNING: The TIMEOUT variable is not set. Defaulting to a blank string.
#停止節點
Stopping peer0.org1.example.com ... done
Stopping peer1.org2.example.com ... done
Stopping orderer.example.com ... done
Stopping peer1.org1.example.com ... done
Stopping peer0.org2.example.com ... done
#洗掉節點
Removing cli ... done
Removing peer0.org1.example.com ... done
Removing peer1.org2.example.com ... done
Removing orderer.example.com ... done
Removing peer1.org1.example.com ... done
Removing peer0.org2.example.com ... done
#移除docker配置的網路
Removing network net_byfn
WARNING: The CHANNEL_NAME variable is not set. Defaulting to a blank string.
WARNING: The DELAY variable is not set. Defaulting to a blank string.
WARNING: The TIMEOUT variable is not set. Defaulting to a blank string.
Removing network net_byfn
WARNING: Network net_byfn not found.
002e468cdba9
170f5d85d314
3b33620503ac
Untagged: dev-peer1.org2.example.com-mycc-1.0:latest #(2)洗掉鏡像
Deleted: sha256:7fad397db58136ffbf954e0a72f3c434a3950259326c138d97fc86a7296b6642
Deleted: sha256:ef2096acef7eae3d1ab6b0b20f7f7d8c759125d3626f24905cb593b55e8b85ed
Deleted: sha256:eb5e22f8804403158339edb3a54a35a6c0e8402f0aee43eab26e5873119920a4
Deleted: sha256:e15cafcb79a3ed9652d231da057d775a0d9fb29b9b1ea496ffe4c3ac6a6c0a66
Deleted: sha256:79ef483a25f7c37d74fb9818e42e19583827d92d9f4fbd4fc8e7d91db6d12599
Deleted: sha256:8697581945d43243c4f948ec9a2aaad2d1150be284872c7e179f87194e7b5667
Deleted: sha256:e2eeb15c5867c453f7d334ad367ad57a5c5f298b7cb0a4cc75a137ff82ba1aa5
Untagged: dev-peer0.org1.example.com-mycc-1.0:latest
Deleted: sha256:450a145d8868220dc42a60f9a767207df65bba76cb25428f3966724150df739a
Deleted: sha256:174485b27a3f841009e5163d2b272b513ec1c1827e51fed82aa1561ff5181004
Deleted: sha256:200f28cfe057c90071a556a593900a45b6467085735b450355371cc2523ba324
Deleted: sha256:f469bc994653b1c9d880180b4d60a29f892562c5fdc951735a549d8a90d3a0ac
Deleted: sha256:94746de84825fd293ea7fa6266b40758ce4f173a6768b95861a7c1c7346f1aa8
Deleted: sha256:021ad292a7d4976239e4e29a1fed4a3661540d75aa8df05fbe13ed51b5a41eab
Deleted: sha256:7342cd488424d969db765a86d61be699556274cd02b3b3290adc2916063a31f3
Untagged: dev-peer0.org2.example.com-mycc-1.0:latest
Deleted: sha256:5cefcfdaf561bce2f3221c3adf900de1d07b7d3d8a940d01d7fd7c1217832a7f
Deleted: sha256:161b4f823bee25a150e15c3400816c05f2f92e627909406f33710c386b29ff07
Deleted: sha256:2ef7d8c764baa7cbccce0f2f8dcdb51053f5894ffa4350869e028b5382013a6d
Deleted: sha256:49a379a5d3ae4fc848119e4e001fe1d6e59c2210582ad3572342a273113facb8
Deleted: sha256:ae022b203e0f13d0b8355a8843dd9a8260ee4e4f23d9fd2be4ab5a656c83efb1
Deleted: sha256:5d82c68f6c22af99c660898c4ca34b730fe68beddbc4e1c9cb425fd2bbd5c4a3
Deleted: sha256:fa449353db192aa55f4064dff52e0a8516ee8389ffb19a7c87ca4f798e076a71
root@VM-0-17-ubuntu:/opt/gopath/src/github.com/hyperledger/fabric-samples/first-network#

此處需要注意的是,clearContainers函式會執行,CONTAINER_IDS=${docker ps -aq} docker rm -f $CONTAINER_IDS操作,該操作會洗掉所有的容器,

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/400643.html

標籤:區塊鏈

上一篇:【問題】以太坊私鏈連接錢包報錯解決匯總

下一篇:如何獲取DelphiProjectsMRU串列?

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • JAVA使用 web3j 進行token轉賬

    最近新學習了下區塊鏈這方面的知識,所學不多,給大家分享下。 # 1. 關于web3j web3j是一個高度模塊化,反應性,型別安全的Java和Android庫,用于與智能合約配合并與以太坊網路上的客戶端(節點)集成。 # 2. 準備作業 jdk版本1.8 引入maven <dependency> < ......

    uj5u.com 2020-09-10 03:03:06 more
  • 以太坊智能合約開發框架Truffle

    前言 部署智能合約有多種方式,命令列的瀏覽器的渠道都有,但往往跟我們程式員的風格不太相符,因為我們習慣了在IDE里寫了代碼然后打包運行看效果。 雖然現在IDE中已經存在了Solidity插件,可以撰寫智能合約,但是部署智能合約卻要另走他路,沒辦法進行一個快捷的部署與測驗。 如果團隊管理的區塊節點多、 ......

    uj5u.com 2020-09-10 03:03:12 more
  • 谷歌二次驗證碼成為區塊鏈專用安全碼,你怎么看?

    前言 谷歌身份驗證器,前些年大家都比較陌生,但隨著國內互聯網安全的加強,它越來越多地出現在大家的視野中。 比較廣泛接觸的人群是國際3A游戲愛好者,游戲盜號現象嚴重+國外賬號安全應用廣泛,這類游戲一般都會要求用戶系結名為“兩步驗證”、“雙重驗證”等,平臺一般都推薦用谷歌身份驗證器。 后來區塊鏈業務風靡 ......

    uj5u.com 2020-09-10 03:03:17 more
  • 密碼學DAY1

    目錄 ##1.1 密碼學基本概念 密碼在我們的生活中有著重要的作用,那么密碼究竟來自何方,為何會產生呢? 密碼學是網路安全、資訊安全、區塊鏈等產品的基礎,常見的非對稱加密、對稱加密、散列函式等,都屬于密碼學范疇。 密碼學有數千年的歷史,從最開始的替換法到如今的非對稱加密演算法,經歷了古典密碼學,近代密 ......

    uj5u.com 2020-09-10 03:03:50 more
  • 密碼學DAY1_02

    目錄 ##1.1 ASCII編碼 ASCII(American Standard Code for Information Interchange,美國資訊交換標準代碼)是基于拉丁字母的一套電腦編碼系統,主要用于顯示現代英語和其他西歐語言。它是現今最通用的單位元組編碼系統,并等同于國際標準ISO/IE ......

    uj5u.com 2020-09-10 03:04:50 more
  • 密碼學DAY2

    ##1.1 加密模式 加密模式:https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html ECB ECB : Electronic codebook, 電子密碼本. 需要加密的訊息按照塊密碼的塊大小被分為數個塊,并對每個塊進 ......

    uj5u.com 2020-09-10 03:05:42 more
  • NTP時鐘服務器的特點(京準電子)

    NTP時鐘服務器的特點(京準電子) NTP時鐘服務器的特點(京準電子) 京準電子官V——ahjzsz 首先對時間同步進行了背景介紹,然后討論了不同的時間同步網路技術,最后指出了建立全球或區域時間同步網存在的問題。 一、概 述 在通信領域,“同步”概念是指頻率的同步,即網路各個節點的時鐘頻率和相位同步 ......

    uj5u.com 2020-09-10 03:05:47 more
  • 標準化考場時鐘同步系統推進智能化校園建設

    標準化考場時鐘同步系統推進智能化校園建設 標準化考場時鐘同步系統推進智能化校園建設 安徽京準電子科技官微——ahjzsz 一、背景概述隨著教育事業的快速發展,學校建設如雨后春筍,隨之而來的學校教育、管理、安全方面的問題成了學校管理人員面臨的最大的挑戰,這些問題同時也是學生家長所擔心的。為了讓學生有更 ......

    uj5u.com 2020-09-10 03:05:51 more
  • 位元幣入門

    引言 位元幣基本結構 位元幣基礎知識 1)哈希演算法 2)非對稱加密技術 3)數字簽名 4)MerkleTree 5)哪有位元幣,有的是UTXO 6)位元幣挖礦與共識 7)區塊驗證(共識) 總結 引言 上一篇我們已經知道了什么是區塊鏈,此篇說一下區塊鏈的第一個應用——位元幣。其實先有位元幣,后有的區塊 ......

    uj5u.com 2020-09-10 03:06:15 more
  • 北斗對時服務器(北斗對時設備)電力系統應用

    北斗對時服務器(北斗對時設備)電力系統應用 北斗對時服務器(北斗對時設備)電力系統應用 京準電子科技官微(ahjzsz) 中國北斗衛星導航系統(英文名稱:BeiDou Navigation Satellite System,簡稱BDS),因為是目前世界范圍內唯一可以大面積提供免費定位服務的系統,所以 ......

    uj5u.com 2020-09-10 03:06:20 more
最新发布
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:46:47 more
  • Hyperledger Fabric 使用 CouchDB 和復雜智能合約開發

    在上個實驗中,我們已經實作了簡單智能合約實作及客戶端開發,但該實驗中智能合約只有基礎的增刪改查功能,且其中的資料管理功能與傳統 MySQL 比相差甚遠。本文將在前面實驗的基礎上,將 Hyperledger Fabric 的默認資料庫支持 LevelDB 改為 CouchDB 模式,以實作更復雜的資料... ......

    uj5u.com 2023-04-16 07:28:31 more
  • .NET Core 波場鏈離線簽名、廣播交易(發送 TRX和USDT)筆記

    Get Started NuGet You can run the following command to install the Tron.Wallet.Net in your project. PM> Install-Package Tron.Wallet.Net 配置 public reco ......

    uj5u.com 2023-04-14 08:08:00 more
  • DKP 黑客分析——不正確的代幣對比率計算

    概述: 2023 年 2 月 8 日,針對 DKP 協議的閃電貸攻擊導致該協議的用戶損失了 8 萬美元,因為 execute() 函式取決于 USDT-DKP 對中兩種代幣的余額比率。 智能合約黑客概述: 攻擊者的交易:0x0c850f,0x2d31 攻擊者地址:0xF38 利用合同:0xf34ad ......

    uj5u.com 2023-04-07 07:46:09 more
  • Defi開發簡介

    Defi開發簡介 介紹 Defi是去中心化金融的縮寫, 是一項旨在利用區塊鏈技術和智能合約創建更加開放,可訪問和透明的金融體系的運動. 這與傳統金融形成鮮明對比,傳統金融通常由少數大型銀行和金融機構控制 在Defi的世界里,用戶可以直接從他們的電腦或移動設備上訪問廣泛的金融服務,而不需要像銀行或者信 ......

    uj5u.com 2023-04-05 08:01:34 more
  • solidity簡單的ERC20代幣實作

    // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; import "hardhat/console.sol"; //ERC20 同質化代幣,每個代幣的本質或性質都是相同 //ETH 是原生代幣,它不是ERC20代幣, ......

    uj5u.com 2023-03-21 07:56:29 more
  • solidity 參考型別修飾符memory、calldata與storage 常量修飾符C

    在solidity語言中 參考型別修飾符(參考型別為存盤空間不固定的數值型別) memory、calldata與storage,它們只能修飾參考型別變數,比如字串、陣列、位元組等... memory 適用于方法傳參、返參或在方法體內使用,使用完就會清除掉,釋放記憶體 calldata 僅適用于方法傳參 ......

    uj5u.com 2023-03-08 07:57:54 more
  • solidity注解標簽

    在solidity語言中 注釋符為// 注解符為/* 內容*/ 或者 是 ///內容 注解中含有這幾個標簽給予我們使用 @title 一個應該描述合約/介面的標題 contract, library, interface @author 作者的名字 contract, library, interf ......

    uj5u.com 2023-03-08 07:57:49 more
  • 評價指標:相似度、GAS消耗

    【代碼注釋自動生成方法綜述】 這些評測指標主要來自機器翻譯和文本總結等研究領域,可以評估候選文本(即基于代碼注釋自動方法而生成)和參考文本(即基于手工方式而生成)的相似度. BLEU指標^[^?88^^?^]^:其全稱是bilingual evaluation understudy.該指標是最早用于 ......

    uj5u.com 2023-02-23 07:27:39 more
  • 基于NOSTR協議的“公有制”版本的Twitter,去中心化社交軟體Damus

    最近,一個幽靈,Web3的幽靈,在網路游蕩,它叫Damus,這玩意詮釋了什么叫做病毒式營銷,滑稽的是,一個Web3產品卻在Web2的產品鏈上瘋狂傳銷,各方大佬紛紛為其背書,到底發生了什么?Damus的葫蘆里,賣的是什么藥? 注冊和簡單實用 很少有什么產品在用戶注冊環節會有什么噱頭,但Damus確實出 ......

    uj5u.com 2023-02-05 06:48:39 more