zoukankan      html  css  js  c++  java
  • 安装 Hyperledger Explorer及翻译中文

    Hyperledger Explorer

    Hyperledger Explorer is a simple, powerful, easy-to-use, highly maintainable, open source browser for viewing activity on the underlying blockchain network.

    Directory Structure

    ├── app                    fabric GRPC interface
    ├── db             the mysql script and help class
    ├── explorer_client        Web Ui
    ├── first-network   Basic fabric network setup
    ├── listener               websocket listener
    ├── metrics                metrics about tx count per minute and block count per minute
    ├── service                the service 
    ├── socket         push real time data to front end
    ├── timer                  Timer to post information periodically  
    └── utils                  Various utility scripts 
    

    Requirements

    Following are the software dependencies required to install and run hyperledger explorer

    • nodejs 6.9.x (Note that v7.x is not yet supported)
    • mysql 5.7 or greater

    Hyperledger Explorer works with Hyperledger Fabric 1.0. Install the following software dependencies to manage fabric network.

    Clone Repository

    Clone this repository to get the latest using the following command.

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

    Database setup

    Run the database setup scripts located under db/fabricexplorer.sql

    mysql -u -p < db/fabricexplorer.sql

    Fabric network setup

    Setup your own network using Build your network tutorial from Fabric. Once you setup the network, please modify the values in config.json accordingly.

    Running blockchain-explorer

    On another terminal,

    1. cd blockchain-explorer
    2. Modify config.json to update network-config
      Change “fabric-path” to your fabric network path, example “/home/user1/workspace/fabric-samples” for the following keys: “tls_cacerts”, “key”, “cert”.
      Final path for key “tls_cacerts” will be “/home/user1/workspace/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt”
    3. Modify config.json to update one of the channel

      • mysql host, username, password details

        “channel”: “mychannel”,
        “mysql”:{
        “host”:”127.0.0.1”,
        “database”:”fabricexplorer”,
        “username”:”root”,
        “passwd”:”123456”
        }

    If you are connecting to a non TLS fabric peer, please modify the

    protocol (grpcs->grpc) and port (9051-> 9050) in the peer url and remove the tls_cacerts. Depending on this key, the application decides whether to go TLS or non TLS route.

    1. npm install
    2. ./start.sh

    Launch the URL http://localhost:8080 on a browser.

    重要的要修改第二步,在config.json中fabric-path改为实际的路径

    常见问题集

    在ubuntu18下运行正常的blockchain-explorer 可以 通过打包复制到新机器centos7下 避免容易出问题npm install 的地方
    TypeError: Cannot read property ‘on’ of undefined 问题

    [root@localhost blockchain-explorer]# ./start.sh
    /opt/gopath/src/github.com/hyperledger/blockchain-explorer/main.js:74
    server.on('connection', connection => {
    ^
    TypeError: Cannot read property 'on' of undefined
    at Object.<anonymous> (/opt/gopath/src/github.com/hyperledger/blockchain-explorer/main.js:74:8)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

    暂时没找到原因 npm install 通过淘宝镜像 安装 的正常,初步猜测1.npm install 淘宝 的问题,2.fabric的config.json配置问题,再看看

    运行在 fabric-samples下的fabcar上引起的问题
    [root@localhost blockchain-explorer]# ./start.sh 
    postgres://hppoc:password@127.0.0.1:5432/fabricexplorer
    (node:4774) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, scandir '/opt/gopath/src/github.com/hyperledger/fabric-samples/basic-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore'
        at Object.fs.readdirSync (fs.js:904:18)
        at Object.readAllFiles (/opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/helper.js:25:18)
        at Platform.setAdminForClient (/opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/platform/fabric/Platform.js:78:37)
        at Platform.initialize (/opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/platform/fabric/Platform.js:146:18)
        at <anonymous>
    (node:4774) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
    (node:4774) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    ^CReceived kill signal, shutting down gracefully
    Closed out remaining connections

    删除fabric的config.json中多余的证书,主意标点符号,别删多了少了,不然会出现 TypeError: Cannot read property ‘on’ of undefined 问题

    [root@localhost blockchain-explorer]# ./start.sh 
    /opt/gopath/src/github.com/hyperledger/blockchain-explorer/main.js:74
    server.on('connection', connection => {
           ^
    
    TypeError: Cannot read property 'on' of undefined
        at Object.<anonymous> (/opt/gopath/src/github.com/hyperledger/blockchain-explorer/main.js:74:8)
        at Module._compile (module.js:652:30)
        at Object.Module._extensions..js (module.js:663:10)
        at Module.load (module.js:565:32)
        at tryModuleLoad (module.js:505:12)
        at Function.Module._load (module.js:497:3)
        at Function.Module.runMain (module.js:693:10)
        at startup (bootstrap_node.js:191:16)
        at bootstrap_node.js:612:3
    
    forEach 问题(https://github.com/hyperledger/blockchain-explorer/blob/release-3.5/TROUBLESHOOT.md
    [root@localhost blockchain-explorer]# ./start.sh 
    postgres://hppoc:password@127.0.0.1:5432/fabricexplorer
    E0903 03:29:13.267101332    4851 ssl_transport_security.cc:989] Handshake failed with fatal error SSL_ERROR_SSL: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number.
    E0903 03:29:14.269565151    4851 ssl_transport_security.cc:989] Handshake failed with fatal error SSL_ERROR_SSL: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number.
    E0903 03:29:16.173519478    4851 ssl_transport_security.cc:989] Handshake failed with fatal error SSL_ERROR_SSL: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number.
    error: [Remote.js]: Error: Failed to connect before the deadline
    error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: Failed to connect before the deadline
        at checkState (/opt/gopath/src/github.com/hyperledger/blockchain-explorer/node_modules/grpc/src/client.js:838:16)
    (node:4851) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined
        at Platform.setChannels (/opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/platform/fabric/Platform.js:192:26)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7)
    (node:4851) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:4851) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    E0903 03:29:18.679853789    4851 ssl_transport_security.cc:989] Handshake failed with fatal error SSL_ERROR_SSL: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number.
    ^CReceived kill signal, shutting down gracefully
    Closed out remaining connections
    

    参考官方的说明,大概就是把config.json中的grpcs 改为grpc就行

    最后,版本容易引起问题,release-3.5 使用postgrsql db
    db error { error: Ident authentication failed for user “hppoc”
    1). 运行下面的命令编辑pg_hba.conf文件 sudo vim /etc/postgresql/9.1/main/pg_hba.conf
    
    2). 将
    
     # Database administrative login by Unix domain socket
    
    local     all      postgres        peer
    
    改为 
    
    # Database administrative login by Unix domain socket
    
    local     all     postgres         trust

    入乡随俗
    这里写图片描述

    这里写图片描述

    初步修改为中文,注意事项:
    修改文件为blockchain-explorerclientsrccomponentsHeader 和blockchain-explorerclientsrccomponentsView 等其它的
    修改后在blockchain-explorer/client 执行npm run build 才行


    断断续续两天, 终于完成了blockchain-explorer 90%的汉化,大致效果如下:

    这里写图片描述

    这里写图片描述
    这里写图片描述
    这里写图片描述


    使用的版本是release-3.5,其它的没有测试,总结起来没什么技术含量,需要注意的一点是修改后需要编译才能起作用
    汉化代码
    还有个事svg文件编译,自行百度Adobe Illustrator吧
    如果有翻译的不合适或者有更好的表述,欢迎留言

  • 相关阅读:
    AppDelegate动态加载StoryBoard
    带交互的 iOS 产品原型可以用什么软件制作?
    day06.1-module模块和包介绍
    day05.2-一个文件的增删改查实例
    day05.1-文件处理
    day04.4-装饰器
    day04.3-生成器
    day04.2-迭代器
    day04.1-三元表达式与列表解析
    day03.2-内置函数的使用
  • 原文地址:https://www.cnblogs.com/llhl/p/9648634.html
Copyright © 2011-2022 走看看