Skip to content

Commit 057c5e6

Browse files
authored
Merge pull request #9 from tronprotocol/dev
support version 3.2; add more info msg; neat command help [DCD-241]
2 parents b7393fb + 2263c25 commit 057c5e6

File tree

8 files changed

+164
-342
lines changed

8 files changed

+164
-342
lines changed

CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,33 @@
88

99
[ ] init - add option to build from source code
1010

11+
[ ] run - multiple (full) nodes
12+
13+
[ ] robust - catch more errors and provide better error msg
14+
15+
[ ] config -- add option to config to sync with newly deployed shasta testnet
16+
17+
[ ] status -- add config setting in status json
18+
19+
#### Version 0.1.4
20+
21+
[X] update to support version 3.2 fetch release, check version
22+
23+
[X] compatible check with version 3.2 release, and update config handler
24+
25+
[X] add more info message;
26+
27+
[X] provide a more neat yet detail help info and command
28+
1129
#### Version 0.1.3
1230

1331
[X] run - check single ps status
1432

1533
[X] keep track of all running nodes
1634

17-
[ ] run - monitor over all system status
35+
[X] run - monitor overall system status
1836

19-
[ ] run - multiple (full) nodes
37+
[X] set default value for all subcommand options
2038

2139
#### Version 0.1.2
2240

README.md

Lines changed: 98 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
A command line tool, to quick set up, turn on/off (multiple) tron nodes(full/solidity), and monitor running status.
1010

