区块链浏览器
- 可以在浏览器上观察整个区块链上的块数、节点数、通道、链码,用于浏览底层区块链网络上的活动
- 安装方式有两种:
- docker
- 下载代码到本地
- 项目地址
配置
- 拉取
blockchain-explorer
配置文件到本地explorer-twonodes
文件夹下
1
2
3
|
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/config.json
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/connection-profile/test-network.json -P connection-profile
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/docker-compose.yaml
|
- 复制
twonodes
网络中保存证书的文件夹crypto-config
到explorer-twonodes
文件夹下,文件夹改名为与官方一致organizations
- 由于
twonodes
网络中有两个组织,所以在connection-profile
文件夹下新增一个json
文件,一个json
文件对应一个组织
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
{
"name": "org1-network",
"version": "1.0.0",
"client": {
"tlsEnable": true,
"adminCredential": {
"id": "exploreradmin",
"password": "exploreradminpw"
},
"enableAuthentication": true,
"organization": "Org1MSP",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org1.example.com": {}
},
"connection":{
"timeout":{
"peer":{
"endorser":"6000",
"eventHub":"6000",
"eventReg":"6000"
}
}
}
}
},
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"adminPrivateKey": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk"
},
"peers": ["peer0.org1.example.com"],
"signedCert": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
}
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"url": "grpcs://peer0.org1.example.com:7051"
}
}
}
|
org2-network.json
:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
{
"name": "org2-network",
"version": "1.0.0",
"client": {
"tlsEnable": true,
"adminCredential": {
"id": "exploreradmin",
"password": "exploreradminpw"
},
"enableAuthentication": true,
"organization": "Org2MSP",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org2.example.com": {}
},
"connection":{
"timeout":{
"peer":{
"endorser":"6000",
"eventHub":"6000",
"eventReg":"6000"
}
}
}
}
},
"organizations": {
"Org2MSP": {
"mspid": "Org2MSP",
"adminPrivateKey": {
"path": "/tmp/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/priv_sk"
},
"peers": ["peer0.org2.example.com"],
"signedCert": {
"path": "/tmp/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem"
}
}
},
"peers": {
"peer0.org2.example.com": {
"tlsCACerts": {
"path": "/tmp/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
},
"url": "grpcs://peer0.org2.example.com:9051"
}
}
}
|
- 配置
config.json
文件
1
2
3
4
5
6
7
8
9
10
11
12
13
|
{
"network-configs": {
"org1-network": {
"name": "org1-network",
"profile": "./connection-profile/org1-network.json"
},
"org2-network": {
"name": "org2-network",
"profile": "./connection-profile/org2-network.json"
}
},
"license": "Apache-2.0"
}
|
- 配置
docker-compose
文件,修改网络名和挂载目录即可
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# SPDX-License-Identifier: Apache-2.0
version: '2.1'
volumes:
pgdata:
walletstore:
networks:
mynetwork.com:
name: twonodes_test
services:
explorerdb.mynetwork.com:
image: hyperledger/explorer-db:latest
container_name: explorerdb.mynetwork.com
hostname: explorerdb.mynetwork.com
environment:
- DATABASE_DATABASE=fabricexplorer
- DATABASE_USERNAME=hppoc
- DATABASE_PASSWORD=password
healthcheck:
test: "pg_isready -h localhost -p 5432 -q -U postgres"
interval: 30s
timeout: 10s
retries: 5
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- mynetwork.com
explorer.mynetwork.com:
image: hyperledger/explorer:latest
container_name: explorer.mynetwork.com
hostname: explorer.mynetwork.com
environment:
- DATABASE_HOST=explorerdb.mynetwork.com
- DATABASE_DATABASE=fabricexplorer
- DATABASE_USERNAME=hppoc
- DATABASE_PASSWD=password
- LOG_LEVEL_APP=debug
- LOG_LEVEL_DB=debug
- LOG_LEVEL_CONSOLE=debug
- LOG_CONSOLE_STDOUT=true
- DISCOVERY_AS_LOCALHOST=false
volumes:
- ./config.json:/opt/explorer/app/platform/fabric/config.json
- ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile
- ./organizations:/tmp/crypto
- walletstore:/opt/explorer/wallet
ports:
- 8080:8080
depends_on:
explorerdb.mynetwork.com:
condition: service_healthy
networks:
- mynetwork.com
|
启动
- 进入
twonodes
目录启动区块链网络
- 进入
explorer-twonodes
启动区块链浏览器,第一次启动的话,会自动拉起浏览器的docker
镜像
- 访问
127.0.0.1:8080
,用户名和密码在org1-network.json
配置文件中
关闭
遇到的BUG
BUG1
登录org1-network
只能看到peer0.org1.example.com
和orderer.example.com:7050
,登录org1-network
只能看到peer0.org2.example.com
和orderer.example.com:7050
解决:检查过配置文件、网络问题、修改过本地hosts
文件使节点可以在本地互相感知到,都没有解决该BUG
2023.01.05 可能是更新锚节点步骤的问题,建议按照官方文档重新搭建一遍网络
2023.01.06 可能是Clash
问题,改成direct
试试
2023.02.07 在官方demo v2.2的测试网络fabric_test
中成功显示全部节点
BUG2
1
|
【ERROR】 main - Error : 【 'Default client peer is down and no channel details available database'】
|
解决:之前执行过docker volume prune
把channel
证书给删除了,所以实际异常根据日志是channel
连接不上。重新加入通道、安装链码、调用链码即可
可能是org1-network.json
文件中的通道名不对
BUG3
1
2
3
4
5
6
|
Failed to create wallet, please check the configuration, and valid file paths: {
"errno": -2,
"syscall": "open",
"code": "ENOENT",
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk"
}
|
原因:搭建网络时使用了Fabric-CA
生成证书和Key,这与搭建网络时默认使用cryptogen
工具生成证书和Key的名称不同
解决:需要修改org1-network.json
和org2-network.json
中的证书和Key的名称,正确的证书和Key名称在搭建网络时生成的文件夹organizations
中寻找