From cdf94fc50d7706d96d5c276852790ed69401777a Mon Sep 17 00:00:00 2001 From: CaiHQ Date: Mon, 23 Dec 2024 16:19:11 +0800 Subject: [PATCH] update docker files --- .../java/org/bdware/sc/ContractClient.java | 39 ++++++++++--------- .../java/org/bdware/sc/ContractManager.java | 29 +++++++------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/bdware/sc/ContractClient.java b/src/main/java/org/bdware/sc/ContractClient.java index 74545d6..ac179d3 100644 --- a/src/main/java/org/bdware/sc/ContractClient.java +++ b/src/main/java/org/bdware/sc/ContractClient.java @@ -133,21 +133,24 @@ public class ContractClient { } private void initProps() { - // LOGGER.info("initProps ---- position-----1"); + LOGGER.info("initProps ---- position-----1"); contractMeta.name = get.syncGet("", "getContractName", ""); - // LOGGER.info("initProps ---- position-----2"); + LOGGER.info("initProps ---- position-----2"); String strEvent = get.syncGet("", "getDeclaredEvents", ""); LOGGER.debug("event: " + strEvent); contractMeta.declaredEvents = JsonUtil.fromJson(strEvent, - new TypeToken>() {}.getType()); - // LOGGER.info("initProps ---- position-----3"); + new TypeToken>() { + }.getType()); + LOGGER.info("initProps ---- position-----3"); contractMeta.dependentContracts = JsonUtil.fromJson(get.syncGet("", "getDependentContracts", ""), - new TypeToken>() {}.getType()); - // LOGGER.info("initProps ---- position-----4"); + new TypeToken>() { + }.getType()); + LOGGER.info("initProps ---- position-----4"); contractMeta.exportedFunctions = JsonUtil.fromJson(get.syncGet("", "getExportedFunctions", ""), - new TypeToken>() {}.getType()); + new TypeToken>() { + }.getType()); contractMeta.logDetail = new HashMap<>(); for (FunctionDesp func : contractMeta.exportedFunctions) { StringBuilder str = new StringBuilder(); @@ -172,24 +175,25 @@ public class ContractClient { } contractMeta.logDetail.put(func.functionName, str.toString()); } - // LOGGER.info("initProps ---- position-----5"); + LOGGER.info("initProps ---- position-----5"); try { String anno = get.syncGet("", "getAnnotations", ""); contractMeta.annotations = - JsonUtil.fromJson(anno, new TypeToken>() {}.getType()); + JsonUtil.fromJson(anno, new TypeToken>() { + }.getType()); } catch (Exception e) { // supoort contract process before version 0.70 contractMeta.annotations = new ArrayList<>(); } - // LOGGER.info("initProps ---- position-----6"); + LOGGER.info("initProps ---- position-----6"); contractMeta.sigRequired = Boolean.parseBoolean(get.syncGet("", "isSigRequired", "")); - // LOGGER.info("initProps ---- position-----7"); + LOGGER.info("initProps ---- position-----7"); contractMeta.thisPermission = get.syncGet("", "showPermission", ""); - // LOGGER.info("initProps ---- position-----8"); + LOGGER.info("initProps ---- position-----8"); isRunning = true; - // LOGGER.info("initProps ---- position-----9"); + LOGGER.info("initProps ---- position-----9"); get.syncGet("", "registerMangerPort", ContractManager.cPort.getCMPort() + ""); contractMeta.contract = JsonUtil.fromJson(get.syncGet("", "getContract", ""), Contract.class); @@ -204,8 +208,7 @@ public class ContractClient { } }); loadTimesAndTraffic(); - // LOGGER.info("initProps ---- position-----10"); - // LOGGER.debug("======= registerPort:" + ret + "-->" + ContractManager.startPort); + LOGGER.info("initProps ---- position-----10 DONE!"); } public String startProcess(PrintStream ps) throws Exception { @@ -262,7 +265,7 @@ public class ContractClient { pbParameters.toArray(result); Constructor pbc = ProcessBuilder.class.getDeclaredConstructor(String[].class); - builder = pbc.newInstance(new Object[] {result}); + builder = pbc.newInstance(new Object[]{result}); File directory = new File("./"); LOGGER.debug("[CMD] path: " + directory.getAbsolutePath()); @@ -327,7 +330,7 @@ public class ContractClient { } else { LOGGER.info("setMember ignore, meta:" + (multiContractMeta == null) + (multiContractMeta == null ? "NULL" - : " members:" + multiContractMeta.getMembers())); + : " members:" + multiContractMeta.getMembers())); } if (isBundlePath(contractMeta.contract.getScriptStr())) { @@ -335,7 +338,7 @@ public class ContractClient { } else { status = get.syncGet("", "setContract", JsonUtil.toJson(contractMeta.contract)); } - LOGGER.debug("port:" + port + " status:" + status); + LOGGER.info("start status, port:" + port + " status:" + status); ContractResult r = JsonUtil.fromJson(status, ContractResult.class); if (r.status == Status.Success) { initProps(); diff --git a/src/main/java/org/bdware/sc/ContractManager.java b/src/main/java/org/bdware/sc/ContractManager.java index 3ee58c9..26b6a4f 100644 --- a/src/main/java/org/bdware/sc/ContractManager.java +++ b/src/main/java/org/bdware/sc/ContractManager.java @@ -104,7 +104,7 @@ public class ContractManager { } private static String convertToBytes(long traffic) { - String[] unit = new String[] {"B", "KB", "MB", "GB", "TB"}; + String[] unit = new String[]{"B", "KB", "MB", "GB", "TB"}; double d = traffic; int i; for (i = 0; i < unit.length - 1; i++) { @@ -368,7 +368,7 @@ public class ContractManager { } public static void checkPointToLedger(OnHashCallback cb, String contractID, String data, - String requestID) { + String requestID) { boolean isMaster = instance.getContractIsMaster(contractID); if (!isMaster) { LOGGER.info("非合约 " + contractID + "的master,无需承担checkPoint上链任务!"); @@ -404,7 +404,9 @@ public class ContractManager { c.setType(ContractExecType.Sole); SM2KeyPair pair = SM2Util.generateSM2KeyPair(); c.setOwner(pair.getPublicKeyStr()); - c.setScript("contract analysis_client{}"); + String content = "contract analysis_client{}"; + c.setID(content.hashCode() + ""); + c.setScript(content); analysisClient = new ContractClient(c); try { analysisClient.startProcess(System.out); @@ -896,8 +898,8 @@ public class ContractManager { config.setMockConfig(mockYPK); // client.setProjectConfig(JsonUtil.toJson(config)); } // else { - // bubian - // } + // bubian + // } } } @@ -1180,7 +1182,7 @@ public class ContractManager { } private void executeInternalAsync(ContractClient client, ContractRequest request, - ResultCallback rcb, OnHashCallback cb) { + ResultCallback rcb, OnHashCallback cb) { ContractResult cr; long start = System.currentTimeMillis(); @@ -1221,7 +1223,7 @@ public class ContractManager { } private String executeInternal(ContractClient client, ContractRequest request, - OnHashCallback ocb) { + OnHashCallback ocb) { // LOGGER.info("ContractManager executeInternal : "); ContractResult cr; @@ -1252,7 +1254,7 @@ public class ContractManager { * @author Kaidong Wu */ public void extractEventsFromContractResult(OnHashCallback ocb, JsonObject result, - ContractClient client, ContractRequest request, long startTime) { + ContractClient client, ContractRequest request, long startTime) { try { ContractResult cr = JsonUtil.fromJson(result, ContractResult.class); if (null != cr.events && !cr.events.isEmpty()) { @@ -1303,7 +1305,7 @@ public class ContractManager { } public void executeContractInternal(ContractRequest cr, final ResultCallback rcb, - final OnHashCallback hcb) { + final OnHashCallback hcb) { LOGGER.debug(JsonUtil.toJson(cr)); ContractMeta meta = statusRecorder.getContractMeta(cr.getContractID()); MultiContractMeta multiMeta = @@ -1793,14 +1795,15 @@ public class ContractManager { */ public void addLocalContractLog(String action, String contractId, String contractName, - String pubKey) { + String pubKey) { String sb = "{\"action\":\"" + action + "\",\"pubKey\":\"" + pubKey + "\",\"contractID\":\"" + contractId + "\",\"contractName\":\"" + contractName + "\",\"date\":" + System.currentTimeMillis() + "}"; logsDB.put(contractName, sb); } - public void changePermission(String contractFileName, String pmList) {} + public void changePermission(String contractFileName, String pmList) { + } // public String getSyncType(String contractName) { // ContractClient client = getByName(contractName); @@ -1851,8 +1854,8 @@ public class ContractManager { // } public void addLocalContractLog(String action, String contractId, String contractName, - String pubKey, String function, String costTime, long totalGas, long executionGas, - long extraGas, Map logType) { + String pubKey, String function, String costTime, long totalGas, long executionGas, + long extraGas, Map logType) { contractCounter.inc(); if (logType == null || logType.isEmpty()) { logsDB.put(contractName,