11+
| Python | JDK |
12+
|--------|-----|
13+
| 3.7+ | 1.8 |
14+
1115
* Learn more about tron on [TRON Developer Hub](https://developers.tron.network/docs/full-node)
1216

1317
* Join the community on [TRON Discord](https://discord.gg/GsRgsTD)
@@ -66,17 +70,20 @@ pip install troncli
6670
6771
## Usage
6872
69-
| Command | Functions | Example1 | Example2 |
70-
|--------------------------------------------------------------------------------------|------------------------------------|------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
71-
| tron-cli init --version | Init dirs and fetch code. | tron-cli init --version latest | tron-cli init --version 3.1.3 |
72-
| tron-cli config --nettype --fullhttpport --solhttpport --fullgrpcport --solgrpcport | Create and customize config files. | tron-cli config --nettype private --fullhttpport 8500 --solhttpport 8600 --fullgrpcport 50051 --solgrpcport 5001 | tron-cli config --nettype main --fullhttpport 8500 --solhttpport 8600 --fullgrpcport 50051 --solgrpcport 5001 |
73-
| tron-cli run --nodetype | Run node. | tron-cli run --nodetype full | tron-cli run --nodetype sol |
74-
| tron-cli stop --pid | Stop node. | tron-cli stop --pid 7777 | tron-cli stop --pid 7777 |
75-
| tron-cli status --node | Monitor nodes status. | tron-cli status --node all | tron-cli status --node 777 |
76-
| tron-cli quick | Quick start. | tron-cli quick | tron-cli quick |
77-
| tron-cli -h, --help | Check help manual. | tron-cli -h | tron-cli --help |
78-
73+
| Command | Functions | Example1 | Example2 |
74+
|--------------------------------------------------------------------------------------|------------------------------------|-----------------|---------------------------------------------------------------------------------------------------------------|
75+
| tron-cli init --version | Init dirs and fetch code. | tron-cli init | tron-cli init --version 3.1.3 |
76+
| tron-cli config --nettype --fullhttpport --solhttpport --fullgrpcport --solgrpcport | Create and customize config files. | tron-cli config | tron-cli config --nettype main --fullhttpport 8500 --solhttpport 8600 --fullgrpcport 50051 --solgrpcport 5001 |
77+
| tron-cli run --nodetype | Run node. | tron-cli run | tron-cli run --nodetype sol |
78+
| tron-cli stop --pid | Stop node. | tron-cli stop | tron-cli stop --pid 7777 |
79+
| tron-cli status --node | Monitor nodes status. | tron-cli status | tron-cli status --node 777 |
80+
| tron-cli quick | Quick start. | tron-cli quick | tron-cli quick |
81+
| tron-cli -h, --help | Check help manual. | tron-cli -h | tron-cli --help |
82+
#### overall
7983
84+
```
85+
tron-cli -h
86+
```
8087
```
8188
usage: tron-cli [-h] {init,config,run,stop,status,quick} ...
8289

@@ -87,13 +94,86 @@ optional arguments:
8794

8895
subcommands:
8996
{init,config,run,stop,status,quick}
90-
init Init dirs and fetch code. >> Parameter(s): --version
91-
config Create customize config files. >> Parameter(s):
92-
--nettype --fullhttpport --solhttpport --fullgrpcport
93-
--solgrpcport
94-
run Run node. >> Parameter(s): --nodetype
95-
stop Stop node. >> Parameter(s): --pid
96-
status Monitor nodes status. >> Parameter(s): --node
97+
init Init dirs and fetch code.
98+
config Create customize config files.
99+
run Run node.
100+
stop Stop node.
101+
status Monitor nodes status.
97102
quick Quick start. (run a full private node by one command)
98-
>> Example: tron-cli quick
103+
```
104+
105+
##### subcommand: init
106+
107+
```
108+
tron-cli init -h
109+
```
110+
```
111+
usage: tron-cli init [-h] [--version VERSION]
112+
113+
optional arguments:
114+
-h, --help show this help message and exit
115+
--version VERSION specify java-tron version
116+
```
117+
118+
##### subcommand: config
119+
120+
```
121+
tron-cli config -h
122+
```
123+
```
124+
usage: tron-cli config [-h] [--nettype NETTYPE] [--fullhttpport FULLHTTPPORT]
125+
[--solhttpport SOLHTTPPORT] [--fullrpcport FULLRPCPORT]
126+
[--solrpcport SOLRPCPORT] [--enablememdb ENABLEMEMDB]
127+
128+
optional arguments:
129+
-h, --help show this help message and exit
130+
--nettype NETTYPE specify net type [main, private]
131+
--fullhttpport FULLHTTPPORT
132+
specify full http port
133+
--solhttpport SOLHTTPPORT
134+
specify solidity http port
135+
--fullrpcport FULLRPCPORT
136+
specify full rpc port
137+
--solrpcport SOLRPCPORT
138+
specify solidity rpc port
139+
--enablememdb ENABLEMEMDB
140+
```
141+
142+
##### subcommand: run
143+
144+
```
145+
tron-cli run -h
146+
```
147+
```
148+
usage: tron-cli run [-h] [--nodetype NODETYPE]
149+
150+
optional arguments:
151+
-h, --help show this help message and exit
152+
--nodetype NODETYPE specify node type [full, sol]
153+
```
154+
155+
##### subcommand: stop
156+
157+
```
158+
tron-cli stop -h
159+
```
160+
```
161+
usage: tron-cli stop [-h] --pid PID
162+
163+
optional arguments:
164+
-h, --help show this help message and exit
165+
--pid PID stop node by given pid
166+
```
167+
168+
##### subcommand: status
169+
170+
```
171+
tron-cli status -h
172+
```
173+
```
174+
usage: tron-cli status [-h] [--node NODE]
175+
176+
optional arguments:
177+
-h, --help show this help message and exit
178+
--node NODE check specific node detail by pid
99179
```

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def cat(files, join_str=''):
1414
PKG_NAME = 'troncli'
1515
PKG_AUTHOR = ', '.join(['Weiyu X'])
1616
PKG_SCRIPTS = ['tron-cli']
17-
PKG_VERSION = '0.1.3'
17+
PKG_VERSION = '0.1.4'
1818
PKG_REQUIRES = [
1919
'bleach==3.0.2',
2020
'cbox==0.5.0',

troncli/cli.py

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
@cbox.cmd
1414
def init(version: str = 'lastest'):
1515
"""Init dirs and fetch code.
16-
>>
17-
Option(s):
18-
--version
16+
17+
:param version: specify java-tron version
1918
"""
2019

2120
init_handler = h_init.Init()
@@ -30,16 +29,16 @@ def init(version: str = 'lastest'):
3029
def config(nettype: str = 'private',
3130
fullhttpport: int = 8500,
3231
solhttpport: int = 8600,
33-
fullgrpcport: int = 50051,
34-
solgrpcport: int = 50001):
32+
fullrpcport: int = 50051,
33+
solrpcport: int = 50001,
34+
enablememdb: str = 'True'):
3535
"""Create customize config files.
36-
>>
37-
Option(s):
38-
--nettype
39-
--fullhttpport
40-
--solhttpport
41-
--fullgrpcport
42-
--solgrpcport
36+
37+
:param nettype: specify net type [main, private]
38+
:param fullhttpport: specify full http port
39+
:param solhttpport: specify solidity http port
40+
:param fullrpcport: specify full rpc port
41+
:param solrpcport: specify solidity rpc port
4342
"""
4443

4544
config_handler = h_config.Config()
@@ -50,17 +49,17 @@ def config(nettype: str = 'private',
5049
loop.run_until_complete(config_handler.set_net_type(nettype))
5150
loop.run_until_complete(config_handler.set_http_port(fullhttpport, 'full'))
5251
loop.run_until_complete(config_handler.set_http_port(solhttpport, 'sol'))
53-
loop.run_until_complete(config_handler.set_grpc_port(fullgrpcport, 'full'))
54-
loop.run_until_complete(config_handler.set_grpc_port(solgrpcport, 'sol'))
52+
loop.run_until_complete(config_handler.set_rpc_port(fullrpcport, 'full'))
53+
loop.run_until_complete(config_handler.set_rpc_port(solrpcport, 'sol'))
54+
loop.run_until_complete(config_handler.set_db_version(enablememdb))
5555
loop.run_until_complete(config_handler.export())
5656

5757

5858
@cbox.cmd
5959
def run(nodetype: str = 'full'):
6060
"""Run node.
61-
>>
62-
Option(s):
63-
--nodetype
61+
62+
:param nodetype: specify node type [full, sol]
6463
"""
6564
utils.progress_msg('Starting node(s)')
6665
worker = h_worker.Worker()
@@ -72,9 +71,8 @@ def run(nodetype: str = 'full'):
7271
@cbox.cmd
7372
def stop(pid: str):
7473
"""Stop node.
75-
>>
76-
Option(s):
77-
--pid
74+
75+
:param pid: stop node by given pid
7876
"""
7977
worker = h_worker.Worker()
8078
utils.progress_msg('Shutting down node(s)')
@@ -86,9 +84,8 @@ def stop(pid: str):
8684
@cbox.cmd
8785
def status(node: str = 'all'):
8886
"""Monitor nodes status.
89-
>>
90-
Option(s):
91-
--node
87+
88+
:param node: check specific node detail by pid
9289
"""
9390
status_handler = h_status.Status()
9491
if node == 'all':
@@ -102,10 +99,10 @@ def quick():
10299
"""Quick start. (run a full private node by one command)
103100
"""
104101
utils.logo()
105-
init('lastest')
106-
config('private', 8500, 8600, 50051, 50001)
107-
run('full')
108-
status('all')
102+
init()
103+
config()
104+
run()
105+
status()
109106

110107

111108
def main():

troncli/h_config.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ async def set_http_port(self, port_num, node_type):
4848
else:
4949
utils.warning_msg('wrong node_type')
5050

51-
async def set_grpc_port(self, port_num, node_type):
51+
async def set_rpc_port(self, port_num, node_type):
5252
if node_type == 'full':
5353
self.full_config[' node'][' rpc'][' port'] = port_num
5454
self.sol_config[' node'][' trustNode'] = LOCAL_HOST + str(port_num)
55-
utils.success_msg('full-node grpc request set to listen: ')
55+
utils.success_msg('full-node rpc request set to listen: ')
5656
utils.msg(LOCAL_HOST + str(port_num))
5757
elif node_type == 'sol':
5858
self.sol_config[' node'][' rpc'][' port'] = port_num
59-
utils.success_msg('solidity-node grpc request set to listen: ')
59+
utils.success_msg('solidity-node rpc request set to listen: ')
6060
utils.msg(LOCAL_HOST + str(port_num))
6161
else:
6262
utils.warning_msg('wrong node_type')
@@ -114,3 +114,15 @@ async def set_net_type(self, net_type):
114114
' address': 'TPL66VK2gCXNCD7EJg9pgJRfqcRazjhUZY',
115115
' url': 'http://tronstudio.com',
116116
' voteCount': 10000}]
117+
118+
async def set_db_version(self, enablememdb):
119+
if enablememdb == 'disable' or enablememdb == '0' or enablememdb == 'False':
120+
# enablememdb = False
121+
self.full_config[' storage'][' db.version'] = 1
122+
utils.success_msg('Enable in memeory db:')
123+
utils.msg('False')
124+
else:
125+
# enablememdb = True
126+
self.full_config[' storage'][' db.version'] = 2
127+
utils.success_msg('Enable in memeory db:')
128+
utils.msg('True')

troncli/h_worker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ async def run(self, node_type):
1717
pid = await self.start(node_type)
1818
utils.success_msg('node running at pid:')
1919
utils.msg(str(pid))
20-
utils.info_msg('To stop this node: tron-cli stop --pid ' + str(pid))
20+
utils.info_msg('To stop this node:')
21+
utils.msg('tron-cli stop --pid ' + str(pid))
22+
utils.info_msg('To check node running details:')
23+
utils.msg('tron-cli status --node ' + str(pid))
2124
await self.nodes_list(node_type, pid, 'add')
2225

2326
async def stop(self, pid):

troncli/json_store.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060

6161
" rpc": {
6262
" port": 50051,
63-
" maxConnectionIdleInMillis": 60000
63+
" maxConnectionIdleInMillis": 60000,
64+
" minEffectiveConnection": 0
6465
}
6566
},
6667

0 commit comments

Comments
 (0)