diff --git a/src/main/java/org/bdware/sc/ContractManager.java b/src/main/java/org/bdware/sc/ContractManager.java index afc1f9f..53de50c 100644 --- a/src/main/java/org/bdware/sc/ContractManager.java +++ b/src/main/java/org/bdware/sc/ContractManager.java @@ -890,6 +890,7 @@ public class ContractManager { case RequestAllResponseHalf: case Sharding: case Sole: + case SelfAdaptiveSharding: case PBFT: ret = client.startProcess(ps); conflictCheck = checkConflict(c, client, ret); @@ -1475,7 +1476,7 @@ public class ContractManager { LOGGER.debug( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") .format(new Date(System.currentTimeMillis())) - + meta.contractExecutor + " 结果是 " + + meta.contractExecutor + " result=" + result.toString() + "\n"); rcb.onResult(result); diff --git a/src/main/java/org/bdware/sc/ContractMeta.java b/src/main/java/org/bdware/sc/ContractMeta.java index 9c30bbe..7b91e9f 100644 --- a/src/main/java/org/bdware/sc/ContractMeta.java +++ b/src/main/java/org/bdware/sc/ContractMeta.java @@ -16,6 +16,7 @@ import java.util.Set; public class ContractMeta implements IDSerializable { public Contract contract; + public transient ContractExecutor contractExecutor; ContractStatusEnum status; String name; String id; @@ -26,8 +27,6 @@ public class ContractMeta implements IDSerializable { List annotations; Set dependentContracts; transient Map funCache; - public transient ContractExecutor contractExecutor; - boolean sigRequired; String thisPermission; // 合约当前权限 /* @@ -101,12 +100,17 @@ public class ContractMeta implements IDSerializable { } public FunctionDesp getExportedFunction(String action) { - if (funCache == null) funCache = new HashMap<>(); - FunctionDesp desp = funCache.get(action); - if (desp != null) return desp; - desp = seekFunction(action); - if (desp != null) funCache.put(action, desp); - return desp; + FunctionDesp ret; + if (null == funCache) { + funCache = new HashMap<>(); + } + if (!funCache.containsKey(action)) { + ret = seekFunction(action); + funCache.put(action, ret); + } else { + ret = funCache.get(action); + } + return ret; } private FunctionDesp seekFunction(String action) { diff --git a/src/main/java/org/bdware/server/trustedmodel/ContractExecutor.java b/src/main/java/org/bdware/server/trustedmodel/ContractExecutor.java index 9f3e8d4..1cd23a9 100644 --- a/src/main/java/org/bdware/server/trustedmodel/ContractExecutor.java +++ b/src/main/java/org/bdware/server/trustedmodel/ContractExecutor.java @@ -10,7 +10,7 @@ public interface ContractExecutor { default void close() { } - default void onSyncMessage(Node node, byte[] data) { + default void onSyncMessage(Node node, byte[] data) { } } diff --git a/src/main/java/org/bdware/server/trustedmodel/SingleNodeExecutor.java b/src/main/java/org/bdware/server/trustedmodel/SingleNodeExecutor.java index c7d4167..1cf0096 100644 --- a/src/main/java/org/bdware/server/trustedmodel/SingleNodeExecutor.java +++ b/src/main/java/org/bdware/server/trustedmodel/SingleNodeExecutor.java @@ -8,9 +8,11 @@ import org.bdware.sc.conn.ResultCallback; public class SingleNodeExecutor implements ContractExecutor { public static SingleNodeExecutor instance = new SingleNodeExecutor(); private ContractManager cm; + public static void setContractManager(ContractManager cm) { instance.cm = cm; } + @Override public void execute(String requestID, ContractRequest req, ResultCallback rcb, OnHashCallback hcb) { cm.executeLocallyAsync(req, rcb, hcb);