Skip to content

Commit 1a16294

Browse files
Merge pull request #8 from tronprotocol/develop
merge develop to master
2 parents 0831017 + 7a4f504 commit 1a16294

File tree

130 files changed

+2138
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+2138
-131
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ gradlew.bat
1313

1414
# log
1515
logs
16+
consensus-logs
1617

1718
# lombok
1819
out

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ for us. We will appreciate it.
2525
### Create issues
2626

2727
Any significant improvement should be documented as [a GitHub
28-
issue](https://github.com/tron-network/java-tron/issues) before anybody
28+
issue](https://github.com/tronprotocol/java-tron/issues) before anybody
2929
starts working on it.
3030

3131
Also when filing an issue, make sure to answer these three questions:

README.md

Lines changed: 84 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
# What’s TRON? [![Build Status](https://www.travis-ci.org/tron-network/java-tron.svg?branch=develop)](https://www.travis-ci.org/tron-network/java-tron)
1+
<p align="center"><img width=27% src="https://github.com/tronprotocol/wiki/blob/master/images/tron.png"></p>
22

3+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
4+
[![Build Status](https://travis-ci.org/tronprotocol/java-tron.svg?branch=feature%2Fconsensus)](https://travis-ci.org/tronprotocol/java-tron)
5+
[![GitHub last commit](https://img.shields.io/github/last-commit/tronprotocol/java-tron.svg)](https://github.com/tronprotocol/java-tron/commits/develop)
6+
[![GitHub issues](https://img.shields.io/github/issues/tronprotocol/java-tron.svg)](https://github.com/tronprotocol/java-tron/issues)
7+
[![GitHub pull requests](https://img.shields.io/github/issues-pr/tronprotocol/java-tron.svg)](https://github.com/tronprotocol/java-tron/pulls)
8+
[![GitHub contributors](https://img.shields.io/github/contributors/tronprotocol/java-tron.svg)](https://github.com/tronprotocol/java-tron/graphs/contributors)
9+
[![license](https://img.shields.io/github/license/tronprotocol/java-tron.svg)](LICENSE)
10+
11+
# What's TRON?
312
TRON is a block chain-based decentralized smart protocol and an application development platform. It allows each user to freely publish, store and own contents and data, and in the decentralized autonomous form, decides an incentive mechanism and enables application developers and content creators through digital asset distribution, circulation and transaction, thus forming a decentralized content entertainment ecosystem.
413

514
TRON is a product of Web 4.0 and the decentralized internet of next generation.
@@ -9,29 +18,90 @@ TRON is a product of Web 4.0 and the decentralized internet of next generation.
918
**Download and build**
1019

1120
```shell
12-
> git clone https://github.com/tron-network/java-tron.git
21+
> git clone https://github.com/tronprotocol/java-tron.git
1322
> cd java-tron
1423
> gradle build
1524
```
1625

1726
**Import project to IDEA**
1827

19-
1. [File] -> [New] -> [Project from Existing Sources...]
20-
2. Select java-tron/build.gradle
21-
3. Dialog [Import Project from Gradle], confirm [Use auto-import] and [Use gradle wrapper task configuration] have been
28+
- [File] -> [New] -> [Project from Existing Sources...]
29+
- Select java-tron/build.gradle
30+
- Dialog [Import Project from Gradle], confirm [Use auto-import] and [Use gradle wrapper task configuration] have been
2231
selected,then select Gradle JVM(JDK 1.8)and click [OK]
2332

2433
# Testing
2534

26-
- Install Kafka, create two topics (block and transaction)
27-
- Adjust constant **DEFAULT_BOOTSTRAP_SERVERS** in ConsumerProperty.java file and ProducerProperty.java file to your Kafka's host(like:192.168.1.199:9092)
28-
- IDEA: [Edit Configurations...] -> [Program arguments]: **--type server**
29-
- Run Tron (server)
30-
- IDEA: [Edit Configurations...] -> [Program arguments]: **--type normal**
31-
- Run Tron (client)
32-
- Execute `help` command on the client
35+
**Install Kafka and create two topics (block and transaction)**
36+
37+
**Update the configuration**
38+
39+
File path: `<your workspace>/java-tron/src/main/resources/tron.conf`
40+
41+
```yml
42+
kafka {
43+
host = "127.0.0.1" # your Kafka's host
44+
port = ":9092" # your Kafka's port
45+
}
46+
```
47+
48+
**Starting program**
49+
50+
IDEA:
51+
- [Edit Configurations...] -> [Program arguments]: `--type server`
52+
- Run
53+
54+
![run](https://github.com/tronprotocol/wiki/blob/master/images/show-how/run.gif)
55+
56+
# Commands
57+
**help**
58+
59+
| Description | Example |
60+
| --- | --- |
61+
| Help tips | `help` |
62+
63+
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/help.gif)
64+
65+
**account**
66+
67+
| Description | Example |
68+
| --- | --- |
69+
| Get address | `account` |
70+
71+
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/account.gif)
72+
73+
**getbalance**
74+
75+
| Description | Example |
76+
| --- | --- |
77+
| Get balance | `getbalance` |
78+
79+
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/getbalance.gif)
80+
81+
**send [to] [balance]**
82+
83+
| Description | Example |
84+
| --- | --- |
85+
| Send balance to address | `send 2cddf5707aefefb199cb16430fb0f6220d460dfe 2` |
86+
87+
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/send.gif)
88+
89+
**printblockchain**
90+
91+
| Description | Example |
92+
| --- | --- |
93+
| Print blockchain | `printblockchain` |
94+
95+
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/printblockchain.gif)
96+
97+
**exit**
98+
99+
| Description | Example |
100+
| --- | --- |
101+
| Exit | `exit` |
33102

34-
# License
103+
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/exit.gif)
35104

36-
java-tron is released under the [LGPL-V3 license](LICENSE).
105+
# Contribution
106+
Contributions are welcomed and greatly appreciated. Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
37107

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ dependencies {
7373
compile group: 'io.atomix.copycat', name: 'copycat-server', version: '1.1.4'
7474
compile group: 'io.atomix.copycat', name: 'copycat-client', version: '1.1.4'
7575
compile group: 'io.atomix.catalyst', name: 'catalyst-netty', version: '1.1.1'
76+
compile group: 'net.jcip', name: 'jcip-annotations', version: '1.0'
7677
}
7778

7879
tasks.matching { it instanceof Test }.all {

src/main/java/org/tron/command/AccountCommand.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* java-tron is free software: you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License as published by
4+
* the Free Software Foundation, either version 3 of the License, or
5+
* (at your option) any later version.
6+
*
7+
* java-tron is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
14+
*/
115
package org.tron.command;
216

317
import org.tron.peer.Peer;

src/main/java/org/tron/command/Cli.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* java-tron is free software: you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License as published by
4+
* the Free Software Foundation, either version 3 of the License, or
5+
* (at your option) any later version.
6+
*
7+
* java-tron is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
14+
*/
115
package org.tron.command;
216

317
import org.tron.peer.Peer;
@@ -42,6 +56,16 @@ public void run(Peer peer) {
4256
case "printblockchain":
4357
new PrintBlockchainCommand().execute(peer, cmdParameters);
4458
break;
59+
60+
case "consensus":
61+
new ConsensusCommand().server();
62+
break;
63+
case "getmessage":
64+
new ConsensusCommand().getClient(cmdParameters);
65+
break;
66+
case "putmessage":
67+
new ConsensusCommand().putClient(cmdParameters);
68+
break;
4569
case "help":
4670
default:
4771
new HelpCommand().execute(peer, cmdParameters);

src/main/java/org/tron/command/Command.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* java-tron is free software: you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License as published by
4+
* the Free Software Foundation, either version 3 of the License, or
5+
* (at your option) any later version.
6+
*
7+
* java-tron is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
14+
*/
115
package org.tron.command;
216

317
import org.tron.peer.Peer;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* java-tron is free software: you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License as published by
4+
* the Free Software Foundation, either version 3 of the License, or
5+
* (at your option) any later version.
6+
*
7+
* java-tron is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
14+
*/
15+
package org.tron.command;
16+
17+
import org.tron.consensus.client.Client;
18+
import org.tron.consensus.server.Server;
19+
20+
public class ConsensusCommand {
21+
22+
public ConsensusCommand() {
23+
24+
}
25+
26+
public void server() {
27+
Server.serverRun();
28+
}
29+
30+
public void putClient(String[] args) {
31+
Client.putMessage(args);
32+
}
33+
34+
public void getClient(String[] args) {
35+
Client.getMessage(args[0]);
36+
}
37+
38+
public void usage() {
39+
System.out.println("");
40+
System.out.println("consensus server");
41+
System.out.println("Command: consensus");
42+
System.out.println("Description: Create a server.");
43+
System.out.println("");
44+
45+
System.out.println("");
46+
System.out.println("get Message");
47+
System.out.println("Command: getmessage [key]");
48+
System.out.println("Description: Get consensus Message");
49+
System.out.println("");
50+
51+
System.out.println("");
52+
System.out.println("put Message");
53+
System.out.println("Command: putmessage [key] [value]");
54+
System.out.println("Description: Put a consensus Message");
55+
System.out.println("");
56+
}
57+
58+
}

src/main/java/org/tron/command/ExitCommand.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* java-tron is free software: you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License as published by
4+
* the Free Software Foundation, either version 3 of the License, or
5+
* (at your option) any later version.
6+
*
7+
* java-tron is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
14+
*/
115
package org.tron.command;
216

317
import org.tron.peer.Peer;

src/main/java/org/tron/command/GetBalanceCommand.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* java-tron is free software: you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License as published by
4+
* the Free Software Foundation, either version 3 of the License, or
5+
* (at your option) any later version.
6+
*
7+
* java-tron is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
14+
*/
115
package org.tron.command;
216

317
import org.tron.peer.Peer;

0 commit comments

Comments
 (0)