From dff61f8246f1f200c85eb76a0b24ba72cce08264 Mon Sep 17 00:00:00 2001 From: CaiHQ Date: Fri, 12 Nov 2021 17:59:11 +0800 Subject: [PATCH] fix: rocksdb null --- src/main/java/org/bdware/sc/ContractProcess.java | 6 ++++++ src/main/java/org/bdware/sc/boundry/utils/RocksDBUtil.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bdware/sc/ContractProcess.java b/src/main/java/org/bdware/sc/ContractProcess.java index ee160e5..a28c86b 100644 --- a/src/main/java/org/bdware/sc/ContractProcess.java +++ b/src/main/java/org/bdware/sc/ContractProcess.java @@ -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(); } diff --git a/src/main/java/org/bdware/sc/boundry/utils/RocksDBUtil.java b/src/main/java/org/bdware/sc/boundry/utils/RocksDBUtil.java index 73d7300..b79b71d 100644 --- a/src/main/java/org/bdware/sc/boundry/utils/RocksDBUtil.java +++ b/src/main/java/org/bdware/sc/boundry/utils/RocksDBUtil.java @@ -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");