在Hyperledger Explorer中运行区块链应用

译文
区块链
Hyperledger Explorer是一款功能强大的实用程序,让用户可以创建对用户友好的基于Web的应用程序。它是一种区块链仪表板,提供了查看、调用、部署和查询原始区块链数据和网络信息的功能,包括存储在账本中的块细节、链代码和事务。

【51CTO.com快译】Hyperledger Explorer是一款功能强大的实用程序,让用户可以创建对用户友好的基于Web的应用程序。它是一种区块链仪表板,提供了查看、调用、部署和查询原始区块链数据和网络信息的功能,包括存储在账本中的块细节、链代码和事务。

如果读者不熟悉Hyperledger项目,强烈建议看一下《Hyperledger系列和Hyperledger区块链生态系统简介》《Hyperledger设计理念和框架架构》这两篇文章。

Hyperledger Explorer是一个高度维护的开源浏览器,可以直接在macOS和Ubuntu上配置和构建。截至本文发稿时,Hyperledger Explorer还没有上线。最新版本v0.3.8支持Fabric v1.3。

到处碰到错误很常见,尤其是在与版本及/或架设环境有关的问题方面。为了节省调试时间,我为你可能遇到的一些错误加入了注释和推荐的修复方法。

Hyperledger Explorer的配置

运行Hyperledger Explorer之前,我们应检查Explorer的配置,配置在explorerconfig.json文件中予以定义。

根据项目的具体需求更新以下信息:

  • 同步将在哪里运行,这可以是Exlporer(本地),也可以是另一个独立位置(主机)
  • 区块链网络的类型(Fabric)
  • 区块链数据与Explorer同步的频次

运行Hyperledger Explorer应用程序

执行以下步骤以运行Hyperledger应用程序:

1.使用vi编辑器或你所选择的编辑器,根据需要进行修改: 

  1. cd blockchain-explorer/app  
  2. vi explorerconfig.json  
  3. # Here we will run local with Explorer, update the "sync" property as needed to # as below:  
  4. "sync": {  
  5. "type""local" 
  6. "platform""fabric" 
  7. "blocksSyncTime""3"  
  8.  

2. 现在从另一个终端启动Explorer。使用Explorer完毕后,应停止Explorer和节点服务器: 

  1. cd blockchain-explorer/  
  2. sudo ./start.sh  
  3. To stop Explorer, use this command:  
  4. sudo ./stop.sh 

3. 可以检查日志文件:[logs/console/console-yyyy-mm-dd.log]中的错误状态。如果一切情况良好,你会看到以下内容:

  1. postgres://hppoc:password@127.0.0.1:5432/fabricexplorer  
  2. (node:14817) DeprecationWarning: grpc.load: Use the @grpc/proto-  
  3. loader module with  
  4. grpc.loadPackageDefinition instead  
  5. Please open web browser to access: http://localhost:8080/  
  6. pid is 14817  
  7. postgres://hppoc:password@127.0.0.1:5432/fabricexplorer  
  8. ... 

4. 控制台日志可能会显示Explorer错误,比如以下:

  1. postgres://hppoc:password@127.0.0.1:5432/fabricexplorer <<<<<<<<<<<<<<<<<<<<<<<<<< Explorer Error >>>>>>>>>>>>>>>>>>>>>  
  2. { Error: The gRPC binary module was not installed. This may be fixed by running "npm rebuild"  
  3. Original error: Cannot find module '/home/ubuntu/blockchain-explorer/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node'  
  4. at Object. (/home/ubuntu/blockchain-explorer/node_modules/grpc/src/grpc_extension.js:43:17)  
  5. at Module._compile (module.js:653:30)  
  6. at Object.Module._extensions..js (module.js:664:10)  
  7. at Module.load (module.js:566:32)  
  8. at tryModuleLoad (module.js:506:12)  
  9. at Function.Module._load (module.js:498:3)  
  10. at Module.require (module.js:597:17)  
  11. at require (internal/module.js:11:18)  
  12. at Object. (/home/ubuntu/blockchain-explorer/node_modules/grpc/src /client_interceptors.js:145:12)  
  13. at Module._compile (module.js:653:30) code: 'MODULE_NOT_FOUND' } Received kill signal, shutting down gracefullyClosed out connections 

5. 只要运行npm重构、随后再次启动Explorer,就可以修复这个错误:

  1. cd ~/blockchain-explorer/  
  2. npm rebuild  
  3. > grpc@1.14.2 install /home/ubuntu/blockchain-explorer/node_modules/grpc  
  4. > node-pre-gyp install --fallback-to-build --library=static_library  
  5. ... 

注意:有一个应用程序日志[logs/app/app.log],如果运行Explorer应用程序时遇到任何错误,它提供了比控制台日志更详细的信息。

6. 另一方面,Explorer start.sh在后台运行。想观察进度,可以针对app.log文件使用tail命令:

  1. tail -f logs/app/app.log 

7. 现在我们可以从浏览器:http://localhost:8080启动Explorer。

8. 如果你在AWS EC2上运行,需要执行另外两步。把localhost换成你实例的公共IP地址,增添或修改与EC2实例有关的安全组,允许来自TCP端口8080的入站流量。如果一切正常,你应该会看到Explorer仪表板的默认页面。此后,你可以浏览该应用程序,查看并监控各个区块链数据:

现在你已成功构建了Hyperledger Explorer应用程序,将它与Hyperledger Fabric框架集成起来,并利用Explorer在浏览器上直观地显示区块链网络数据。

原文标题:Running Blockchain Applications in Hyperledger Explorer,作者:Matt Zand和Brian Wu

【51CTO译稿,合作站点转载请注明原文译者和出处为51CTO.com】

责任编辑:庞桂玉 来源: 51CTO
相关推荐

2022-02-22 08:30:12

Husky代码工作流

2022-06-30 20:47:58

区块链

2022-04-07 12:02:22

区块链大数据数据中心

2021-03-17 13:46:20

区块链保险技术

2021-06-01 22:31:57

区块链随机数技术

2020-08-05 10:28:17

区块链制造业区块链应用

2018-12-28 10:05:00

2022-01-15 00:01:10

区块链比特币日本

2022-02-11 14:31:14

区块链航天技术

2021-11-17 14:28:18

区块链数字钱包数字货币

2019-07-08 10:16:30

物联网区块链大数据

2022-01-20 11:12:00

区块链金融应用

2018-06-14 16:15:10

2021-01-21 11:36:01

区块链医疗安全

2022-01-25 14:06:24

比特币区块链安全

2021-04-19 16:49:58

区块链传媒技术

2018-09-19 09:31:56

2018-04-03 14:36:13

2018-09-05 13:00:09

点赞
收藏

51CTO技术栈公众号