diff --git a/src/main/java/org/bdware/sc/ContractProcess.java b/src/main/java/org/bdware/sc/ContractProcess.java index d55a54f..ee160e5 100644 --- a/src/main/java/org/bdware/sc/ContractProcess.java +++ b/src/main/java/org/bdware/sc/ContractProcess.java @@ -456,7 +456,7 @@ public class ContractProcess { JavaScriptEntry.random.setSeed(Integer.parseInt(contract.getID())); JavaScriptEntry.numOfCopies = this.contract.getNumOfCopies(); JavaScriptEntry.shardingID = - this.contract.getShardingId(); // 设置javaScriptEntry中的shadingID + this.contract.getShardingId(); // 设置javaScriptEntry中的shardingID // JavaScriptEntry String zipPath = contract.getScriptStr(); if (isArchiveFile(new File(zipPath))) { diff --git a/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java b/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java index 37e67cf..b436616 100644 --- a/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java +++ b/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java @@ -59,7 +59,7 @@ public class JavaScriptEntry { public static int numOfCopies; public static boolean isDebug; public static List msgList; - public static int shadingId; + public static int shardingID; // private static SM2KeyPair keyPair = new SM2().generateKeyPair(); // TODO ?? 本地服务器的,39上运行39的 // public static String privKey; // public static String pubKey; @@ -594,6 +594,23 @@ public class JavaScriptEntry { topic_handlers.put(topic, fun); } + /** + * subscribe a local event + * + * @param contractID contractID + * @param event local event topic + * @param fun related handler function + * @author Kaidong Wu + */ + public static void subscribe(String contractID, String event, ScriptFunction fun) { + String topic = HashUtil.sha3(contractID, event); + subscribe(topic, fun, false); + if (topic_handlers.containsKey(topic)) { + ContractProcess.instance.unSubscribe(topic_handlers.get(topic).getName()); + } + topic_handlers.put(topic, fun); + } + private static void subscribe(String topic, ScriptFunction fun, boolean fromPreSub) { String reqID = String.format(