波场节点介绍
波场网络的节点主要分为两类:超级节点,全节点
- 超级节点
包含全网全部区块数据,并负责共识出块 - 全节点
包含全网全部区块数据
波场节点编译安装
笔者使用波场的master分支, 官方git链接:https://github.com/tronprotocol/java-tron.git
- 服务基础环境
JDK1.8
CentOS 7.2 6CUP 16G 300G - 节点编译安装
创建代码目录
mkdir -p /home/tron/
下载源码
cd /home/tron/
git clone -b master https://github.com/tronprotocol/java-tron.git
编译源码(本文主要将源码编译成jar形式)
cd java-tron
./gradlew clean shadowJar
编译结果jar文件路径
/home/tron/java-tron/build/libs/java-tron.jar
代码目录.png
编译信息.png
结果目录.png
运行节点
- a.) 节点需要的jar及配置文件
- java-tron.jar(/home/tron/java-tron/build/libs/java-tron.jar)
2.config.conf(/home/tron/java-tron/src/main/resources/config.conf)
- b.) 运行Super Node
目标:创建超级节点,并开始创建区块
创建节点目录并拷贝相关jar包及配置文件(见a项)
# mkdir -p /home/tron/superNode
# cp /home/tron/java-tron/build/libs/java-tron.jar /home/tron/superNode
# cp /home/tron/java-tron/src/main/resources/config.conf /home/tron/superNode
创建你的tron账号
可通过https://tronscan.org/ 去创建你的个人账号,并保存创建的私钥及地址信息
修改配置文件
- 配置文件:/home/tron/superNode/config.conf
- 修改genesis.block.witnesses为你个人的tron地址
witnesses = [
{
address: 27PsvT28qhmUM1GHMVVJeyRskhB2pfzA1En,
url= "http://tron.com",
voteCount = 10000
}
]- 修改seed.node.ip.list 为服务器的IP:PORT
seed.node = {
ip.list = [
"123.207.xx.xxx:18888"
]
}- 第一个超级节点,则需要修改needSyncCheck =false
block = {
needSyncCheck = false# first node : false, other : true
maintenanceTimeInterval = 21600000 // 1 day: 86400000(ms), 6 hours: 21600000(ms)
}- 可修改p2pversion 为你自己定制的版本,建议不修改该值
启动超级节点:
cd /home/tron/superNode
java -jar java-tron.jar -p 个人地址的私钥 --witness -c /home/tron/superNode/config.conf
验证节点启动状态:
- 节点启动后,java-tron.jar的同级目录上将生成 logs 和 output-directory 两个文件夹
logs : 节点日志文件
output-directory : 节点数据存储目录- 查看日志,确定节点是否正常启动,并在出块
超级节点启动,并创建创世块:
15:49:34.973 INFO [main] [o.t.c.d.Manager](Manager.java:305) create genesis block
15:49:34.975 INFO [main] [o.t.c.d.Manager](Manager.java:311) save block: BlockCapsule
[ hash=0000000000000000318b90bda4950d183bab0031b9005d4c0be1b180c21d6fde
number=0
parentId=0000000000000000000000000000000000000000000000000000000000000000
witness address=
generated by myself=true
generate time=1970-01-01 08:00:00.0
merkle root=c5b031aa2d4a77d237f785fcc760e17839a75f414b62765fcd0d614aff96ce09
txs size=4
]
超级节点正常出块:
15:55:06.008 INFO [Thread-5] [o.t.c.d.Manager](Manager.java:1108) update solid block, num = 109
15:55:06.008 INFO [Thread-5] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:719) update state flag = 0
15:55:06.008 INFO [Thread-5] [o.t.c.d.Manager](Manager.java:742) save block: BlockCapsule
[ hash=000000000000006d9b18d04237b60abb321264d2282d7a864083c32d0e3ddad9
number=109
parentId=000000000000006c7717e85f0d2db9fc089bccd9d5dc1c233a3a3bad5d557fb9
witness address=a008c7176410573e7a16bc62e5089bf25b49548ba4
generated by myself=true
generate time=2018-05-31 15:55:06.0
txs are empty
]
15:55:06.008 INFO [Thread-5] [o.t.c.s.WitnessService](WitnessService.java:241) Produce block successfully, blockNumber:109, abSlot[509251102], blockId:000000000000006d9b18d04237b60abb321264d2282d7a864083c32d0e3ddad9, transactionSize:0, blockTime:2018-05-31T15:55:06.000+08:00, parentBlockId:000000000000006d9b18d04237b60abb321264d2282d7a864083c32d0e3ddad9
15:55:06.008 INFO [Thread-5] [o.t.c.n.n.NodeImpl](NodeImpl.java:347) Ready to broadcast block 000000000000006d9b18d04237b60abb321264d2282d7a864083c32d0e3ddad9
- c.) 运行Full Node
目标:创建全节点,并连上自建的超级节点同步数据
准备全节点的jar包及配置文件:
- 在全节点服务器上创建节点目录:mkdir -p /home/tron/fullNode
- 拷贝步骤b)的jar包及配置文件到全节点服务器/home/tron/fullNode目录下
修改配置文件:
- 将超级节点加入active列表
active = [
"123.207.xx.xxx:18888"
]- 修改needSyncCheck =true
block = {
needSyncCheck = true# first node : false, other : true
maintenanceTimeInterval = 21600000 // 1 day: 86400000(ms), 6 hours: 21600000(ms)
}
启动全节点:
cd /home/tron/fullNode
java -jar java-tron.jar -c /home/tron/fullNode/config.conf
验证全节点:
- 节点启动后,java-tron.jar的同级目录上将生成 logs 和 output-directory 两个文件夹
logs : 节点日志文件
output-directory : 节点数据存储目录- 查看日志,确定节点是否正常启动,并在同步区块
全节点启动,并创建创世块:
16:19:15.399 INFO [main] [o.t.c.d.Manager](Manager.java:305) create genesis block
16:19:15.401 INFO [main] [o.t.c.d.Manager](Manager.java:311) save block: BlockCapsule
[ hash=0000000000000000318b90bda4950d183bab0031b9005d4c0be1b180c21d6fde
number=0
parentId=0000000000000000000000000000000000000000000000000000000000000000
witness address=
generated by myself=true
generate time=1970-01-01 08:00:00.0
merkle root=c5b031aa2d4a77d237f785fcc760e17839a75f414b62765fcd0d614aff96ce09
txs size=4
]
16:19:15.401 INFO [main] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:706) update latest block header number = 0
16:19:15.401 INFO [main] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:714) update latest block header id = 0000000000000000318b90bda4950d183bab0031b9005d4c0be1b180c21d6fde
连接超级节点:
16:24:52.645 INFO [TronJClientWorker-0] [HandshakeHandler](HandshakeHandler.java:73) channel active, /123.207.xx.xxx:18888
16:24:52.652 INFO [TronJClientWorker-0] [HandshakeHandler](HandshakeHandler.java:122) Handshake Send to /123.207.xx.xxx:18888, type: P2P_HELLO
from {
address: "47.74.xx.xxx"
port: 18888
nodeId: "\344\276\257|\232\261f\370r\367\231\203\034\t\212\336\212\034\350\260\020X\324\025\233:\223\'6\311-AD\002\203\236O\034\250\367\300,\313\211\236\210\263\352\327\026\335|\223\030\356\200\356\320D\030"
}
从超级节点同步区块:
16:24:53.872 INFO [TronJClientWorker-0] [MessageQueue](MessageQueue.java:104) Receive from /123.207.xx.xxx:18888, type: BLOCK
Num:1,ID:000000000000000111033c4e558ef57e3063a949856528c368aa126c1f4e6cef, trx size: 0
16:24:53.874 INFO [TronJClientWorker-0] [MessageQueue](MessageQueue.java:104) Receive from /123.207.xx.xxx:18888, type: BLOCK
Num:2,ID:0000000000000002f385a7ade9ef2afd9139cf4a491ddd0a4a001ce20eccf3c4, trx size: 0
16:24:53.874 INFO [TronJClientWorker-0] [MessageQueue](MessageQueue.java:104) Receive from /123.207.xx.xxx:18888, type: BLOCK
Num:3,ID:0000000000000003bcbd41f1ee2e64dad8e61b40342561f3a3184930d8dc4959, trx size: 0
16:24:53.875 INFO [TronJClientWorker-0] [MessageQueue](MessageQueue.java:104) Receive from /123.207.xx.xxx:18888, type: BLOCK
Num:4,ID:00000000000000046923e5cf0f999c3935d80bdeb8b4fa55b1aec58ed056a4fb, trx size: 0
小结
至此已经在个人的私有网络上搭建起波场网络,根据实际需求,可以增加超级节点及全节点;后续笔者则将在此构建私有波场的网络的基础上,介绍如何接入波场的测试网络。
网友评论