Skip to content

Commit 1ff0d9c

Browse files
committed
fix
2 parents a58558a + a84aa0f commit 1ff0d9c

250 files changed

Lines changed: 11209 additions & 10571 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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "2"
2+
plugins:
3+
sonar-java:
4+
enabled: true
5+
config:
6+
sonar.java.source: 8

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ language: java
33
jdk: oraclejdk8
44

55
script:
6+
- ./gradlew lint
67
- ./gradlew test

build.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version '1.0.0'
44
apply plugin: 'java'
55
apply plugin: 'com.google.protobuf'
66
apply plugin: 'application'
7+
apply plugin: 'checkstyle'
78

89
sourceCompatibility = 1.8
910
mainClassName = 'org.tron.example.Tron'
@@ -21,6 +22,19 @@ buildscript {
2122
}
2223
}
2324

25+
def versions = [
26+
checkstyle: '8.7',
27+
]
28+
29+
configurations {
30+
checkstyleConfig
31+
32+
}
33+
34+
configurations.getByName('checkstyleConfig') {
35+
transitive = false
36+
}
37+
2438
dependencies {
2539
testCompile group: 'junit', name: 'junit', version: '4.12'
2640
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.5'
@@ -86,8 +100,30 @@ dependencies {
86100
compile group: 'org.apache.commons', name: 'commons-math', version: '2.2'
87101

88102
compile group: 'io.dropwizard.metrics', name: 'metrics-core', version: '3.1.2'
103+
104+
checkstyleConfig "com.puppycrawl.tools:checkstyle:${versions.checkstyle}"
105+
106+
}
107+
108+
task lint(type: Checkstyle) {
109+
// Cleaning the old log because of the creation of the new ones (not sure if totaly needed)
110+
delete fileTree(dir: "${project.rootDir}/app/build/reports")
111+
source 'src'
112+
include '**/*.java'
113+
exclude '**/gen/**'
114+
// empty classpath
115+
classpath = files()
116+
//Failing the build
117+
ignoreFailures = false
89118
}
90119

120+
checkstyle {
121+
toolVersion = "${versions.checkstyle}"
122+
config = resources.text.fromArchiveEntry(configurations.checkstyleConfig, 'google_checks.xml')
123+
}
124+
125+
126+
91127
tasks.matching { it instanceof Test }.all {
92128
testLogging.events = ["failed", "passed", "skipped"]
93129
}

gradle/wrapper/gradle-wrapper.jar

-61 Bytes
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Sat Jan 06 16:37:04 CST 2018
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
43
zipStoreBase=GRADLE_USER_HOME
54
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-rc-2-bin.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip

gradlew

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,30 @@
66

77
public class Application {
88

9-
private Injector injector;
10-
private ServiceContainer services;
11-
12-
private static final Logger logger = LoggerFactory.getLogger("Application");
13-
14-
public Application(Injector injector) {
15-
this.injector = injector;
16-
this.services = new ServiceContainer();
17-
}
18-
19-
public Injector getInjector() {
20-
return injector;
21-
}
22-
23-
public void addService(Service service) {
24-
this.services.add(service);
25-
}
26-
27-
public void run() {
28-
this.services.start();
29-
}
30-
31-
public void shutdown() {
32-
logger.info("shutting down");
33-
this.services.stop();
34-
System.exit(0);
35-
}
9+
private static final Logger logger = LoggerFactory.getLogger("Application");
10+
private Injector injector;
11+
private ServiceContainer services;
12+
13+
public Application(Injector injector) {
14+
this.injector = injector;
15+
this.services = new ServiceContainer();
16+
}
17+
18+
public Injector getInjector() {
19+
return injector;
20+
}
21+
22+
public void addService(Service service) {
23+
this.services.add(service);
24+
}
25+
26+
public void run() {
27+
this.services.start();
28+
}
29+
30+
public void shutdown() {
31+
logger.info("shutting down");
32+
this.services.stop();
33+
System.exit(0);
34+
}
3635
}

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55

66
public class ApplicationFactory {
77

8-
/**
9-
* Build a Guice instance
10-
*
11-
* @return Guice
12-
*/
13-
public Injector buildGuice() {
14-
return Guice.createInjector(
15-
new Module());
16-
}
8+
/**
9+
* Build a Guice instance
10+
*
11+
* @return Guice
12+
*/
13+
public Injector buildGuice() {
14+
return Guice.createInjector(
15+
new Module());
16+
}
1717

18-
/**
19-
* Build a new application
20-
*
21-
* @return
22-
*/
23-
public Application build() {
24-
return new Application(buildGuice());
25-
}
18+
/**
19+
* Build a new application
20+
*
21+
* @return
22+
*/
23+
public Application build() {
24+
return new Application(buildGuice());
25+
}
2626

27-
/**
28-
* Build a new cli application
29-
*
30-
* @return
31-
*/
32-
public CliApplication buildCli() {
33-
return new CliApplication(buildGuice());
34-
}
27+
/**
28+
* Build a new cli application
29+
*
30+
* @return
31+
*/
32+
public CliApplication buildCli() {
33+
return new CliApplication(buildGuice());
34+
}
3535
}

src/main/java/org/tron/application/CliApplication.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
public class CliApplication extends Application {
77

8-
private Peer peer;
8+
private Peer peer;
99

10-
public CliApplication(Injector injector) {
11-
super(injector);
12-
}
10+
public CliApplication(Injector injector) {
11+
super(injector);
12+
}
1313

14-
public Peer getPeer() {
15-
return peer;
16-
}
14+
public Peer getPeer() {
15+
return peer;
16+
}
1717

18-
public void setPeer(Peer peer) {
19-
this.peer = peer;
20-
}
18+
public void setPeer(Peer peer) {
19+
this.peer = peer;
20+
}
2121
}
Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,58 @@
11
package org.tron.application;
22

3+
import static org.tron.core.Constant.BLOCK_DB_NAME;
4+
import static org.tron.core.Constant.TRANSACTION_DB_NAME;
5+
36
import com.google.inject.AbstractModule;
47
import com.google.inject.Provides;
58
import com.google.inject.Singleton;
9+
import javax.inject.Named;
610
import org.tron.consensus.client.Client;
711
import org.tron.consensus.server.Server;
12+
import org.tron.core.Blockchain;
813
import org.tron.core.Constant;
914
import org.tron.storage.leveldb.LevelDbDataSourceImpl;
1015

11-
import javax.inject.Named;
12-
13-
import static org.tron.core.Constant.BLOCK_DB_NAME;
14-
import static org.tron.core.Constant.TRANSACTION_DB_NAME;
15-
1616
public class Module extends AbstractModule {
1717

18-
@Override
19-
protected void configure() {
20-
21-
}
22-
23-
@Provides
24-
@Singleton
25-
public Client buildClient() {
26-
return new Client();
27-
}
28-
29-
@Provides
30-
@Singleton
31-
public Server buildServer() {
32-
return new Server();
33-
}
34-
35-
@Provides
36-
@Singleton
37-
@Named("transaction")
38-
public LevelDbDataSourceImpl buildTransactionDb() {
39-
LevelDbDataSourceImpl db = new LevelDbDataSourceImpl(Constant.NORMAL,TRANSACTION_DB_NAME);
40-
db.initDB();
41-
return db;
42-
}
43-
44-
@Provides
45-
@Singleton
46-
@Named("block")
47-
public LevelDbDataSourceImpl buildBlockDb() {
48-
LevelDbDataSourceImpl db = new LevelDbDataSourceImpl(Constant.NORMAL,BLOCK_DB_NAME);
49-
db.initDB();
50-
return db;
51-
}
18+
@Override
19+
protected void configure() {
20+
21+
}
22+
23+
@Provides
24+
@Singleton
25+
public Client buildClient() {
26+
return new Client();
27+
}
28+
29+
@Provides
30+
@Singleton
31+
public Server buildServer() {
32+
return new Server();
33+
}
34+
35+
@Provides
36+
@Singleton
37+
@Named("transaction")
38+
public LevelDbDataSourceImpl buildTransactionDb() {
39+
LevelDbDataSourceImpl db = new LevelDbDataSourceImpl(Constant.NORMAL, TRANSACTION_DB_NAME);
40+
db.initDB();
41+
return db;
42+
}
43+
44+
@Provides
45+
@Singleton
46+
@Named("block")
47+
public LevelDbDataSourceImpl buildBlockDb() {
48+
LevelDbDataSourceImpl db = new LevelDbDataSourceImpl(Constant.NORMAL, BLOCK_DB_NAME);
49+
db.initDB();
50+
return db;
51+
}
52+
53+
@Provides
54+
@Singleton
55+
public Blockchain buildBlockchain(@Named("block") LevelDbDataSourceImpl blockDB) {
56+
return new Blockchain(blockDB);
57+
}
5258
}

0 commit comments

Comments
 (0)