Skip to content

Commit ddfe87b

Browse files
committed
refactor and code the main loopls
1 parent c1e5d3f commit ddfe87b

124 files changed

Lines changed: 4914 additions & 5710 deletions

File tree

Some content is hidden

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

.codeclimate.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
version: "2"
2-
plugins:
3-
sonar-java:
4-
enabled: true
5-
config:
1+
version: "2"
2+
plugins:
3+
sonar-java:
4+
enabled: true
5+
config:
66
sonar.java.source: 8

.github/ISSUE_TEMPLATE.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
Please answer these questions before submitting your issue. Thanks!
2-
3-
1. What did you do?
4-
If possible, provide a recipe for reproducing the error.
5-
6-
7-
2. What did you expect to see?
8-
9-
10-
11-
3. What did you see instead?
12-
13-
1+
Please answer these questions before submitting your issue. Thanks!
2+
3+
1. What did you do?
4+
If possible, provide a recipe for reproducing the error.
5+
6+
7+
2. What did you expect to see?
8+
9+
10+
11+
3. What did you see instead?
12+
13+

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
**What does this PR do?**
2-
3-
**Why are these changes required?**
4-
5-
**This PR has been tested by:**
6-
- Unit Tests
7-
- Manual Testing
8-
9-
**Follow up**
10-
11-
**Extra details**
12-
1+
**What does this PR do?**
2+
3+
**Why are these changes required?**
4+
5+
**This PR has been tested by:**
6+
- Unit Tests
7+
- Manual Testing
8+
9+
**Follow up**
10+
11+
**Extra details**
12+

README.md

Lines changed: 4 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -19,101 +19,15 @@ TRON is a block chain-based decentralized smart protocol and an application deve
1919

2020
TRON is a product of Web 4.0 and the decentralized internet of next generation.
2121

22-
# Quick Start
23-
24-
> Note: This repository is a IDEA project which you can simply download and import.
25-
26-
**Download and build**
27-
28-
```shell
29-
> git clone https://github.com/tronprotocol/java-tron.git
30-
> cd java-tron
31-
> gradle build
32-
```
33-
34-
**Import project to IDEA**
35-
36-
- [File] -> [New] -> [Project from Existing Sources...]
37-
- Select java-tron/build.gradle
38-
- Dialog [Import Project from Gradle], confirm [Use auto-import] and [Use gradle wrapper task configuration] have been
39-
selected,then select Gradle JVM(JDK 1.8)and click [OK]
40-
41-
# Testing
42-
43-
**Install Kafka and create two topics (block and transaction)**
22+
4423

45-
**Update the configuration**
46-
47-
48-
**Starting program**
49-
50-
IDEA:
51-
- [Edit Configurations...] -> [Add New Configuration] -> [Application]
52-
- [Edit Configurations...] -> [Main Class]: `org.tron.example.Tron`
53-
- [Edit Configurations...] -> [Use classpath of module]: `java-tron_main`
54-
- [Edit Configurations...] -> [Program arguments]: `--type server`
55-
- Run
56-
57-
![run](https://github.com/tronprotocol/wiki/blob/master/images/commands/default-set.gif)
58-
59-
or simply from terminal:
60-
- ./gradlew run -Pserver=true
61-
62-
**Complete process**
24+
# Quick Start
6325

64-
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/process.gif)
26+
Read the [Quick Srart](http://wiki.tron.network/en/latest/quick_start.html).
6527

66-
**Other nodes to join need to modify the connection ip**
67-
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/node-ip.gif)
6828

