Skip to content

Commit 2d9eb95

Browse files
committed
merge
2 parents 8fa02a8 + b4de313 commit 2d9eb95

Some content is hidden

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

50 files changed

+881
-462
lines changed

.travis.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
sudo: required
22
language: java
33
jdk: oraclejdk8
4-
script:
5-
- sh tron.sh
6-
- ./gradlew lint
7-
- ./gradlew test
84
addons:
95
ssh_known_hosts:
106
- 47.93.9.236:22008
7+
sonarcloud:
8+
organization: tron-zhaohong
9+
token:
10+
secure: "KXWEeQ1elAoQ0XfR54TQWfhrIdDP0+2CYPv2X9aWpU/YDl7hqZBAjcCOAUGvlbyM54jtG6YMaWwG48jlrOwwl5l/VjWSnUXF+7ixQy5ki0Ci9s7Y1pTQwV9SpL8TLIK2TYqabN8Mw+FJULASXLjYr9GerbbcUbCPTmcL6mQKw6ivxxpNPmz4eNoKAEuOzruO9fTXGAV3yr8Nn85c+mVxV8EUhkR17zpE9O8fvzOtSnYArWNOSCgDBn0EG45UNNPF2vn44s1c3h3gX1m3WK6PeCXPgy3hPqRn3wTG+xglnbqthGpo2wt1rJ83af+BwdYwvPEcUq84yLgXcE/aMkTKcVAfPWBP/6vblaoI90jxCeFji+MdMimKZAqIXt7oLqDZVmIq65de5YC5s7QTSbzJNY/tsAu3dqzSfbUJY6CRNFDcoenVpvgQkqb37TkDah4mJM8EUjbu2A9Q2HSFbyCVsQJtdasuu9cBOf6azK3U0XgFNBc0y2aziZrTnX30q7bi+5L/mbTnRdXrDqBOqyPeGtT77UZfcajHHmEWU/e6gYWiA/c+K25n13DD53Au6gpnnQ6ALeUl/1gDwz3fPBebJ5bVWrkIcLj7bbysjzfOvQmDS6G13RNz58Hm0/B7bVtZTr1E1q6Z1zEJwbuJYEJASNcezAfK5x/hIfZTGNqT3M8="
11+
cache:
12+
directories:
13+
- '$HOME/.sonar/cache'
14+
script:
15+
- sh tron.sh
16+
- "./gradlew build"
17+
- sonar-scanner
1118
skip_build:
1219
- README.md:
1320
- LICENSE
@@ -17,6 +24,5 @@ deploy:
1724
on:
1825
branch: develop
1926
after_deploy:
20-
- ./gradlew stest
21-
27+
- "./gradlew stest"
2228

build.gradle

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
buildscript {
2+
repositories {
3+
maven { url 'http://mvnrepository.com' }
4+
mavenCentral()
5+
jcenter()
6+
}
7+
dependencies {
8+
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
9+
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
10+
}
11+
}
12+
plugins {
13+
id "org.sonarqube" version "2.6"
14+
}
15+
116
group 'org.tron'
217
version '1.0.0'
318

@@ -8,7 +23,6 @@ apply plugin: 'checkstyle'
823
apply plugin: 'com.github.johnrengelman.shadow'
924
apply plugin: "jacoco"
1025

11-
1226
sourceCompatibility = 1.8
1327
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
1428
mainClassName = 'org.tron.program.FullNode'
@@ -18,19 +32,6 @@ repositories {
1832
mavenLocal()
1933
mavenCentral()
2034
}
21-
22-
buildscript {
23-
repositories {
24-
maven { url 'http://mvnrepository.com' }
25-
mavenCentral()
26-
jcenter()
27-
}
28-
dependencies {
29-
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
30-
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
31-
}
32-
}
33-
3435
def versions = [
3536
checkstyle: '8.7',
3637
]
@@ -143,17 +144,15 @@ checkstyle {
143144
}
144145

145146
checkstyleMain {
146-
source 'src'
147-
include '**/*.java'
148-
exclude '**/gen/**'
147+
source = 'src/main/java'
149148
}
150149

