From 18f40dc6a91d06424bff9de1e6cd9a5721d60c86 Mon Sep 17 00:00:00 2001 From: "Frank.R.Wu" Date: Fri, 5 Nov 2021 14:13:22 +0800 Subject: [PATCH] feat: add return value of JavaScriptEntry.subscribe --- src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java b/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java index b436616..5a52252 100644 --- a/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java +++ b/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java @@ -586,12 +586,13 @@ public class JavaScriptEntry { * @param fun related handler function * @author Kaidong Wu */ - public static void subscribe(String topic, ScriptFunction fun) { + public static String subscribe(String topic, ScriptFunction fun) { subscribe(topic, fun, false); if (topic_handlers.containsKey(topic)) { ContractProcess.instance.unSubscribe(topic_handlers.get(topic).getName()); } topic_handlers.put(topic, fun); + return topic; } /** @@ -602,13 +603,14 @@ public class JavaScriptEntry { * @param fun related handler function * @author Kaidong Wu */ - public static void subscribe(String contractID, String event, ScriptFunction fun) { + public static String 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); + return topic; } private static void subscribe(String topic, ScriptFunction fun, boolean fromPreSub) {