fix: rocksdb null

This commit is contained in:
CaiHQ 2021-11-12 17:59:11 +08:00
parent 6673cedf0f
commit dff61f8246
2 changed files with 8 additions and 1 deletions

View File

@ -168,6 +168,12 @@ public class ContractProcess {
return res;
}
public static String getContractDir() {
if (instance!=null && instance.cn!=null && instance.cn.getContractName()!=null)
return instance.cn.getContractName();
return "debug";
}
public String getContractName() {
return cn.getContractName();
}

View File

@ -30,7 +30,8 @@ public class RocksDBUtil {
this.path = path;
Options options = new Options();
options.setCreateIfMissing(true);
File parent = new File("./ContractDB/" + ContractProcess.instance.getContractName());
File parent = new File("./ContractDB/" + ContractProcess.getContractDir());
File dir = new File(parent, path);
if (!dir.exists()) dir.mkdirs();
File lockFile = new File(dir, "LOCK");