Published: 14 Aug 2018 › Updated: 14 Aug 2018

byteball 见证节点witeness
背景
公司需要上线byteball的见证节点,在测试环境同步testnet见证节点数据
安装节点软件,并做数据同步
安装node,npm等环境(必须是官方指定的版本),npm 配置淘宝源加速
apt install g++ make
wget https://nodejs.org/download/release/v5.12.0/node-v5.12.0-linux-x64.tar.xz
tar xvf node-v5.12.0-linux-x64.tar.xz
mv node-v5.12.0-linux-x64 /usr/local/node
ln -s /usr/local/node/bin/node /usr/local/bin/node
ln -s /usr/local/node/bin/npm /usr/local/bin/npm
npm config set registry https://registry.npm.taobao.org
高版本或者低版本的node/npm在npm install的时候会出现各种各样的问题,建议直接卸载系统内部的node和npm,手动安装node-v5.12.0版本
pull 最新的byteball-witness代码并编译
cd /opt/byteball
git clone https://github.com/byteball/byteball-witness
cd byteball-witness
npm install
测试网络(testnet)修改配置文件
测试网络配置文件修改
- 由于我们连接的测试网络,需要执行byteball-witness目录下的
testnetify.sh文件,但是这个文件还缺少一行,完整如下:
#!/bin/sh
sed -ie "s/version = '1.0'/version = '1.0t'/; s/alt = '1'/alt = '2'/" node_modules/byteballcore/constants.js
sed -ie "s/.hub = 'byteball.org\/bb'/.hub = 'byteball.org\/bb-test'/" conf.js
主要是修改了node_modules/byteballcore/constants.js和conf.js文件,修改成为测试网络的配置。
节点配置文件修改
- exports.bLight = false;
- 见证节点要求同步线上所有的DAG数据到本地,故
conf.js文件里的exports.bLight = false;
- 见证节点要求同步线上所有的DAG数据到本地,故
- exports.port = 6611;
- 打开监听端口
- exports.bServeAsHub = false;
- 是否是Serve Hub,false
conf.js文件配置说明
bLight: 是否是轻钱包,默认是false ,(light client (true) or full node (false).storage: 区块存储方式,可以是mysql和sqlite,默认sqlite,如果需要修改为mysql,需要将这个sql库导入,并在conf.json文件加入这个配置项:{
"port": 3306,
"storage": "mysql",
"database": {
"max_connections": 30,
"host" : "localhost",
"user" : "byteball",
"password" : "yourmysqlpassword",
"name" : "byteball"
}
}
control_addresses: 远端可以配对的设备地址。可以在GUI钱包menu button-Settings-Global preference- Device address找到,以0开头的字符串payout_address: 执行pay命令时候付款的对方地址。可以填写自己的钱包地址,作为后面获取见证节点获取奖励的接受地址deviceName: 在对话界面显示的名称permanent_paring_secret: 加密配对地址的认证词,跟在配对地址#后面KEYS_FILENAME: 保存的keys文件名称
以下文件是示例:
/*jslint node: true */
"use strict";
exports.port = 6611;
//exports.myUrl = 'wss://mydomain.com/bb';
exports.bServeAsHub = false;
exports.bLight = false;
exports.storage = 'sqlite';
exports.hub = 'byteball.org/bb-test';
exports.deviceName = ‘Witness-test';
exports.permanent_pairing_secret = 'randomstring';
exports.control_addresses = ['DEVICE ALLOWED TO CHAT'];
exports.payout_address = 'WHERE THE MONEY CAN BE SENT TO';
exports.bSingleAddress = true;
exports.THRESHOLD_DISTANCE = 50;
exports.MIN_INTERVAL = 60*1000; // min interval between witnessings in milliseconds
exports.MIN_AVAILABLE_WITNESSINGS = 100;
exports.KEYS_FILENAME = 'keys.json';
console.log('finished witness conf');
启动节点
第一次启动
- 节点启动的时候只能在前端运行,按
Ctrl+Z放在后台,所以建议开启一个screen来运行,第一次运行会让输入设备名称和加密钱包密码,这里自己定义好并记住
screen -S witness
cd /opt/byteball/byteball-witness
node start.js
- 启动后,会在启动用户的家目录生产
.config/byteball-witness数据文件,里面包括这些文件:
root@sh-gdex-08:~/.config/headless-byteball# ll
total 2664
drwx------ 2 root root 4096 Aug 9 18:20 ./
drwx------ 5 root root 4096 Aug 9 18:00 ../
-rw-r--r-- 1 root root 811008 Aug 9 18:00 byteball-light.sqlite
-rw-r--r-- 1 root root 32768 Aug 9 19:45 byteball-light.sqlite-shm
-rw-r--r-- 1 root root 795192 Aug 9 19:45 byteball-light.sqlite-wal
-rw-r--r-- 1 root root 0 Aug 9 18:20 byteball.sqlite
-rw-r--r-- 1 root root 31 Aug 9 18:00 conf.json
-rw-r--r-- 1 root root 243 Aug 9 18:00 keys.json
-rw-r--r-- 1 root root 1060736 Aug 9 19:55 log.txt
- 这下面的除了log.txt文件之外都需要做好备份
keys.json:是钱包的加密文件conf.json:配置文件,包括上面的msql的配置都放在里面,会覆盖默认的conf.js文件*.sqlite: 文件是数据文件,可以用sqlite连接进去看里面的表的结构
- 第一次启动完会自动退出,提示修改
~/.config/byteball-witness/conf.json,增加admin_email和from_email地址admin_email: 作为接受节点报警的邮件地址from_email: 作为发送邮件的地址,前提是需要在本地部署SMTP服务
第二次启动
- 启动命令和第一次一样,启动后输入之前设置的密码。开始数据同步。线上大概有30G的DAG数据需要同步
转帐到钱包地址
节点启动同步完数据需要转一笔 byte 到节点钱包地址,大概 100000 bytes 。之后就可以让其他用户的钱包修改他们的见证节点地址为自己的节点地址 ⚠️但是需要关注邮件告警,"Only [1-100] spendable outputs left, will split an output of 25000”,见证节点同步数据缺失超过100个区块会被停止作为见证节点的资格
怎样检测是否是见证节点
线上可以使用这个这样页面: https://byteball-cashback-witness.com/balance-and-withdrawal.php,输入框输入你的见证节点的地址,如果是见证节点,会红字提示:"Witness addresses can not use cashback witness system.",不是则没有这个提示
Leave byteball 见证节点witeness to:
Read more #byteball posts
Best Posts From ioung
We have not curated any of ioung's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.