Hyperledger Fabric维护的实际上是一个区块链网络。为了能够直观的观察网络上的节点,交易等行为,Hyperledger Explore随之诞生。

本文讲述如何搭建 Hyperledger Explore。

Hyperledger Explorer

源代码链接: https://github.com/hyperledger/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

浏览器的目的是为了维护网络,所以默认要启动一个fabric网络。默认读者已经部署了一个BYFN网络,如果没有,参考https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html。

准备

首先需要安装:

  • nodejs 8.11.x (Note that v9.x is not yet supported)
  • PostgreSQL 9.5 or greater
  • Jq [https://stedolan.github.io/jq/]

注意对应安装的版本。一般构建完BYFN下面这两个应该都安装了:

  • docker 17.06.2-ce [https://www.docker.com/community-edition]
  • docker-compose 1.14.0 [https://docs.docker.com/compose/]

下载源码

git上下载源码

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

配置/初始化数据库

cd blockchain-explorer/app

这个文件夹下有一个 explorerconfig.json   里面可以配置数据库。

{
"persistence": "postgreSQL",
"platforms": ["fabric"],
"postgreSQL": {
"host": "127.0.0.1",
"port": "",
"database": "fabricexplorer", //数据库名称
"username": "admin123", //用户名
"passwd": "admin123" //密码
},
"sync": {
"type": "local",
"platform": "fabric",
"blocksSyncTime": ""
}
}

后续的初始化脚本会读取这个文件,根据配置的信息登录数据库,执行初始化的创建语句。

执行初始化:

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

这个过程如果报错,需要用户自己登录postgresql  创建对应的数据库 fabricexplorer,用户名 admin123,密码 admin123.

如果出现 Ident authentication failed for user XX错误,修改一下pg_hdconfig的配置就可以了。

执行createdb.sh会执行同一个文件夹的 explorerpg.sql  updatepg.sql

设置fabric网络

需要配置浏览器能找到当前fabric网络。

cd blockchain-explorer/app/platform/fabric
vi config.json

搜索config.json中的所有fabric-path。我的fabric-sample安装目录是  /mnt/fabric-samples/ 。所以把fabric-path改成   /mnt/fabric-samples/  。这样浏览器就能够凭借配置,找到tlsCACerts adminPrivateKey signedCert 来执行网络的查询。

构建Hyperledger Explore

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

在运行test的时候要注意观察是不是所有的mocha的用例都通过了。

启动 Hyperledger Explorer

  • cd blockchain-explorer/
  • ./start.sh

启动浏览器。这个目录下的脚本 ./stop.sh 用来关闭。 默认的端口是8080

访问对应端口:

最新文章

  1. [LeetCode] Flatten Binary Tree to Linked List 将二叉树展开成链表
  2. ubuntu下安装lrzsz
  3. HTML5的属性
  4. 奥威软件Speed-BI荣获2016年度中国大数据最佳云平台奖
  5. spring security防御会话伪造session攻击
  6. POJ 1251 && HDU 1301 Jungle Roads (最小生成树)
  7. c# 中Intern的作用
  8. ASP.NET 5 Beta8 发布
  9. centos搭建svn服务器
  10. ajax不进success,
  11. 基因探针富集分析(GSEA)& GO & pathway
  12. Sql Server的艺术(三) SQL聚合函数的应用
  13. nginx 关于client_max_body_size client_body_buffer_size配置
  14. 数据库【mysql】之pymysql
  15. 第六章 使用 Bootstrap Typeahead 组件(百度下拉效果)(续)
  16. HTML和CSS总结
  17. Spring中的@Async
  18. grid - 显式网格
  19. js的JSON
  20. Storm工作流程

热门文章

  1. Python基础之字符串操作
  2. priority_queue用法(转载)
  3. PHP中怎样让数组以字母为键值来递增
  4. jQuery 事件 - one() 方法
  5. torch7 安装中Missing dependencies for nn:moses >= 1错误解决办法
  6. HDU3037Saving Beans(组合数+lucas定理)
  7. 经过一年时间的沉淀 再次回首 TCP Socket服务器编程 (二)
  8. jquery给select赋值
  9. Poj 1659 Distance on Chessboard(国际象棋的走子规则)
  10. loadrunner的四个主要部件