diff --git a/src/main/java/org/bdware/sc/ContractStatusRecorder.java b/src/main/java/org/bdware/sc/ContractStatusRecorder.java index ca33431..3a595f2 100644 --- a/src/main/java/org/bdware/sc/ContractStatusRecorder.java +++ b/src/main/java/org/bdware/sc/ContractStatusRecorder.java @@ -8,7 +8,6 @@ import org.bdware.sc.bean.Contract; import org.bdware.sc.bean.ContractRequest; import org.bdware.sc.db.CMTables; import org.bdware.sc.db.StatusRecorder; -import org.bdware.sc.units.MultiContractMeta; import org.bdware.sc.util.JsonUtil; import org.bdware.sc.util.LRUList; @@ -148,6 +147,7 @@ public class ContractStatusRecorder extends StatusRecorder { id2ContractClient.put(meta.id, client); runningProcess.add(meta); } + public ContractMeta createIfNotExist(String contractID) { ContractMeta ret = getContractMeta(contractID); if (null == ret) { @@ -199,7 +199,9 @@ public class ContractStatusRecorder extends StatusRecorder { public String killContract(String idOrName) { ContractMeta meta = getContractMeta(idOrName); - if (meta != null) return killContract(meta); + if (null != meta) { + return killContract(meta); + } return "no such contract " + idOrName; } @@ -227,6 +229,7 @@ public class ContractStatusRecorder extends StatusRecorder { ContractManager.instance.invokeContractSuicide(client); ContractManager.cPort.updateDb(client.port, false); } + meta.contractExecutor.close(); id2ContractClient.remove(meta.id); runningProcess.remove(meta); return "success"; diff --git a/src/main/java/org/bdware/sc/units/MultiContractMeta.java b/src/main/java/org/bdware/sc/units/MultiContractMeta.java index e673895..3198432 100644 --- a/src/main/java/org/bdware/sc/units/MultiContractMeta.java +++ b/src/main/java/org/bdware/sc/units/MultiContractMeta.java @@ -11,7 +11,6 @@ import org.bdware.sc.db.CMTables; import org.bdware.sc.db.KeyValueDBUtil; import org.bdware.sc.redo.TransRecord; import org.bdware.sc.util.JsonUtil; -import org.bdware.server.trustedmodel.ContractExecutor; import org.bdware.server.trustedmodel.ContractUnitStatus; import java.util.Map; diff --git a/src/main/java/org/bdware/server/trustedmodel/ContractExecutor.java b/src/main/java/org/bdware/server/trustedmodel/ContractExecutor.java index b976816..9f3e8d4 100644 --- a/src/main/java/org/bdware/server/trustedmodel/ContractExecutor.java +++ b/src/main/java/org/bdware/server/trustedmodel/ContractExecutor.java @@ -8,6 +8,8 @@ import org.bdware.sc.conn.ResultCallback; public interface ContractExecutor { void execute(String requestID, ContractRequest req, ResultCallback rcb, OnHashCallback hcb); + default void close() { + } default void onSyncMessage(Node node, byte[] data) { }