Skip to content

Commit 0dd6259

Browse files
committed
feat(db): remove rocksDB compatibility with LevelDB
for later updating RocksDB
1 parent e5b83a2 commit 0dd6259

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

chainbase/src/main/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,12 @@ public void setDBName(String name) {
196196
public boolean checkOrInitEngine() {
197197
String dir = getDbPath().toString();
198198
String enginePath = dir + File.separator + "engine.properties";
199-
199+
File currentFile = new File(dir, "CURRENT");
200+
if (currentFile.exists() && !Paths.get(enginePath).toFile().exists()) {
201+
// if the CURRENT file exists, but the engine.properties file does not exist, it is LevelDB
202+
logger.error(" You are trying to open a LevelDB database with RocksDB engine.");
203+
return false;
204+
}
200205
if (FileUtil.createDirIfNotExists(dir)) {
201206
if (!FileUtil.createFileIfNotExists(enginePath)) {
202207
return false;

plugins/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ DB convert provides a helper which can convert LevelDB data to RocksDB data, par
3434

3535
- `<src>`: Input path for leveldb, default: output-directory/database.
3636
- `<dest>`: Output path for rocksdb, default: output-directory-dst/database.
37-
- `--safe`: In safe mode, read data from leveldb then put into rocksdb, it's a very time-consuming procedure. If not, just change engine.properties from leveldb to rocksdb, rocksdb
38-
is compatible with leveldb for the current version. This may not be the case in the future, default: false.
3937
- `-h | --help`: Provide the help info.
4038

4139
### Examples:
4240

4341
```shell script
4442
# full command
45-
java -jar Toolkit.jar db convert [-h] [--safe] <src> <dest>
43+
java -jar Toolkit.jar db convert [-h] <src> <dest>
4644
# examples
4745
java -jar Toolkit.jar db convert output-directory/database /tmp/database
4846
```

plugins/src/main/java/org/tron/plugins/DbConvert.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,7 @@ public class DbConvert implements Callable<Integer> {
4949
description = "Output path for rocksdb. Default: ${DEFAULT-VALUE}")
5050
private File dest;
5151

52-
@CommandLine.Option(names = {"--safe"},
53-
description = "In safe mode, read data from leveldb then put rocksdb."
54-
+ "If not, just change engine.properties from leveldb to rocksdb,"
55-
+ "rocksdb is compatible with leveldb for current version."
56-
+ "This may not be the case in the future."
57-
+ "Default: ${DEFAULT-VALUE}")
58-
private boolean safe;
52+
private final boolean safe = true;
5953

6054
@CommandLine.Option(names = {"-h", "--help"})
6155
private boolean help;

plugins/src/test/java/org/tron/plugins/DbConvertTest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ public void testRun() throws IOException {
1515
Assert.assertEquals(0, cli.execute(args));
1616
}
1717

18-
@Test
19-
public void testRunWithSafe() throws IOException {
20-
String[] args = new String[] { "db", "convert", INPUT_DIRECTORY,
21-
temporaryFolder.newFolder().toString(),"--safe" };
22-
Assert.assertEquals(0, cli.execute(args));
23-
}
24-
2518
@Test
2619
public void testHelp() {
2720
String[] args = new String[] {"db", "convert", "-h"};

0 commit comments

Comments
 (0)