基於以太坊的DPOS實現(一)原始碼及測試執行
阿新 • • 發佈:2018-12-12
原始碼
目錄
測試執行
安裝環境
開始之前請先確認已經安裝配置好Go語言環境,安裝包可以從https://golang.org下載,如果連不Go的官網請自行百度下安裝包。gttc現在支援Go版本為 1.9.x、1.10.x 及1.11.x。
$ go version
go version go1.11 darwin/amd64
下載gttc
$ go get github.com/TTCECO/gttc
$ cd $HOME/go/src/github.com/TTCECO/gttc
# 如果安裝Go時,自己指定了GOPATH,則
$ cd $GOPATH/src/github.com/TTCECO/gttc
國內用go get
編譯
測試的時候,我們只需要進入cmd/gttc編譯這一個檔案即可。
$ cd $HOME/go/src/github.com/TTCECO/gttc/cmd/gttc
$ go build
如果沒有任何提示,那恭喜你,編譯成功了,你會發現當前目錄下多了一個gttc的檔案
執行測試
$ ./gttc --testnet
如果出現如下提示,則說明已經連上我們部署的ttc測試網路,開始進行同步。
INFO [09-27|11:23:00] Maximum peer count ETH=25 LES=0 total=25 INFO [09-27|11:23:00] Starting peer-to-peer node instance=gttc/v0.0.4-unstable/darwin-amd64/go1.11 INFO [09-27|11:23:00] Allocated cache and file handles database=/Users/tataufo/Library/Ethereum/testnet/gttc/chaindata cache=768 handles=128 INFO [09-27|11:23:00] Persisted trie from memory database nodes=54 size=9.96kB time=63.432µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B INFO [09-27|11:23:00] Initialised chain configuration config="{ChainID: 8434 Homestead: 1 EIP150: 2 EIP155: 3 EIP158: 3 Byzantium: 4 Constantinople: <nil> Engine: alien}" INFO [09-27|11:23:00] Initialising Ethereum protocol versions="[63 62]" network=8434 INFO [09-27|11:23:01] Loaded most recent local header number=437847 hash=b41bfe…f68e3f td=437848 INFO [09-27|11:23:01] Loaded most recent local full block number=437847 hash=b41bfe…f68e3f td=437848 INFO [09-27|11:23:01] Loaded most recent local fast block number=437847 hash=b41bfe…f68e3f td=437848 INFO [09-27|11:23:01] Loaded local transaction journal transactions=0 dropped=0 INFO [09-27|11:23:01] Regenerated local transaction journal transactions=0 accounts=0 WARN [09-27|11:23:01] Blockchain not empty, fast sync disabled INFO [09-27|11:23:01] Starting P2P networking INFO [09-27|11:23:03] UDP listener up self=enode://9a7318a48c4d9b279e96c157db6b4651672dac72bd57fc23736c06c65d60464e4
[email protected][::]:30303 INFO [09-27|11:23:03] RLPx listener up self=enode://9a7318a48c4d9b279e96c157db6b4651672dac72bd57fc23736c06c65d60464e4[email protected][::]:30303 INFO [09-27|11:23:03] IPC endpoint opened url=/Users/tataufo/Library/Ethereum/testnet/gttc.ipc INFO [09-27|11:23:07] Block synchronisation started INFO [09-27|11:23:08] Imported new chain segment blocks=6 txs=212 mgas=4.827 elapsed=72.939ms mgasps=66.176 number=437853 hash=cdfc63…9e4ecd cache=50.93kB INFO [09-27|11:23:09] Imported new chain segment blocks=6 txs=216 mgas=4.918 elapsed=80.791ms mgasps=60.872 number=437859 hash=56ee8c…7dc15d cache=97.11kB INFO [09-27|11:23:11] Imported new chain segment blocks=156 txs=5625 mgas=128.070 elapsed=1.953s mgasps=65.544 number=438015 hash=714503…70370a cache=1.01mB INFO [09-27|11:23:19] Imported new chain segment blocks=631 txs=22721 mgas=517.312 elapsed=8.005s mgasps=64.623 number=438646 hash=0bbc83…aa69da cache=1.01mB INFO [09-27|11:23:24] Imported new chain segment blocks=412 txs=14818 mgas=337.376 elapsed=5.203s mgasps=64.832 num