151150
task lint(type: Checkstyle) {
152151
// Cleaning the old log because of the creation of the new ones (not sure if totaly needed)
153152
delete fileTree(dir: "${project.rootDir}/app/build/reports")
154153
source 'src'
155154
include '**/*.java'
156-
exclude '**/gen/**'
155+
exclude 'main/gen/**'
157156
// empty classpath
158157
classpath = files()
159158
//Failing the build
@@ -186,6 +185,7 @@ protobuf {
186185
protoc {
187186
artifact = "com.google.protobuf:protoc:3.5.1-1"
188187
}
188+
189189
plugins {
190190
grpc {
191191
artifact = 'io.grpc:protoc-gen-grpc-java:1.9.0'
@@ -236,9 +236,9 @@ jacocoTestReport {
236236
}
237237
}
238238

239-
task stest(type:Test){
240-
useTestNG{
241-
suites( file('src/test/resources/testng.xml') )
239+
task stest(type: Test) {
240+
useTestNG {
241+
suites(file('src/test/resources/testng.xml'))
242242
}
243243

244244
testLogging {
@@ -247,7 +247,7 @@ task stest(type:Test){
247247
}
248248
}
249249

250-
def binaryRelease(taskName,jarName,mainClass) {
250+
def binaryRelease(taskName, jarName, mainClass) {
251251
return tasks.create("${taskName}", Jar) {
252252
baseName = jarName
253253
version = null
@@ -267,7 +267,8 @@ def binaryRelease(taskName,jarName,mainClass) {
267267
}
268268
}
269269

270+
270271
artifacts {
271-
archives(binaryRelease('buildSolidityNodeJar','SolidityNode','org.tron.program.SolidityNode'),
272-
binaryRelease('buildFullNodeJar','FullNode','org.tron.program.FullNode'))
272+
archives(binaryRelease('buildSolidityNodeJar', 'SolidityNode', 'org.tron.program.SolidityNode'),
273+
binaryRelease('buildFullNodeJar', 'FullNode', 'org.tron.program.FullNode'))
273274
}

sonar-project.properties

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
sonar.projectKey=java-tron
2+
sonar.projectName=java-tron
3+
sonar.projectVersion=2.1
4+
# =====================================================
5+
# Meta-data for the project
6+
# =====================================================
7+
sonar.links.homepage=https://github.com/tronprotocol/java-tron
8+
sonar.links.ci=https://travis-ci.org/tronprotocol/java-tron
9+
sonar.links.scm=https://github.com/tronprotocol/java-tron
10+
sonar.links.issue=https://github.com/tronprotocol/java-tron/issues
11+
# =====================================================
12+
# Properties that will be shared amongst all modules
13+
# =====================================================
14+
# SQ standard properties
15+
sonar.sources=src/main
16+
sonar.tests=src/test
17+
sonar.java.binaries=build/classes
18+
# =====================================================
19+
# Properties that will be shared amongst all modules

src/main/java/org/tron/common/storage/leveldb/LevelDbDataSourceImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ public class LevelDbDataSourceImpl implements DbSourceInter<byte[]>,
6060
* constructor.
6161
*/
6262
public LevelDbDataSourceImpl(String parentName, String name) {
63-
parentName += Args.getInstance().getStorage().getDirectory();
64-
this.parentName = parentName;
6563
this.dataBaseName = name;
64+
this.parentName = Paths.get(
65+
parentName,
66+
Args.getInstance().getStorage().getDbDirectory()
67+
).toString();
6668
}
6769

6870
@Override
@@ -79,7 +81,7 @@ public void initDB() {
7981
throw new NullPointerException("no name set to the dbStore");
8082
}
8183

82-
Options dbOptions = createDbOptions();
84+
Options dbOptions = Args.getInstance().getStorage().getOptionsByDbName(dataBaseName);
8385

8486
try {
8587
openDatabase(dbOptions);
@@ -109,6 +111,7 @@ private void openDatabase(Options dbOptions) throws IOException {
109111
}
110112
}
111113

114+
@Deprecated
112115
private Options createDbOptions() {
113116
Options dbOptions = new Options();
114117
dbOptions.createIfMissing(true);

src/main/java/org/tron/core/config/DefaultConfig.java

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -26,72 +26,6 @@ public DefaultConfig() {
2626
Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.error("Uncaught exception", e));
2727
}
2828

29-
@Bean(name = "witness")
30-
public String witness() {
31-
return "witness";
32-
}
33-
34-
@Bean(name = "account")
35-
public String account() {
36-
return "account";
37-
}
38-
39-
@Bean(name = "asset-issue")
40-
public String assetIssue() {
41-
return "asset-issue";
42-
}
43-
44-
@Bean(name = "block")
45-
public String block() {
46-
return "block";
47-
}
48-
49-
@Bean(name = "votes")
50-
public String votes() {
51-
return "votes";
52-
}
53-
54-
@Bean(name = "trans")
55-
public String trans() {
56-
return "trans";
57-
}
58-
59-
@Bean(name = "utxo")
60-
public String utxo() {
61-
return "utxo";
62-
}
63-
64-
@Bean(name = "properties")
65-
public String properties() {
66-
return "properties";
67-
}
68-
69-
@Bean(name = "block_KDB")
70-
public String blockKdb() {
71-
return "block_KDB";
72-
}
73-
74-
@Bean(name = "block-index")
75-
public String blockIndex() {
76-
return "block-index";
77-
}
78-
79-
@Bean(name = "account-index")
80-
public String accountIndex() {
81-
return "account-index";
82-
}
83-
84-
@Bean(name = "witness_schedule")
85-
public String witnessSchedule() {
86-
return "witness_schedule";
87-
}
88-
89-
@Bean(name = "recent-block")
90-
public String recentBlock() {
91-
return "recent-block";
92-
}
93-
94-
9529
@Bean
9630
public IndexHelper indexHelper() {
9731
if (!Args.getInstance().isSolidityNode()) {

src/main/java/org/tron/core/config/Parameter.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ interface ChainConstant {
1414
double SOLIDIFIED_THRESHOLD = 0.7;
1515
int PRIVATE_KEY_LENGTH = 64;
1616
int MAX_ACTIVE_WITNESS_NUM = 27;
17-
int TRXS_SIZE = 2_000_000; // < 2MiB
17+
//int TRXS_SIZE = 2_000_000; // < 2MiB
18+
int BLOCK_SIZE = 2_000_000;
1819
int BLOCK_PRODUCED_INTERVAL = 3000; //ms,produce block period, must be divisible by 60. millisecond
19-
long CLOCK_MAX_DELAY = 3600 * 1000; //ms
20+
long CLOCK_MAX_DELAY = 3600000; // 3600 * 1000 ms
2021
double BLOCK_PRODUCED_TIME_OUT = 0.75;
2122
long BATCH_FETCH_RESPONSE_SIZE = 1000; //for each inventory message from peer, the max count of fetch inv message
2223
long PRECISION = 1000_000;
2324
long ONE_DAY_NET_LIMIT = 57_600_000_000L;
24-
long WINDOW_SIZE_MS = 24 * 3600 * 1000;
25+
long WINDOW_SIZE_MS = 24 * 3600 * 1000L;
2526
long CREATE_NEW_ACCOUNT_COST = 10000;
2627
}
2728

@@ -37,6 +38,7 @@ interface NodeConstant {
3738
}
3839

3940
interface NetConstants {
41+
4042
long GRPC_IDLE_TIME_OUT = 60000L;
4143
long ADV_TIME_OUT = 20000L;
4244
long SYNC_TIME_OUT = 5000L;
@@ -50,6 +52,7 @@ interface NetConstants {
5052
}
5153

5254
interface DatabaseConstants {
55+
5356
int TRANSACTIONS_COUNT_LIMIT_MAX = 1000;
5457
}
5558
}

src/main/java/org/tron/core/config/args/Args.java

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import lombok.extern.slf4j.Slf4j;
2828
import org.apache.commons.collections4.CollectionUtils;
2929
import org.apache.commons.lang3.StringUtils;
30+
import org.iq80.leveldb.Options;
3031
import org.spongycastle.util.encoders.Hex;
3132
import org.springframework.stereotype.Component;
3233
import org.tron.common.crypto.ECKey;
@@ -65,8 +66,11 @@ public class Args {
6566
@Parameter(names = {"-p", "--private-key"}, description = "private-key")
6667
private String privateKey = "";
6768

68-
@Parameter(names = {"--storage-directory"}, description = "Storage directory")
69-
private String storageDirectory = "";
69+
@Parameter(names = {"--storage-db-directory"}, description = "Storage db directory")
70+
private String storageDbDirectory = "";
71+
72+
@Parameter(names = {"--storage-index-directory"}, description = "Storage index directory")
73+
private String storageIndexDirectory = "";
7074

7175
@Getter
7276
private Storage storage;
@@ -218,8 +222,16 @@ public static void clearParam() {
218222
INSTANCE.witness = false;
219223
INSTANCE.seedNodes = new ArrayList<>();
220224
INSTANCE.privateKey = "";
221-
INSTANCE.storageDirectory = "";
222-
INSTANCE.storage = null;
225+
INSTANCE.storageDbDirectory = "";
226+
INSTANCE.storageIndexDirectory = "";
227+
228+
// FIXME: INSTANCE.storage maybe null ?
229+
if (INSTANCE.storage != null) {
230+
// WARNING: WILL DELETE DB STORAGE PATHS
231+
INSTANCE.storage.deleteAllStoragePaths();
232+
INSTANCE.storage = null;
233+
}
234+
223235
INSTANCE.overlay = null;
224236
INSTANCE.seedNode = null;
225237
INSTANCE.genesisBlock = null;
@@ -253,6 +265,7 @@ public static void clearParam() {
253265
INSTANCE.getTransactionsToThisCountFeature = false;
254266
INSTANCE.getTransactionsByTimestampFeature = false;
255267
INSTANCE.getTransactionsByTimestampCountFeature = false;
268+
256269
}
257270

258271
/**
@@ -281,9 +294,16 @@ public static void setParam(final String[] args, final String confFileName) {
281294
}
282295

283296
INSTANCE.storage = new Storage();
284-
INSTANCE.storage.setDirectory(Optional.ofNullable(INSTANCE.storageDirectory)
297+
INSTANCE.storage.setDbDirectory(Optional.ofNullable(INSTANCE.storageDbDirectory)
285298
.filter(StringUtils::isNotEmpty)
286-
.orElse(config.getString("storage.directory")));
299+
.orElse(config.getString("storage.db.directory")));
300+
301+
INSTANCE.storage.setIndexDirectory(Optional.ofNullable(INSTANCE.storageIndexDirectory)
302+
.filter(StringUtils::isNotEmpty)
303+
.orElse(config.getString("storage.index.directory")));
304+
305+
INSTANCE.storage.setPropertyMapFromConfig(config);
306+
287307
INSTANCE.seedNode = new SeedNode();
288308
INSTANCE.seedNode.setIpList(Optional.ofNullable(INSTANCE.seedNodes)
289309
.filter(seedNode -> 0 != seedNode.size())
@@ -436,6 +456,20 @@ public static Args getInstance() {
436456
return INSTANCE;
437457
}
438458

459+
/**
460+
* Get storage path by name of database
461+
*
462+
* @param dbName name of database
463+
* @return path of that database
464+
*/
465+
public String getOutputDirectoryByDbName(String dbName) {
466+
String path = storage.getPathByDbName(dbName);
467+
if (!StringUtils.isBlank(path)) {
468+
return path;
469+
}
470+
return getOutputDirectory();
471+
}
472+
439473
/**
440474
* get output directory.
441475
*/
@@ -475,7 +509,7 @@ private static String getGeneratedNodePrivateKey() {
475509
String nodeId;
476510
try {
477511
File file = new File(
478-
INSTANCE.outputDirectory + File.separator + INSTANCE.storage.getDirectory(),
512+
INSTANCE.outputDirectory + File.separator + INSTANCE.storage.getDbDirectory(),
479513
"nodeId.properties");
480514
Properties props = new Properties();
481515
if (file.canRead()) {

0 commit comments

Comments
 (0)