1 Star 1 Fork 3

ezpod/blockchain-explorer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

Hyperledger Explorer是一个简单易用的开源工具,可以用于监视 区块链网络中的活动。Hyperledger Explorer支持Fabric、Iroha等 多种区块链,可以运行在MocOS和Ubuntu下。

Hyperledger Fabric区块链开发教程与工具:

1.0 Hyperledger Explorer与Fabirc版本对应关系说明

Hyperledger Explorer和Fabric以及NodeJS之间的版本对应关系如下:

Hyperledger Explorer Version Fabric Version Supported NodeJS Version Supported
v1.0.0-rc2 (Dec 10, 2019) v1.4.0 to v1.4.4 8.11.x
v1.0.0-rc1 (Nov 18, 2019) v1.4.2 8.11.x
v0.3.9.5 (Sep 8, 2019) v1.4.2 8.11.x
v0.3.9.4 (June 18, 2019) v1.4.1 8.11.x
v0.3.9.3 (May 24, 2019) v1.4 8.11.x
v0.3.9.2 (May 16, 2019) v1.4 8.11.x
v0.3.9.1 (Feb 28, 2019) v1.4 8.11.x
v0.3.9 (Feb 7, 2019) v1.4 8.11.x
v0.3.8 (Dec 13, 2018) v1.3 8.x.x
v0.3.7 (Sep 21, 2018) v1.2 8.x.x
v0.3.6.1 (Sep 21, 2018) v1.2 8.x.x
v0.3.6 (Sep 6, 2018) v1.2 8.x.x
v0.3.5.1 (Sep 21, 2018) v1.1 8.x.x
v0.3.5 (Aug 24, 2018) v1.1 8.x.x
v0.3.4 (Jul 13, 2018) v1.1 8.x.x

2.0 Hyperledger Explorer源代码目录结构

blockchain-explorer
    |
    ├── app                     Application backend root, Explorer configuration
    |    ├── rest               REST API
    |    ├── persistence        Persistence layer
    |    ├── fabric             Persistence API (Hyperledger Fabric)
    |    └── platform           Platforms
    |    |    └── fabric        Explorer API (Hyperledger Fabric)
    |    └── test               Application backend test
    |
    └── client         	        Web UI
         ├── public             Assets
         └── src                Front end source code
              ├── components    React framework
              ├── services      Request library for API calls
              ├── state         Redux framework
              └── static        Custom and Assets

3.0 Hyperledger Explorer的依赖说明

在安装和运行Hyperledger Explorer之前需要先满足以下依赖条件:

  • Nodejs 8.11.x(注意目前v9.x还不支持)
  • PostgreSQL 9.5或更高版本
  • jq
  • 基于Linux的操作系统,例如Ubuntu或MacOS

以下版本的Docker已经验证过支持Hyperledger Explorer:

  • Docker CE 18.09.2或更高版本
  • Docker Compose 1.14.0

4.0 克隆Hyperledger Explorer的Git仓库

执行以下命令克隆Hyperledger Explorer的Git仓库以获得最新版本:

git clone https://github.com/hyperledger/blockchain-explorer.git
cd blockchain-explorer

如果你的网络不是很好,可能上面的命令会执行很长时间。发生这种情况时,可以只保留最新的变更:

git clone https://github.com/hyperledger/blockchain-explorer.git -depth=1
cd blockchain-explorer

5.0 PostgreSQL数据库设置

首先进入app目录:

cd blockchain-explorer/app

然后修改explorerconfig.json以更新PostgreSQL数据库的配置:

"postgreSQL": {
    "host": "127.0.0.1",
    "port": "5432",
    "database": "fabricexplorer",
    "username": "hppoc",
    "passwd": "password"
}

配置数据库的另一种替代方式是使用环境变量,例如:

export DATABASE_HOST=127.0.0.1
export DATABASE_PORT=5432
export DATABASE_DATABASE=fabricexplorer
export DATABASE_USERNAME=hppoc
export DATABASE_PASSWD=pass12345

注意:在每次执行git pull之后,你可能需要修改数据库目录的 权限。执行以下命令进行权限修改:

cd blockchain-explorer/app/persistence/fabric/postgreSQL
chmod -R 775 db/

接下来运行数据库创建脚本。

在Ubuntu下执行如下命令:

cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
sudo -u postgres ./createdb.s

在MacOS执行如下命令:

cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
./createdb.sh

