@@ -8,7 +8,17 @@ title: Deploy custom miner
8
8
文档对应版本:
9
9
10
10
cql HEAD-f0e4e13d-2019080103005
11
- covenantsql/covenantsql 1601418d1aef
11
+ covenantsql/covenantsql 84b7da393152
12
+
13
+ 本教程可以为中国测试网(testnet cn)或者国外测试网(testnet w) 部署 miner 节点,注意区分网络环境。
14
+
15
+ 本教程在当前目录(` $PWD ` ) 会产生三个目录,分别是:
16
+
17
+ miner_config: 您自己的 miner 节点配置
18
+ super_client_config: 测试网超级客户端配置
19
+ client_config: 您 miner 的使用者客户端配置
20
+
21
+ 各个命令都会使用上述配置之一,代表了命令的执行角色。
12
22
13
23
### 环境依赖
14
24
@@ -34,19 +44,24 @@ docker pull covenantsql/covenantsql:latest
34
44
35
45
#### 生成 Miner 配置文件
36
46
37
- 执行以下命令在当前目录中创建一个 config 目录,并生成 Miner 启动所需的配置文件 ` config.yaml ` 和 私钥 ` private.key `
47
+ 执行以下命令在当前目录中创建一个 miner_config 目录,并生成 Miner 启动所需的配置文件 ` config.yaml ` 和 私钥 ` private.key `
38
48
39
49
> 请将命令中的 ` miner_external_ip ` 和 ` miner_listen_port ` 替换成实际 miner 运行时对外提供服务的 ip 或域名以及端口号;需要注意的是,之后使用者的命令行客户端或 Adapter 都将使用这个地址连接 Miner,请确保这个地址在使用者的机器上可以访问(没有被云平台或其他防火墙限制访问)。可以使用 telnet 或者 nc 的形式在 Miner 启动后检查服务的可用性
40
50
41
51
``` shell
42
- docker run -it --rm -v $( pwd) /config/:/app/config/ \
52
+ mkdir -v ./miner_config
53
+
54
+ docker run -it --rm -v $( pwd) /miner_config/:/app/config/ \
43
55
--entrypoint /app/cql covenantsql/covenantsql:latest -- \
44
56
generate -miner " <miner_external_ip>:<miner_listen_port>" /app/config/
45
57
```
46
58
59
+ > 如果需要生成国外区测试网配置,将上述命令的 ` generate ` 后面增加 ` -testnet w ` 参数。并且注意下述第一行输出会变成 ` Generating testnet w config `
60
+
47
61
命令将会生成一个 miner 的配置文件和私钥,并在命令行中输出 Miner 的节点 id、公钥 hex 和 钱包地址,例如:
48
62
49
- ``` shel
63
+ ``` shell
64
+ Generating testnet cn config
50
65
Generated private key.
51
66
Generating nonce...
52
67
INFO cpu: 8
@@ -64,8 +79,8 @@ Generated nonce.
64
79
Generating config file...
65
80
Generated config.
66
81
67
- Config file: /Users/xq262144/.cql /config.yaml
68
- Private key file: /Users/xq262144/.cql /private.key
82
+ Config file: /app/config /config.yaml
83
+ Private key file: /app/config /private.key
69
84
Public key' s hex: 0338816967be3c24bd490f841de57f2c42daf024dd7f462305aab9a601c423ab8d
70
85
Wallet address: eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451
71
86
@@ -76,19 +91,32 @@ You can get some free PTC from:
76
91
77
92
可以得到 miner 的钱包地址:`eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451`
78
93
94
+
79
95
#### 给 Miner 帐户充值
80
96
81
- 执行以下命令将会给 miner 的钱包地址转入 ` 10000000000 ` 个 ` Particle `
97
+ 为了大家使用方便,我们创建了一个公共使用的超级客户端节点,拥有大量测试余额,首先需要下载这个超级客户端节点的配置:
82
98
83
- > 请将命令中的 ` miner_wallet_address ` 替换成上一步中生成的 miner 的钱包地址,例如上例中的 ` eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451 `
99
+ 国内测试网:
84
100
101
+ ```shell
102
+ mkdir -v ./super_client_config/
103
+ curl -kL -# ' https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/config.yaml' -o ./super_client_config/config.yaml
104
+ curl -kL -# ' https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/private.key' -o ./super_client_config/private.key
105
+ ```
106
+ 国外测试网:
85
107
86
108
```shell
87
- mkdir -v ./testnet/
88
- curl -kL -# ' https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/config.yaml' -o ./testnet/config.yaml
89
- curl -kL -# ' https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/private.key' -o ./testnet/private.key
109
+ mkdir -v ./super_client_config/
110
+ curl -kL -# ' https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/w/config.yaml' -o ./super_client_config/config.yaml
111
+ curl -kL -# ' https://raw.githubusercontent.com/covenantsql/covenantsql/develop/conf/testnet/w/private.key' -o ./super_client_config/private.key
112
+ ```
113
+
114
+ 执行以下命令将会给 miner 的钱包地址转入 `10000000000` 个 `Particle`
115
+
116
+ > 请将命令中的 `miner_wallet_address` 替换成上一步中生成的 miner 的钱包地址,例如上例中的 `eb46e59dbc4eac17b51762f051937a0082ff7423742866e4baff6c6053719451`
90
117
91
- docker run -it --rm -v $( pwd) /testnet/:/app/config/ \
118
+ ```shell
119
+ docker run -it --rm -v $(pwd)/super_client_config/:/app/config/ \
92
120
--entrypoint /app/cql covenantsql/covenantsql:latest -- \
93
121
transfer -config /app/config/config.yaml \
94
122
-wait-tx-confirm -to-user "<miner_wallet_address>" \
@@ -111,7 +139,7 @@ INFO succeed in sending transaction to CovenantSQL
111
139
查询 miner 的账户余额以确定转账成功
112
140
113
141
```shell
114
- docker run -it --rm -v $( pwd) /config /:/app/config/ \
142
+ docker run -it --rm -v $(pwd)/miner_config /:/app/config/ \
115
143
--entrypoint /app/cql covenantsql/covenantsql:latest -- \
116
144
wallet -config ./config/config.yaml
117
145
```
@@ -135,7 +163,7 @@ Particle balance 这行输出中可以看到转账的金额,这样 miner 就
135
163
136
164
在默认启动的情况下,Miner 是面向全网用户提供服务的。如果只希望给指定的 Miner 提供服务,需要在 Miner 上设置 TargetUsers 配置,并指定需要服务的用户的钱包地址。
137
165
138
- 修改 ` miner ` 的配置文件 ` ./config /config.yaml ` ,在 ` Miner ` 配置段下添加 ` TargetUsers ` 配置,指定一个需要服务的用户的 List,例如如下修改:
166
+ 修改 `miner` 的配置文件 `./miner_config /config.yaml`,在 `Miner` 配置段下添加 `TargetUsers` 配置,指定一个需要服务的用户的 List,例如如下修改:
139
167
140
168
```diff
141
169
--- old.yaml 2019-05-14 00:12:33.000000000 +0800
@@ -159,15 +187,15 @@ Particle balance 这行输出中可以看到转账的金额,这样 miner 就
159
187
```shell
160
188
docker create --name "<miner_name>" \
161
189
--restart always \
162
- -v $( pwd) /config /:/app/config/ \
190
+ -v $(pwd)/miner_config /:/app/config/ \
163
191
-v "<data_disk_dir>:/app/config/data/" \
164
192
-e COVENANT_ROLE=miner \
165
193
-e COVENANT_CONF=/app/config/config.yaml \
166
194
-e METRIC_WEB_ADDR=0.0.0.0:4665 \
167
195
--log-driver "json-file" \
168
196
--log-opt "max-size=1g" \
169
197
--log-opt "max-file=3" \
170
- -p " <miner_listen_port>:4661 " \
198
+ -p "<miner_listen_port>:<miner_listen_port> " \
171
199
covenantsql/covenantsql:latest
172
200
```
173
201
@@ -208,20 +236,26 @@ docker logs --tail=10 -f "<miner_name>"
208
236
209
237
执行如下命令将在 `./client_config` 目录下生成使用者账户的私钥和配置
210
238
239
+ > 如果需要生成国外区测试网配置,将上述命令的 `generate` 后面增加 `-testnet w` 参数。并且注意第一行输出会变成 `Generating testnet w config`
240
+
211
241
```shell
242
+ mkdir -v client_config
243
+
212
244
docker run -it --rm -v $(pwd)/client_config/:/app/config/ \
213
245
--entrypoint /app/cql covenantsql/covenantsql:latest -- \
214
246
generate /app/config/
215
247
```
216
248
249
+ 命令最后一行会显示 wallet address,注意需要将此 wallet address 加入到 miner 的 `TargetUsers` 配置中,并重启 miner。
250
+
217
251
##### 向使用者账户中充值
218
252
219
253
类似向 Miner 账户充值,请执行如下命令:
220
254
221
255
> 请将 `client_wallet_address` 替换为创建的使用者账号的钱包地址
222
256
223
257
```shell
224
- docker run -it --rm -v $( pwd) /testnet /:/app/config/ \
258
+ docker run -it --rm -v $(pwd)/super_client_config /:/app/config/ \
225
259
--entrypoint /app/cql covenantsql/covenantsql:latest -- \
226
260
transfer -config /app/config/config.yaml \
227
261
-wait-tx-confirm -to-user "<client_wallet_address>" \
@@ -356,7 +390,7 @@ docker run -d -v $(pwd)/client_config/:/app/config/ \
356
390
--log-driver "json-file" \
357
391
--log-opt "max-size=1g" \
358
392
--log-opt "max-file=3" \
359
- -p " <explorer_listen_port>:<explorer_listen_port> " \
393
+ -p "<explorer_listen_port>:4661 " \
360
394
covenantsql/covenantsql:latest
361
395
```
362
396
0 commit comments