波場(chǎng)節(jié)點(diǎn)介紹
波場(chǎng)網(wǎng)絡(luò)的節(jié)點(diǎn)主要分為兩類:超級(jí)節(jié)點(diǎn)迷殿,全節(jié)點(diǎn)
- 超級(jí)節(jié)點(diǎn)
包含全網(wǎng)全部區(qū)塊數(shù)據(jù)诉濒,并負(fù)責(zé)共識(shí)出塊 - 全節(jié)點(diǎn)
包含全網(wǎng)全部區(qū)塊數(shù)據(jù)
波場(chǎng)節(jié)點(diǎn)編譯安裝
筆者使用波場(chǎng)的master分支靶草, 官方git鏈接:https://github.com/tronprotocol/java-tron.git
- 服務(wù)基礎(chǔ)環(huán)境
JDK1.8
CentOS 7.2 6CUP 16G 300G - 節(jié)點(diǎn)編譯安裝
創(chuàng)建代碼目錄
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
編譯結(jié)果jar文件路徑
/home/tron/java-tron/build/libs/java-tron.jar
運(yùn)行節(jié)點(diǎn)
- a.) 節(jié)點(diǎn)需要的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.) 運(yùn)行Super Node
目標(biāo):創(chuàng)建超級(jí)節(jié)點(diǎn)兴想,并開始創(chuàng)建區(qū)塊
創(chuàng)建節(jié)點(diǎn)目錄并拷貝相關(guān)jar包及配置文件(見a項(xiàng))
# 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
創(chuàng)建你的tron賬號(hào)
可通過https://tronscan.org/ 去創(chuàng)建你的個(gè)人賬號(hào),并保存創(chuàng)建的私鑰及地址信息
修改配置文件
- 配置文件:/home/tron/superNode/config.conf
- 修改genesis.block.witnesses為你個(gè)人的tron地址
witnesses = [
{
address: 27PsvT28qhmUM1GHMVVJeyRskhB2pfzA1En,
url= "http://tron.com",
voteCount = 10000
}
]- 修改seed.node.ip.list 為服務(wù)器的IP:PORT
seed.node = {
ip.list = [
"123.207.xx.xxx:18888"
]
}- 第一個(gè)超級(jí)節(jié)點(diǎn),則需要修改needSyncCheck =false
block = {
needSyncCheck = false# first node : false, other : true
maintenanceTimeInterval = 21600000 // 1 day: 86400000(ms), 6 hours: 21600000(ms)
}- 可修改p2pversion 為你自己定制的版本雄人,建議不修改該值
啟動(dòng)超級(jí)節(jié)點(diǎn):
cd /home/tron/superNode
java -jar java-tron.jar -p 個(gè)人地址的私鑰 --witness -c /home/tron/superNode/config.conf
驗(yàn)證節(jié)點(diǎn)啟動(dòng)狀態(tài):
- 節(jié)點(diǎn)啟動(dòng)后,java-tron.jar的同級(jí)目錄上將生成 logs 和 output-directory 兩個(gè)文件夾
logs : 節(jié)點(diǎn)日志文件
output-directory : 節(jié)點(diǎn)數(shù)據(jù)存儲(chǔ)目錄- 查看日志念赶,確定節(jié)點(diǎn)是否正常啟動(dòng)础钠,并在出塊
超級(jí)節(jié)點(diǎn)啟動(dòng),并創(chuàng)建創(chuàng)世塊:
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
]
超級(jí)節(jié)點(diǎn)正常出塊:
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.) 運(yùn)行Full Node
目標(biāo):創(chuàng)建全節(jié)點(diǎn)叉谜,并連上自建的超級(jí)節(jié)點(diǎn)同步數(shù)據(jù)
準(zhǔn)備全節(jié)點(diǎn)的jar包及配置文件:
- 在全節(jié)點(diǎn)服務(wù)器上創(chuàng)建節(jié)點(diǎn)目錄:mkdir -p /home/tron/fullNode
- 拷貝步驟b)的jar包及配置文件到全節(jié)點(diǎn)服務(wù)器/home/tron/fullNode目錄下
修改配置文件:
- 將超級(jí)節(jié)點(diǎn)加入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)
}
啟動(dòng)全節(jié)點(diǎn):
cd /home/tron/fullNode
java -jar java-tron.jar -c /home/tron/fullNode/config.conf
驗(yàn)證全節(jié)點(diǎn):
- 節(jié)點(diǎn)啟動(dòng)后旗吁,java-tron.jar的同級(jí)目錄上將生成 logs 和 output-directory 兩個(gè)文件夾
logs : 節(jié)點(diǎn)日志文件
output-directory : 節(jié)點(diǎn)數(shù)據(jù)存儲(chǔ)目錄- 查看日志,確定節(jié)點(diǎn)是否正常啟動(dòng)停局,并在同步區(qū)塊
全節(jié)點(diǎn)啟動(dòng)很钓,并創(chuàng)建創(chuàng)世塊:
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
連接超級(jí)節(jié)點(diǎn):
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"
}
從超級(jí)節(jié)點(diǎn)同步區(qū)塊:
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
小結(jié)
至此已經(jīng)在個(gè)人的私有網(wǎng)絡(luò)上搭建起波場(chǎng)網(wǎng)絡(luò),根據(jù)實(shí)際需求董栽,可以增加超級(jí)節(jié)點(diǎn)及全節(jié)點(diǎn)码倦;后續(xù)筆者則將在此構(gòu)建私有波場(chǎng)的網(wǎng)絡(luò)的基礎(chǔ)上,介紹如何接入波場(chǎng)的測(cè)試網(wǎng)絡(luò)锭碳。