Hyperledger Explorer
简介
Hyperledger Explorer is a simple, powerful, easy-to-use, well maintained, open source utility to browse activity on the underlying blockchain network. Users have the ability to configure and build Hyperledger Explorer on MacOS and Ubuntu.
下载
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 |
项目结构
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
安装
准备条件
Following are the software dependencies required to install and run hyperledger explorer:
- Nodejs 8.11.x (Note that v9.x is not yet supported)
- PostgreSQL 9.5 or greater
- jq
- Linux-based operating system, such as Ubuntu or MacOS
Verified Docker versions supported:
克隆仓库到本地
Clone this repository to get the latest using the following command.
git clone https://github.com/hyperledger/blockchain-explorer.git
cd blockchain-explorer
设置数据库
cd blockchain-explorer/app
- Modify explorerconfig.json to update PostgreSQL database settings.
"postgreSQL": {
"host": "127.0.0.1",
"port": "",
"database": "fabricexplorer",
"username": "hppoc",
"passwd": "password"
}
Another alternative to configure database settings is to use environment variables, example of settings:
export DATABASE_HOST=127.0.0.1
export DATABASE_PORT=
export DATABASE_DATABASE=fabricexplorer
export DATABASE_USERNAME=hppoc
export DATABASE_PASSWD=pass12345
Important repeat after every git pull (in some case you may need to apply permission to db/ directory from blockchain-explorer/app/persistence/fabric/postgreSQL run:
chmod -R db/
运行创建的数据库脚本
Ubuntu
cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
sudo -u postgres ./createdb.sh
MacOS
cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
./createdb.sh
Connect to the PostgreSQL database and run DB status commands:
\l View created fabricexplorer database.
\d View created tables.
If your Postgresql configured with TLS, read link how to configure connection to Postgresql with TLS
授权认证
cd blockchain-explorer/app
- Modify explorerconfig.json to update Authorization (JWT) settings.
"jwt": {
"secret" : "a secret phrase!!",
"expiresIn": "2 days"
}
secret
: secret string to sign the payload.
expiresIn
: expressed in seconds or a string describing a time span zeit/ms.Eg:
60
,"2 days"
,"10h"
,"7d"
. A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc), otherwise milliseconds unit is used by default ("120"
is equal to"120ms"
).
Fabric 网络设置
- Note: This section will take some time to complete.
- Setup your own network using the Building Your First Network tutorial from Hyperledger. Once you setup the network, please modify the values in
/blockchain-explorer/app/platform/fabric/config.json
accordingly. - Hyperledger Explorer defaults to utilize fabric-samples/first-network.
- Make sure to set the environment variables
CORE_PEER_GOSSIP_BOOTSTRAP
andCORE_PEER_GOSSIP_EXTERNALENDPOINT
for each peer in the docker-compose.yaml file. These settings enable the Fabric discovery service, which is used by Hyperledger Explorer to discover the network topology.
配置操作服务 Config-Operations-Service-Hyperledger-Explorer
运营服务
- 对等方和订购者托管一个HTTP服务器,该服务器提供RESTful“操作” API。此API与Fabric网络服务无关,旨在供运营商使用,而不是网络的管理员或“用户”使用,更多内容请参见 Operations Service
“结构样本/第一个网络”的样本配置
修改/fabric-samples/first-network/base/docker-compose-base.yaml文件,为每个订购者和每个对等方添加操作服务,然后重新启动光纤网络,以使操作服务广播指标和其他信息。请访问提供的docker-compose-base-sample.yaml示例。
订购者样本配置
- ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0: # operation RESTful API
- ORDERER_METRICS_PROVIDER=prometheus # prometheus will pull metrics from orderer via /metrics RESTful API对等样本配置
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0: # operation RESTful API
- CORE_METRICS_PROVIDER=prometheus # prometheus will pull metrics from orderer via /metrics RESTful API
Note that each peer, and orderer need to have a different port, and it available within your environment
在本地设置Prometheus服务器并配置
- 后续操作如何设置Prometheus服务器入门
- 使用样本prometheus.yml启动prometheus。在本地
- 要查看配置是否正确,请启动prometheus,然后在浏览器中打开http:// localhost:9090。
设置Grafana
- 开始使用Grafana
- 登录到grafana http:// localhost:3000 / login,默认凭据admin / admin
- 导航到http:// localhost:3000 / dashboard / import
- 单击“上传.json文件”按钮,然后选择示例文件。
使用Docker设置Prometheus服务器和Grafana
在示例docker-compose文件中,我们已经完成了Prometheus服务器和Grafana设置的配置。如果要自定义配置,请参阅以下文件和官方说明(Prometheus / Grafana)。
- app/platform/fabric/artifacts/operations/balance-transfer/prometheus.yml
- app/platform/fabric/artifacts/operations/balance-transfer/balance-transfer-grafana-dashboard.json
- app/platform/fabric/artifacts/operations/grafana_conf/provisioning/dashboards/dashboard.yaml
- app/platform/fabric/artifacts/operations/grafana_conf/provisioning/datasources/datasource.yaml使用以下命令启动服务后,在浏览器中打开http:// localhost:3000。您将能够看到
Balance Transfer, Quick Summary
预配置的仪表板。$ cd blockchain-explorer
$ docker-compose down -v # Just for cleaning up the old persist docker volumes
$ docker-compose up -d
7.0 Configure Hyperledger Fabric
On another terminal:
cd blockchain-explorer/app/platform/fabric
- Modify config.json to define your fabric network connection profile:
{
"network-configs": {
"first-network": {
"name": "firstnetwork",
"profile": "./connection-profile/first-network.json",
"enableAuthentication": false
}
},
"license": "Apache-2.0"
}
"first-network" is the name of your connection profile, and can be changed to any name.
"name" is a name you want to give to your fabric network, you can change only value of the key "name".
"profile" is the location of your connection profile, you can change only value of the key "profile"
Modify connection profile in the JSON file first-network.json:
- Change "fabric-path" to your fabric network disk path in the first-network.json file:
/blockchain-explorer/app/platform/fabric/connection-profile/first-network.json
- Provide the full disk path to the adminPrivateKey config option, it ussually ends with "_sk", for example:
"/fabric-path/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/aaacd899a6362a5c8cc1e6f86d13bfccc777375365bbda9c710bb7119993d71c_sk"
- "adminUser" is the the admin user of the network, in this case it's fabric CA or an identity user.
- "adminPassword" is the password for the admin user.
- "enableAuthentication" is a flag to enable authentication using a login page, setting to false will skip authentication.
- Change "fabric-path" to your fabric network disk path in the first-network.json file:
配置 Fabcar Sample
Setup Fabcar sample network by following Fabcar Sample Network from Hyperledger fabric samples.
- Make sure to set the environment variables
CORE_PEER_GOSSIP_BOOTSTRAP
andCORE_PEER_GOSSIP_EXTERNALENDPOINT
for each peer in the docker-compose.yaml file. These settings enable the Fabric discovery service, which is used by Hyperledger Explorer to discover the network topology. - Configure Fabcar sample network based on this link CONFIG-FABCAR-HLEXPLORER.md
配置 Balance Transfer Sample
Balance Transfer Sample network by following Balance Transfer Sample from Hyperledger fabric samples.
- Balance Transfer Sample network based on this link CONFIG-BALANCE-TRANSFER-HLEXPLORER.md
配置 Hyperledger Composer
Setup your own network using Composer Build your network from Hyperledger Composer. Once you setup the network, please modify the values in /blockchain-explorer/app/platform/fabric/config.json
accordingly.
On another terminal.
git checkout v0.3.5.
cd blockchain-explorer/app/platform/fabric
- Modify config.json to update network-config
- Change "fabric-path" to your composer network path,Configure the Hyperledger composer based on this link CONFIG-COMPOSER-HLEXPLORER.md
- Modify "syncStartDate" to filter data by block timestamp
- Modify "channel" to your default channel
If you are connecting to a non TLS fabric peer, please modify "network-id.clients.client-id.tlsEnable" (true->false
) in config.json. Depending on this configuration, the application decides whether to go TLS or non TLS route.
配置 Hyperledger Cello
Setup your fabric network using Setup Cello Platform from Hyperledger Cello. Once you setup the network, please modify the values in /blockchain-explorer/app/platform/fabric/config.json
accordingly.
Optional: Configure Hyperledger Explorer for Cello
On another terminal.
git checkout v0.3.5.
cd blockchain-explorer/app/platform/fabric
- Modify config.json to update network-config.
- Change "fabric-path" to your cello network path,
- Configure the Hyperledger cello based on this link CONFIG-CELLO-HLEXPLORER.md
- Modify "syncStartDate" to filter data by block timestamp
- Modify "channel" to your default channel
If you are connecting to a non TLS fabric peer, please modify "network-id.clients.client-id.tlsEnable" (true->false
) in config.json. Depending on this configuration, the application decides whether to go TLS or non TLS route.
构建 Hyperledger Explorer
Important: repeat the below steps after every git pull.
On another terminal:
./main.sh install
to install, run tests, and build project
./main.sh clean
to clean the /node_modules, client/node_modules client/build, client/coverage, app/test/node_modules directories
./main.sh test
to test REST API, and UI components to generate code coverage report 或者
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
配置 Hyperledger Explorer for HTTPS
- Configure Hyperledger Explorer for HTTPS based on this link CONFIG-HTTPS-HLEXPLORER.md
启动 Hyperledger Explorer
cd blockchain-explorer/app
- Modify explorerconfig.json to update sync properties
- sync type (local or host), platform, blocksSyncTime(in min) details.
Sync Process Configuration
- Please restart Explorer if any changes made to explorerconfig.json
Host (Standalone)
- Ensure same configuration in Explorer explorerconfig.json if sync process is running from different locations
"sync": {
"type": "host"
}
Local (Run with Explorer)
"sync": {
"type": "local"
}
From a new terminal:
cd blockchain-explorer/
./start.sh (it will have the backend up).
./start.sh debug (it will have the backend in debug mode).
./start.sh print (it will print help).
Launch the URL http(s)://localhost:8080 on a browser.
./stop.sh (it will stop the node server).
From new terminal (if Sync Process in Standalone).
cd blockchain-explorer/ ./syncstart.sh (it will have the sync node up). ./syncstop.sh (it will stop the sync node). If the Hyperledger Explorer was used previously in your browser be sure to clear the cache before relaunching. If Hyperledger Fabric network is deployed on other machine, please toggle DISCOVERY_AS_LOCALHOST in start.sh / syncstart.sh to 'false'.
配置日志
By using the following environmet variables, you can control log level of each component (app, db and console). You can set these ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < MARK < OFF
string to each level. Each file is rolled by both date (7days) and size (8MB).
- LOG_LEVEL_APP
- Log level regarding application layer. The logs are written to
logs/app/app.log
. - default
DEBUG
- Log level regarding application layer. The logs are written to
- LOG_LEVEL_DB
- Log level regarding backend layer. The logs are written to
logs/db/db.log
. - default
DEBUG
- Log level regarding backend layer. The logs are written to
- LOG_LEVEL_CONSOLE
- Log level regarding console. The logs are written to
logs/console/console.log
. - default
INFO
- Log level regarding console. The logs are written to
- LOG_CONSOLE_STDOUT
- You can switch the destination of console log from file to standard output.
- default
false
Docker 运行 Hyperledger Explorer
There is also an automated deployment of the Hyperledger Explorer available via docker given the following requirements are met:
- BASH installed
- Docker is installed on deployment machine.
- Docker Compose is installed on deployment machine.
12.1 Docker Repository
- Hyperledger Explorer docker repository
https://hub.docker.com/r/hyperledger/explorer/
- Hyperledger Explorer PostgreSQL docker repository
https://hub.docker.com/r/hyperledger/explorer-db
12.2 Run Hyperledger Explorer Using Docker Compose
Modify an example of docker-compose.yaml to align with your environment
- networks > mynetwork.com > external > name
networks:
mynetwork.com:
external:
name: net_byfn- services > explorer.mynetwork.com > volumes
- Connection profile path (ex. ./examples/net1/config.json)
- Connection profile directory path (ex. ./examples/net1/connection-profile, which is referred from config.json)
- Directory path for crypto artifacts of fabric network (ex. ./examples/net1/crypto)
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- When you connect the explorer to your fabric network through bridge network, you need to set
DISCOVERY_AS_LOCALHOST
tofalse
for disabling hostname mapping intolocalhost
.
explorer.mynetwork.com:
...
environment:
...
- DISCOVERY_AS_LOCALHOST=falseRun the following to start up explore and explorer-db services after starting your fabric network:
cd /blockchain-explorer
docker-compose up -dTo stop services without removing persistent data, run the following:
docker-compose down
In this docker-compose.yaml, two named volumes are allocated for persistent data (for Postgres data and user wallet), if you would like to clear these named volumes, run the following:
docker-compose down -v
12.3 Docker 故障排查
If you have an error on Explorer container as below, the initialisation of database might fail in some reasons.
postgres://hppoc:password@192.168.10.11:5432/fabricexplorer
error when connecting to db: { error: role "hppoc" does not existIn such a case, you need to clear the persistent data by running the following command.
docker-compose down -v
docker-compose up -dIf you have an error on Explorer container as below, the Explorer might not have connected the network which your fabric network is belonging.
<<<<<<<<<<<<<<<<<<<<<<<<<< Explorer Error >>>>>>>>>>>>>>>>>>>>>
Error : [ 'Default client peer is down and no channel details available database' ]
In such a case, you need to check whether the explorer container has belonged to the same network with your fabric network or not, with the following command.
docker network inspect net_byfn | jq ".[].Containers[].Name" | sort
"cli"
"dev-peer0.org1.example.com-mycc-1.0"
"dev-peer0.org2.example.com-mycc-1.0"
"dev-peer1.org2.example.com-mycc-1.0"
"explorerdb.mynetwork.com" <<---
"explorer.mynetwork.com" <<---
"orderer.example.com"
"peer0.org1.example.com"
"peer0.org2.example.com"
"peer1.org1.example.com"
"peer1.org2.example.com"Or you need to check whether the explorer can ping to each peer on your fabric network or not, with the following command.
docker exec explorer.mynetwork.com ping -c peer0.org1.example.com
PING peer0.org1.example.com (172.18.0.3): data bytes
bytes from 172.18.0.3: seq= ttl= time=0.064 ms --- peer0.org1.example.com ping statistics ---
packets transmitted, packets received, % packet loss
round-trip min/avg/max = 0.064/0.064/0.064 ms
NPM Utility Scripts to Dockerize Application
Set the DOCKER_REGISTRY
variable to the Container Registry you will use and login to that registry if you want to store your container there.
To build the container (auto-tagged as latest
), run: npm run docker_build
To tag the container with your registry and the NPM package version, run: npm run docker_tag
To push the container to your registry, run: npm run docker_push
Hyperledger Explorer Swagger
- Once the Hyperledger Explorer has been launched go to http://localhost:8080/api-docs to view the Rust API description
- Enter bearer token in Authorize dialog that is generated by the application when you login to Hyperledger Explorer
- Bearer token can be found using Chrome Developer Tools under the Network tab --> Name --> click on REST API request --> Request Headers --> Authorization: bearer
Logs
- Please visit the
./logs/console
folder to view the logs relating to console and./logs/app
to view the application logs and visit the./logs/db
to view the database logs. - Logs rotate every 7 days.
参考资料
源码:https://github.com/hyperledger/blockchain-explorer
Hyperledger Explorer的更多相关文章
- hyperledger explorer 结合 fabric1.4 搭建 区块链浏览器 踩坑记录
博主通过这篇博客的步骤搭建区块链浏览器:https://blog.csdn.net/qq_32675427/article/details/99946945 进行到下面这一步时出现各种异常,浪费了博主 ...
- HyperLedger Fabric 1.4 超级账本项目(5.4)
超级账本(Hyperledger)项目分框架类和工具类两种项目,框架类有Hyperledger Burrow.Hyperledger Fabric.Hyperledger Indy.Hyperledg ...
- HyperLedger Explore 浏览器配置启动教程
Hyperledger Fabric维护的实际上是一个区块链网络.为了能够直观的观察网络上的节点,交易等行为,Hyperledger Explore随之诞生. 本文讲述如何搭建 Hyperledger ...
- Hyperledger Fabric介绍
转载地址 https://blog.csdn.net/xiaonu123/article/details/81006936 简介 Hyperledger介绍 超级账本(Hyperledger)项目是首 ...
- 用Java为Hyperledger Fabric(超级账本)编写区块链智能合约链代码
编写第一个 Java 链代码程序 在上一节中,您已经熟悉了如何构建.运行.部署和调用链代码,但尚未编写任何 Java 代码. 在本节中,将会使用 Eclipse IDE.一个用于 Eclipse 的 ...
- 在Ubuntu中部署并测试HyperLedger Fabric 0.6
最近开始研究区块链,对这个新兴的技术有了基本概念上的了解,所以打算基于一个开源项目做做实验.如果是做数字货币,那么比特币的源代码是最好的了,不过这算是区块链1.0吧,已经有很多改进的竞争币和山寨币出来 ...
- 阿里云容器服务区块链解决方案全新升级 支持Hyperledger Fabric v1.1
摘要: 全球开源区块链领域影响最为广泛的Hyperledger Fabric日前宣布了1.1版本的正式发布,带来了一系列丰富的新功能以及在安全性.性能与扩展性等方面的显著提升.阿里云容器服务区块链解决 ...
- Hyperledger子项目
Hyperledger由五个子项目构成: • BlockChain Explorer 展⽰和查询区块链块.事务和相关数据的 Web应⽤ • Fabric 区块链技术的⼀个实现(主要项目) • STL ...
- HyperLedger Fabric 1.4 超级账本简介(5.2)
超级账本(Hyperledger)是推动区块链跨行业应用的开源项目的总称,组织成员可以发起新的区块链项目,加入到超级账本项目(Hyperledger)中,但需要遵循Hyperledger的生命周期. ...
随机推荐
- 02 Django虚拟环境搭建
01 创建虚拟环境目录 该目录用于存放所有虚拟环境. cd / mkdir venv cd venv 02 创建当前项目的虚拟环境 virtualenv --python=/usr/bin/pytho ...
- 洛谷P1068 分数线划定
https://www.luogu.org/problem/P1068 #include<bits/stdc++.h> using namespace std; struct Can { ...
- 2020算法设计竞赛 C 汉诺塔
作者:珩月链接:https://ac.nowcoder.com/discuss/367149来源:牛客网 将木板按照Xi从小到大排序,将这时的Yi数列记为Zi数列,则问题变成将Zi划分为尽可能少的若干 ...
- 10.3lambda表达式笔记
与参数不同被捕获的变量的值是在lambda创建时拷贝,而不是调用时拷贝 void fcn() { int v1 = 42; //局部变量 auto f = [v1] { return v1; }; a ...
- 【Python】字符串处理方法
- A New Recurrence-Network-Based Time Series Analysis Approach for Characterizing System Dynamics - Guangyu Yang, Daolin Xu * and Haicheng Zhang
Purpose: characterize the evolution of dynamical systems. In this paper, a novel method based on eps ...
- git 解决每次更新代码都要输入用户名密码
git config --global credential.helper store git pull /git push (第一次输入,后续就不用再次数据)
- C++ vector的用法(转)
原文链接:https://blog.csdn.net/qinyuehong/article/details/92837359
- AcWing 开平方 浮点数二分
#include<iostream> using namespace std; int main() { double x; cin>>x; ,r=x; ) //for(int ...
- wamp配置本地多站点。
' 进入C:\wamp64\wamp64\bin\apache\apache2.4.37\conf\http.conf 首先确保httpd-vhosts.conf扩展文件引入进来了,部分版本默认是不引 ...