注意
这里使用的explorer版本为3.9,对应fabric版本为1.4,针对自己使用的软件版本挑选https://github.com/hyperledger/blockchain-explorer
依赖
- nodejs 8.11.x (Note that v9.x is not yet supported)
- PostgreSQL 9.5 or greater
- Jq [https://stedolan.github.io/jq/]
- docker 17.06.2-ce [https://www.docker.com/community-edition]
- docker-compose 1.14.0 [https://docs.docker.com/compose/]
http://123.207.166.162:8090/#/
准备工作
克隆区块链浏览器资源
git clone https://github.com/hyperledger/blockchain-explorer.git
数据库
数据库配置
修改 blockchain-explorer/app/explorerconfig.json 与当前的数据库一致
"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
初始化PostgreSQL
cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
./createdb.sh
有时候需要配置权限,在blockchain-explorer/app/persistence/fabric/postgreSQL下执行chmod -R 775 db/
区块链网络配置
修改
/Users/qifei/IdeaProjects/blockchain-explorer/app/platform/fabric/config.json
- fabric-path 修改为fabric网络目录
- channel 改为默认的channel
- 如果连接的是一个非TLS的fabric节点,将network-id.clients.client-id.tlsEnable修改为false
构建Hyperledger Explorer
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
过程中可能会遇到node err,根据提示进行操作,如
- npm audit fix
- npm audit fix --force
- rm package-lock.json && rm -rf node_modules/*
- vim package.json 或删除某些node_module
运行
同步配置
"sync": {
"type": "local",
"platform": "fabric",
"blocksSyncTime": "3"
}
- type: 同步类型,local 或 host
- blocksSyncTime:同步时间(分钟)
启动
./start.sh
./stop.sh
后台执行命令,查看日志
tail -f ./logs/sync/console/console-*.log
访问地址:http://localhost:8080
如果端口号占用,修改
blockchain-explorer/appconfig.json
Docker 方式
镜像地址:
略
hyperledger/explorer
hyperledger/explorer-db