From 630bb2eb7e4e63841083759e2255630bac9798f8 Mon Sep 17 00:00:00 2001 From: CaiHQ Date: Fri, 31 Mar 2023 17:10:06 +0800 Subject: [PATCH] add support for doipPort --- .../java/org/bdware/sc/ContractClient.java | 38 ------------------- .../java/org/bdware/sc/ContractManager.java | 31 +-------------- .../org/bdware/sc/ContractStatusRecorder.java | 6 +-- 3 files changed, 5 insertions(+), 70 deletions(-) diff --git a/src/main/java/org/bdware/sc/ContractClient.java b/src/main/java/org/bdware/sc/ContractClient.java index b938bee..a105b50 100644 --- a/src/main/java/org/bdware/sc/ContractClient.java +++ b/src/main/java/org/bdware/sc/ContractClient.java @@ -269,31 +269,6 @@ public class ContractClient { pbParameters.toArray(result); Constructor pbc = ProcessBuilder.class.getDeclaredConstructor(String[].class); builder = pbc.newInstance(new Object[]{result}); - -// if (remoteDebug.length() == 0) -// builder = -// new ProcessBuilder( -// "java", -// "-Dfile.encoding=UTF-8", -// darg, -// "-jar", -// classpath, -// "-port=" + startPort, -// "-cmi=" + cmi, // cmi 区分不同CM的cp -// (isDebug ? "-debug" : "")); -// else -// builder = -// -// new ProcessBuilder( -// "java", -// "-Dfile.encoding=UTF-8", -// darg, remoteDebug, -// "-jar", -// classpath, -// "-port=" + startPort, -// "-cmi=" + cmi, // cmi 区分不同CM的cp -// (isDebug ? "-debug" : "")); - File directory = new File("./"); LOGGER.debug("[CMD] path: " + directory.getAbsolutePath()); LOGGER.debug(JsonUtil.toPrettyJson(builder.command())); @@ -415,19 +390,10 @@ public class ContractClient { return contractMeta.getExportedFunctions(); } - public String getIdentifier() { - return get.syncGet("", "getIdentifier", " "); - } - public String executeMethod(String pkgName, String method, String arg) { return get.syncGet(pkgName, method, arg); } - public void setIdentifier(String alias) { - get.asyncGet("", "setIdentifier", alias, null); - } - - public String getPubkey() { return contractMeta.contract.getPublicKey(); } @@ -440,10 +406,6 @@ public class ContractClient { return contractMeta.name; } - public String getContractDOI() { - return contractMeta.contract.getDOI(); - } - public String getContractKey() { return contractMeta.contract.getKey(); } diff --git a/src/main/java/org/bdware/sc/ContractManager.java b/src/main/java/org/bdware/sc/ContractManager.java index e4dcaba..04c8a56 100644 --- a/src/main/java/org/bdware/sc/ContractManager.java +++ b/src/main/java/org/bdware/sc/ContractManager.java @@ -786,7 +786,7 @@ public class ContractManager { addLocalContractLog(action, meta.contract.getID(), meta.name, meta.contract.getOwner()); } - public String startContractAndRedirect(Contract c, PrintStream ps, String alias) { + public String startContractAndRedirect(Contract c, PrintStream ps) { long freeMemory = getFreeMemory(); if (statusRecorder.runningProcess.size() > 5 && (freeMemory < memoryLimit)) { statusRecorder.hangLeastUsedContractProcess(); @@ -817,7 +817,6 @@ public class ContractManager { LOGGER.debug("contract pubKey: " + c.getPublicKey()); // 合约启动时读取Manifest文件设置合约DOI - setContractDOI(c); setContractStateful(c); ContractClient client = new ContractClient(c); String ret; @@ -856,14 +855,6 @@ public class ContractManager { client.traffic += ret.length(); // TODO @ZYX // updateContractInfo(client); - - if (alias != null) { - client.setIdentifier(alias); - } - if (c.getDoipFlag() && !c.getDOI().equals("registerFailed")) { - client.setIdentifier(c.getDOI()); - } - // if (BDOAHandler.cm != null) { // BDOAHandler.cm.name2Contract = name2Contract; // } @@ -982,24 +973,6 @@ public class ContractManager { } return null; } - - private void setContractDOI(Contract c) { - //@TODO add Automatically register a doi instead. - ContractManifest cm = YJSPacker.getManifest(c.getScriptStr()); - if (cm != null && cm.doi != null) { - if (!cm.doi.equals("") - && !cm.doi.equals("null") - && c.getType() == ContractExecType.Sole && chainOpener != null) { - c.setDOI(cm.doi); - c.setBuildTime(cm.buildTime); - c.setDoipFlag(true); - chainOpener.reRegister(cm.doi); - } - } else { - c.setDoipFlag(false); - } - } - private void setContractStateful(Contract c) { ContractManifest cm = YJSPacker.getManifest(c.getScriptStr()); if (cm != null && cm.stateful != null && cm.stateful.equals("false")) { @@ -1008,7 +981,7 @@ public class ContractManager { } public String startContract(Contract c) { - return startContractAndRedirect(c, System.out, null); + return startContractAndRedirect(c, System.out); } public String queryDEPort(String contractID) { diff --git a/src/main/java/org/bdware/sc/ContractStatusRecorder.java b/src/main/java/org/bdware/sc/ContractStatusRecorder.java index 40ae144..f80aee9 100644 --- a/src/main/java/org/bdware/sc/ContractStatusRecorder.java +++ b/src/main/java/org/bdware/sc/ContractStatusRecorder.java @@ -95,7 +95,7 @@ public class ContractStatusRecorder extends StatusRecorder { } private static String resumeStartContract(Contract contract) { - return ContractManager.instance.startContractAndRedirect(contract, null, null); + return ContractManager.instance.startContractAndRedirect(contract, null); } public boolean hasPID(int pid) { @@ -179,14 +179,14 @@ public class ContractStatusRecorder extends StatusRecorder { if (meta != null) return meta; for (ContractMeta cc : getStatus().values()) { if (cc.status == ContractStatusEnum.RUNNING || cc.status == ContractStatusEnum.HANGED) - if (idOrNameOrDOI.equals(cc.name) || idOrNameOrDOI.equals(cc.contract.getDOI())) { + if (idOrNameOrDOI.equals(cc.name)) { return cc; } } for (ContractMeta cc : getStatus().values()) { if (cc.name == null) continue; if (cc.contract == null) continue; - if (idOrNameOrDOI.equals(cc.name) || idOrNameOrDOI.equals(cc.contract.getDOI())) { + if (idOrNameOrDOI.equals(cc.name)) { return cc; } }