现在可以连接到PostgreSQL数据库,运行DB状态命令:

  • \l:查看创建的fabricexplorer数据库
  • \d:查看创建的数据表

如果你的Postgresql启用了TLS,请参考Postgresql官方文档

5.1 Hyperledger Explorer身份授权配置

首先进入浏览器应用目录:

cd blockchain-explorer/app

然后修改explorerconfig.json以更新授权配置(JWT):

"jwt": {
    "secret" : "a secret phrase!!",
    "expiresIn": "2 days"
}

其中:

  • secret:用于签名消息载荷的密文
  • expiresIn:过期时间,以秒为单位的数值或一个时间字符串,例如:60,2 days,10h,7d等,可参考zeit/ms

6.0 Fabric网络设置

注意:完成这一部分的设置需要一定的时间。

首先参考Hyperledger官方文档Building Your First Network 搭建好你自己的网络。

然后修改配置文件/blockchain-explorer/app/platform/fabric/config.json里的 对应的值。

Hyperledger Explorer默认使用fabric-samples/first-network

请确保在docker-compose.yaml文件中为每个Peer节点都设置了 环境变量CORE_PEER_GOSSIP_BOOTSTRAP和CORE_PEER_GOSSIP_EXTERNALENDPOINT。 这些设置用来启用Fabric发现服务,Hyperledger Explorer依赖于该服务来 自动发现Fabric区块链网络的拓扑结构。

6.1 为Hyperledger Explorer配置运维服务

请参考 CONFIG-OPERATIONS-SERVICE-HLEXPLORER.md来 为Hyperledger Explorer配置运维服务。

7.0 配置Hyperledger Fabric

开启另一个终端,进入以下目录:

cd blockchain-explorer/app/platform/fabric

修改config.json文件来定义fabric网络的连接配置文件:

{
    "network-configs": {
        "first-network": {
            "name": "firstnetwork",
            "profile": "./connection-profile/first-network.json",
            "enableAuthentication": false
        }
    },
    "license": "Apache-2.0"
}
  • first-network:是连接配置的名称,可以随意修改
  • name:你的fabric网络的名字
  • profile:你的连接配置文件的路径

修改JSON文件first-network.json中的连接配置信息:

  • 修改fabric-path指向你的fabric网络硬盘路径:
    /blockchain-explorer/app/platform/fabric/connection-profile/first-network.json
    
  • 为adminPrivateKey配置选项提供完整的磁盘路径,它通常 以_sk结尾,例如:
    "/fabric-path/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/aaacd899a6362a5c8cc1e6f86d13bfccc777375365bbda9c710bb7119993d71c_sk"
    
  • adminUser是网络的管理用户
  • adminPassword是管理用户的密码
  • enableAuthentication标志用来启用登录页,设置为false将跳过 身份验证

7.1 为Hyperledger Explorer配置Fabcar示例,可选

参考Hyperledger Fabric示例中的Fabcar Sample Network 为Hyperledger Explorer设置连接Fabcar示例网络。

  • 确保在docker-compose.yaml文件中为每个peer节点都是遏制了 CORE_PEER_GOSSIP_BOOTSTRAP和CORE_PEER_GOSSIP_EXTERNALENDPOINT 环境变量。这些设置用于启用fabric的自动发现服务。
  • 参考CONFIG-FABCAR-HLEXPLORER.md 配置Fabcar示例网络

7.2 为Hyperledger Explorer配置Balance Transfer示例

