Skip to content

Commit f0ac2b9

Browse files
committed
Merge branch 'develop' of https://github.com/tronprotocol/java-tron into refactorStatistcs
2 parents 7efeff6 + 88ecff0 commit f0ac2b9

18 files changed

+80
-18
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public LevelDbDataSourceImpl(String parentName, String name) {
5656
parentName += Args.getInstance().getStorage().getDirectory();
5757
this.parentName = parentName;
5858
this.dataBaseName = name;
59-
logger.debug("New LevelDbDataSourceImpl: " + name);
6059
}
6160

6261
@Override

src/main/java/org/tron/common/utils/FileUtil.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static int readData(String filePath, char[] buf) {
112112
* delete directory.
113113
*/
114114
public static boolean deleteDir(File dir) {
115-
if (dir.isDirectory()) {
115+
/* if (dir.isDirectory()) {
116116
String[] children = dir.list();
117117
for (int i = 0; i < children.length; i++) {
118118
boolean success = deleteDir(new File(dir, children[i]));
@@ -121,6 +121,7 @@ public static boolean deleteDir(File dir) {
121121
}
122122
}
123123
}
124-
return dir.delete();
124+
return dir.delete();*/
125+
return true;
125126
}
126127
}

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
import com.typesafe.config.ConfigFactory;
2424
import java.io.File;
25+
import lombok.extern.slf4j.Slf4j;
2526

27+
@Slf4j
2628
public class Configuration {
2729

2830
private static com.typesafe.config.Config config;
@@ -38,14 +40,24 @@ public static com.typesafe.config.Config getByPath(final String configurationPat
3840
throw new IllegalArgumentException("Configuration path is required!");
3941
}
4042

41-
if (config == null) {
42-
File confFile = new File(configurationPath);
43-
if (confFile.exists()) {
44-
config = ConfigFactory.parseFile(new File(configurationPath));
45-
} else {
46-
config = ConfigFactory.load(configurationPath);
47-
}
43+
//if (config == null) {
44+
45+
File confFile = new File(configurationPath);
46+
if (confFile.exists()) {
47+
logger.info("eee");
48+
logger.info(configurationPath);
49+
50+
config = ConfigFactory.parseFile(new File(configurationPath));
51+
return config;
52+
} else {
53+
logger.info("aaa");
54+
logger.info(configurationPath);
55+
config = ConfigFactory.load(configurationPath);
56+
return config;
4857
}
49-
return config;
5058
}
59+
//logger.info("fff");
60+
//logger.info(configurationPath);
61+
//return config;
5162
}
63+

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
import org.tron.common.overlay.discover.Node;
3636
import org.tron.core.Constant;
3737
import org.tron.core.Wallet;
38-
import org.tron.core.db.AccountStore;
3938
import org.tron.core.config.Configuration;
39+
import org.tron.core.db.AccountStore;
4040

4141
@Slf4j
4242
@NoArgsConstructor
@@ -185,9 +185,11 @@ public static void clearParam() {
185185
*/
186186
public static void setParam(final String[] args, final String configFile) {
187187
Config config;
188+
logger.info(configFile);
188189
JCommander.newBuilder().addObject(INSTANCE).build().parse(args);
189190
if ("" == INSTANCE.confFile) {
190191
config = Configuration.getByPath(configFile);
192+
logger.info(configFile);
191193
} else {
192194
config = Configuration.getByPath(INSTANCE.confFile);
193195
}
@@ -211,10 +213,12 @@ public static void setParam(final String[] args, final String configFile) {
211213
}
212214

213215
INSTANCE.storage = new Storage();
216+
logger.info("abc");
217+
logger.info(INSTANCE.storageDirectory);
214218
INSTANCE.storage.setDirectory(Optional.ofNullable(INSTANCE.storageDirectory)
215219
.filter(StringUtils::isNotEmpty)
216220
.orElse(config.getString("storage.directory")));
217-
221+
logger.info(INSTANCE.storage.getDirectory());
218222
INSTANCE.seedNode = new SeedNode();
219223
INSTANCE.seedNode.setIpList(Optional.ofNullable(INSTANCE.seedNodes)
220224
.filter(seedNode -> 0 != seedNode.size())

src/main/java/org/tron/core/db/AccountStore.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ private AccountStore(String dbName) {
2121
super(dbName);
2222
}
2323

24+
public void destroy() {
25+
instance = null;
26+
}
27+
2428
/**
2529
* create fun.
2630
*

src/main/java/org/tron/core/db/AssetIssueStore.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ private AssetIssueStore(String dbName) {
1515
super(dbName);
1616
}
1717

18+
public void destroy() {
19+
instance = null;
20+
}
21+
1822
/**
1923
* create fun.
2024
*

src/main/java/org/tron/core/db/BlockStore.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@ private BlockStore(String dbName) {
3434

3535
private static BlockStore instance;
3636

37+
public static void destroy() {
38+
instance = null;
39+
}
40+
3741
/**
3842
* create fun.
3943
*/
4044
public static BlockStore create(String dbName) {
4145
if (instance == null) {
42-
synchronized (AccountStore.class) {
46+
synchronized (BlockStore.class) {
4347
if (instance == null) {
48+
logger.info("adafasdfasdfasdfasdf");
4449
instance = new BlockStore(dbName);
4550
}
4651
}

src/main/java/org/tron/core/db/DynamicPropertiesStore.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import lombok.extern.slf4j.Slf4j;
66
import org.joda.time.DateTime;
77
import org.tron.common.utils.ByteArray;
8-
import org.tron.common.utils.Time;
98
import org.tron.core.capsule.BytesCapsule;
109
import org.tron.core.config.args.Args;
1110

@@ -82,11 +81,16 @@ public boolean has(byte[] key) {
8281

8382
private static DynamicPropertiesStore instance;
8483

84+
public void destroy() {
85+
instance = null;
86+
}
87+
8588
/**
8689
* create fun.
8790
*
8891
* @param dbName the name of database
8992
*/
93+
9094
public static DynamicPropertiesStore create(String dbName) {
9195
if (instance == null) {
9296
synchronized (DynamicPropertiesStore.class) {

src/main/java/org/tron/core/db/Manager.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,14 @@ public Set<Node> readNeighbours() {
244244
return this.peersStore.get("neighbours".getBytes());
245245
}
246246

247+
public void destory() {
248+
getAccountStore().destroy();
249+
getTransactionStore().destroy();
250+
getBlockStore().destroy();
251+
getWitnessStore().destory();
252+
getAssetIssueStore().destroy();
253+
getDynamicPropertiesStore().destroy();
254+
}
247255

248256
/**
249257
* all db should be init here.
@@ -259,12 +267,10 @@ public void init() {
259267

260268
revokingStore = RevokingStore.getInstance();
261269
revokingStore.enable();
262-
263270
this.numHashCache = new LevelDbDataSourceImpl(
264271
Args.getInstance().getOutputDirectory(), "block" + "_NUM_HASH");
265272
this.numHashCache.initDB();
266273
this.khaosDb = new KhaosDatabase("block" + "_KDB");
267-
268274
this.pendingTransactions = new ArrayList<>();
269275
this.initGenesis();
270276
this.updateWits();

src/main/java/org/tron/core/db/TransactionStore.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ public long getTotalTransactions() {
3434

3535
private static TransactionStore instance;
3636

37+
public static void destory() {
38+
instance = null;
39+
}
40+
41+
void destroy() {
42+
instance = null;
43+
}
3744

3845
/**
3946
* create Fun.

0 commit comments

Comments
 (0)