Skip to content

Commit e619b49

Browse files
seanrobbinssasaxie
authored andcommitted
Remove dbExists logic, as now rely on the Dependency Injection for BlockDB
1 parent 30519c5 commit e619b49

2 files changed

Lines changed: 3 additions & 48 deletions

File tree

src/main/java/org/tron/core/Blockchain.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,6 @@ public Blockchain(LevelDbDataSourceImpl blockDB, String address, String type) {
124124
}
125125
}
126126

127-
/**
128-
* create blockchain by db source
129-
*/
130-
@Inject
131-
public Blockchain(@Named("block") LevelDbDataSourceImpl blockDb) {
132-
if (!dbExists()) {
133-
logger.info("no existing blockchain found. please create one first");
134-
throw new IllegalStateException("No existing blockchain found. please create one first");
135-
}
136-
137-
blockDB = blockDb;
138-
139-
this.lastHash = blockDB.getData(LAST_HASH);
140-
this.currentHash = this.lastHash;
141-
142-
logger.info("load blockchain");
143-
}
144-
145127
/**
146128
* find transaction by id
147129
*
@@ -229,23 +211,6 @@ public HashMap<String, TXOutputs> findUTXO() {
229211
return utxo;
230212
}
231213

232-
/**
233-
* Checks if the database file exists
234-
*
235-
* @return boolean
236-
*/
237-
public static boolean dbExists() {
238-
if (Constant.NORMAL==parentName){
239-
parentName= Configer.getConf(Constant.NORMAL_CONF).getString(Constant.DATABASE_DIR);
240-
}else {
241-
parentName=Configer.getConf(Constant.TEST_CONF).getString(Constant.DATABASE_DIR);
242-
243-
}
244-
File file = new File(Paths.get(parentName, BLOCK_DB_NAME).toString());
245-
return file.exists();
246-
}
247-
248-
249214
/**
250215
* add a block into database
251216
*

src/test/java/org/tron/core/BlockchainTest.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414
*/
1515
package org.tron.core;
1616

17-
import com.alibaba.fastjson.JSON;
18-
import com.google.common.io.ByteStreams;
1917
import com.google.protobuf.ByteString;
2018
import com.google.protobuf.InvalidProtocolBufferException;
21-
import org.junit.AfterClass;
2219
import org.junit.Before;
23-
import org.junit.BeforeClass;
2420
import org.junit.Test;
2521
import org.mockito.Mockito;
2622
import org.slf4j.Logger;
@@ -33,13 +29,12 @@
3329
import org.tron.wallet.Wallet;
3430

3531
import java.io.IOException;
36-
import java.io.InputStream;
37-
import java.util.*;
32+
import java.util.ArrayList;
33+
import java.util.HashMap;
34+
import java.util.List;
3835

3936
import static org.mockito.Matchers.any;
4037
import static org.mockito.Matchers.eq;
41-
import static org.tron.core.Blockchain.GENESIS_COINBASE_DATA;
42-
import static org.tron.core.Blockchain.dbExists;
4338
import static org.tron.core.Constant.LAST_HASH;
4439
import static org.tron.utils.ByteArray.toHexString;
4540

@@ -107,11 +102,6 @@ public void testFindTransaction() {
107102
logger.info("{}", TransactionUtils.toPrintString(transaction));
108103
}
109104

110-
@Test
111-
public void testDBExists() {
112-
logger.info("test dbStore exists: {}", dbExists());
113-
}
114-
115105
@Test
116106
public void testFindUTXO() {
117107
long testAmount = 10;

0 commit comments

Comments
 (0)