参考Hyperledger Fabric示例中的[]Balance Transfer Sample(https://github.com/hyperledger/fabric-samples/tree/release-1.4/balance-transfer) 为Hyperledger Explorer设置对Balance Transfer网络的访问。

参考文档:CONFIG-BALANCE-TRANSFER-HLEXPLORER.md

8.0 Hyperledger Composer 设置

TODO

9.0 Hyperledger Cello设置

TODO

10.0 构建Hyperledger Explorer

注意,请在每次git pull之后重复以下步骤!

在终端执行如下命令安装、测试并构建项目

./main.sh install

在终端执行如下命令清理/node_modules、client/node_modules
client/build、client/coverage、app/test/node_modules目录

./main.sh clean

在终端执行如下命令测试REST API、UI组件并生成代码覆盖报告;

./main.sh test

或者:

cd blockchain-explorer
npm install
cd blockchain-explorer/app/test
npm install
npm run test
cd client/
npm install
npm run test:ci -- -u --coverage
npm run build

10.1 配置Hyperledger Explorer启用HTTPS

参考:CONFIG-HTTPS-HLEXPLORER.md

11.0 运行Hyperledger Explorer

首先进入应用目录:

cd blockchain-explorer/app

然后修改explorerconfig.json来更新同步属性,例如同步类型、平台等。

如果修改了explorerconfig.json中的参数,请重新启动同步进程。

如果同步进程和Hyperledger Explorer不在同一台主机上,那么在 Explorer的explorerconfig.json中应当将同步类型设置为host:

"sync": {
  "type": "host"
}

如果同步进程和Hyperledger Explorer安装在同一台主机上,则设置 为local类型:

"sync": {
  "type": "local"
}

另外开启一个终端:

  • cd blockchain-explorer/
  • ./start.sh 启动后台
  • ./start.sh debug 以调试方式启动后台
  • ./start.sh print 显示帮助信息
  • 在浏览器中打开http(s)/localhost:8080
  • ./stop.sh 终止node服务器

如果Sync进程在单独主机中,那么在新的终端中:

  • cd blockchain-explorer/
  • ./syncstart.sh 启动同步节点
  • ./syncstop.sh 停止同步节点
  • 如果之前在浏览器中访问了hyperledger explorer,请先清理浏览器缓存
  • 如果Hyperledger Fabric网络部署在另一台机器上,请切换start.sh/syncstart.sh 中的DISCOVERY_AS_LOCALHOST标志位false

11.1 Hyperledger Explorer日志配置

使用如下的环境变量,可以控制Hyperledger Explorer中每个组件 (例如app、db和console)的日志输出等级,例如: ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < MARK < OFF。 每个文件按时间(7天)和大小(8MB)滚动。

  • LOG_LEVEL_APP:应用层日志等级,日志写入logs/app/app.log,默认为DEBUG
  • LOG_LEVEL_DB:后端日志等级,日志写入logs/db/db.log,默认为DEBUG
  • LOG_LEVEL_CONSOLE:控制台日志等级,日志写入logs/console/console.log,默认为INFO
  • LOG_CONSOLE_STDOUT :iang控制台日志目标从文件切换为标准输出设备,默认值:false

12.0 使用Docker运行Hyperledger Explorer

如果以下条件满足的话,可以利用docker自动部署Hyperledger Explorer:

  • 安装了bash
  • 在部署机器上安装有docker
  • 在部署机器上安装有docker compose

12.1 Docker仓库

Hyperledger Explorer docker仓库: https://hub.docker.com/r/hyperledger/explorer/

Hyperledger Explorer PostgreSQL docker 仓库: https://hub.docker.com/r/hyperledger/explorer-db

12.2 使用docker compose运行Hyperledger Explorer

修改示例docker-compose.yaml文件以匹配你自己的环境:

  • networks > mynetwork.com > external > name
networks:
    mynetwork.com:
        external:
            name: net_byfn
  • services > explorer.mynetwork.com > volumes
volumes:
  - ./examples/net1/config.json:/opt/explorer/app/platform/fabric/config.json
  - ./examples/net1/connection-profile:/opt/explorer/app/platform/fabric/connection-profile
  - ./examples/net1/crypto:/tmp/crypto
  • 如果Hyperledger Explorer是通过桥接网络连接到Fabric网络 的,你需要设置DISCOVERY_AS_LOCALHOST为false以便禁止将 主机名映射为localhost:
explorer.mynetwork.com:
    ...
    environment:
    ...
    - DISCOVERY_AS_LOCALHOST=false
  • 在启动Fabric网络后,运行如下命令启动Hyperledger Explorer和explorer-db服务
cd /blockchain-explorer
docker-compose up -d
  • 运行如下命令停止服务但不删除持久化数据:
docker-compose down
  • 在docker-compose.yaml中,为持久化数据分配了两个命名 卷(用于postgresql数据和用户钱包),运行以下命令清理 这些数据:
docker-compose down -v

12.3 ~ 18.0

TODO

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} 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.

简介

Hyperledger Explorer是一个简单易用的开源工具,可以用于监视Fabric 区块链网络中的活动。Hyperledger Explorer支持Fabric、Iroha等 多种区块链,可以运行在MocOS和Ubuntu下。中文版由汇智网提供。 展开 收起
README
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ezpod/hyperledger-blockchain-explorer.git
git@gitee.com:ezpod/hyperledger-blockchain-explorer.git
ezpod
hyperledger-blockchain-explorer
blockchain-explorer
master

搜索帮助