6929
# Commands
70-
**help**
71-
72-
| Description | Example |
73-
| --- | --- |
74-
| Help tips | `help` |
75-
76-
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/help.gif)
77-
78-
**account**
79-
80-
| Description | Example |
81-
| --- | --- |
82-
| Get address | `account` |
83-
84-
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/account.gif)
85-
86-
**getbalance**
87-
88-
| Description | Example |
89-
| --- | --- |
90-
| Get balance | `getbalance` |
91-
92-
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/getbalance.gif)
93-
94-
**send [to] [balance]**
95-
96-
| Description | Example |
97-
| --- | --- |
98-
| Send balance to address | `send 2cddf5707aefefb199cb16430fb0f6220d460dfe 2` |
99-
100-
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/send1.gif)
101-
102-
**printblockchain**
103-
104-
| Description | Example |
105-
| --- | --- |
106-
| Print blockchain | `printblockchain`|
107-
108-
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/printblockchain.gif)
109-
110-
**exit**
111-
112-
| Description | Example |
113-
| --- | --- |
114-
| Exit | `exit` |
115-
116-
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/exit.gif)
30+
Read the [Commands](http://wiki.tron.network/en/latest/quick_start.html#commands).
11731

11832
# Contact
11933

build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apply plugin: 'application'
77
apply plugin: 'checkstyle'
88

99
sourceCompatibility = 1.8
10-
mainClassName = 'org.tron.program.example.Tron'
10+
mainClassName = 'org.tron.program.FullNode'
1111

1212
repositories {
1313
mavenCentral()
@@ -112,8 +112,9 @@ dependencies {
112112
compile group: 'io.grpc', name: 'grpc-stub', version: '1.9.0'
113113
// end google grpc
114114

115-
116-
115+
compile group: 'io.scalecube', name: 'scalecube-services', version: '1.0.7'
116+
compile group: 'io.scalecube', name: 'scalecube-cluster', version: '1.0.7'
117+
compile group: 'io.scalecube', name: 'scalecube-transport', version: '1.0.7'
117118
}
118119

119120
task lint(type: Checkstyle) {
@@ -148,9 +149,9 @@ sourceSets {
148149

149150

150151
proto {
151-
srcDir 'src/proto'
152-
}
152+
srcDir 'src/proto'
153153
}
154+
}
154155

155156
}
156157

@@ -171,7 +172,7 @@ protobuf {
171172
generateProtoTasks {
172173
all().each { task ->
173174
task.builtins {
174-
java {outputSubDir = "gen"}
175+
java { outputSubDir = "gen" }
175176
}
176177
}
177178
all()*.plugins {

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM tronprotocol/centos7-jdk8
22
MAINTAINER tronprotocol
33

44
# Install dependencies && Download java-tron
5-
RUN yum update && \
5+
RUN yum update -y && \
66
yum install -y git && \
77
git clone https://github.com/tronprotocol/java-tron.git /home/java-tron
88

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
distributionBase=GRADLE_USER_HOME
2-
distributionPath=wrapper/dists
3-
zipStoreBase=GRADLE_USER_HOME
4-
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
zipStoreBase=GRADLE_USER_HOME
4+
zipStorePath=wrapper/dists
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip

gradlew

100755100644
File mode changed.

src/main/java/org/tron/common/application/Application.java

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,32 @@
1212
* You should have received a copy of the GNU General Public License
1313
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1414
*/
15+
1516
package org.tron.common.application;
1617

17-
import com.google.inject.Injector;
18-
import org.slf4j.Logger;
19-
import org.slf4j.LoggerFactory;
2018
import org.tron.core.db.BlockStore;
2119
import org.tron.core.net.node.Node;
22-
import org.tron.core.net.node.NodeImpl;
23-
24-
public class Application {
25-
26-
private static final Logger logger = LoggerFactory.getLogger("Application");
27-
private Injector injector;
28-
29-
private NodeImpl p2pnode;
20+
import org.tron.program.Args;
3021

31-
private ServiceContainer services;
22+
public interface Application {
3223

33-
public Application(Injector injector) {
34-
this.injector = injector;
24+
void setOptions(Args args);
3525

36-
}
26+
void init(String path, Args args);
3727

38-
public Application() {
39-
this.services = new ServiceContainer();
40-
p2pnode = new NodeImpl();
41-
}
28+
void initServices(Args args);
4229

43-
public Injector getInjector() {
44-
return injector;
45-
}
30+
void startup();
4631

47-
public void addService(Service service) {
48-
this.services.add(service);
49-
}
32+
void shutdown();
5033

51-
public BlockStore getBlockStoreS() {
52-
return p2pnode.getBlockdb();
53-
}
34+
void startServies();
5435

55-
public Node getP2pNode() {
56-
return p2pnode.getP2pNode();
57-
}
58-
public void run() {
59-
p2pnode.start();
60-
this.services.start();
61-
}
36+
void shutdownServices();
6237

38+
Node getP2pNode();
6339

64-
public void shutdown() {
65-
logger.info("shutting down");
66-
this.services.stop();
67-
System.exit(0);
68-
}
40+
BlockStore getBlockStoreS();
6941

42+
void addService(Service service);
7043
}

src/main/java/org/tron/common/application/ApplicationFactory.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* You should have received a copy of the GNU General Public License
1313
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1414
*/
15+
1516
package org.tron.common.application;
1617

1718
import com.google.inject.Guice;
@@ -20,7 +21,7 @@
2021
public class ApplicationFactory {
2122

2223
/**
23-
* Build a Guice instance
24+
* Build a Guice instance.
2425
*
2526
* @return Guice
2627
*/
@@ -30,24 +31,19 @@ public Injector buildGuice() {
3031
}
3132

3233
/**
33-
* Build a new application
34-
*
35-
* @return
34+
* Build a new application.
3635
*/
3736
public Application build() {
38-
return new Application(buildGuice());
37+
return new ApplicationImpl();
3938
}
4039

4140
/**
42-
* Build a new cli application
43-
*
44-
* @return
41+
* Build a new cli application.
4542
*/
46-
public CliApplication buildCli() {
47-
return new CliApplication(buildGuice());
48-
}
49-
50-
public static Application create() {
51-
return new Application();
43+
//public CliApplication buildCli() {
44+
// return new CliApplication(buildGuice());
45+
//}
46+
public static Application create() {
47+
return new ApplicationImpl();
5248
}
5349
}

0 commit comments

Comments
 (0)