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; 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() { public String getContractName() {
return cn.getContractName(); return cn.getContractName();
} }

View File

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