This commit is contained in:
Frank.R.Wu 2021-11-22 14:38:28 +08:00
parent 9876ccc2e2
commit 5b4221dd29
4 changed files with 17 additions and 10 deletions

View File

@ -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);

View File

@ -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<AnnotationNode> annotations;
Set<String> dependentContracts;
transient Map<String, FunctionDesp> 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) {

View File

@ -10,7 +10,7 @@ public interface ContractExecutor {
default void close() {
}
default void onSyncMessage(Node node, byte[] data) {
default void onSyncMessage(Node node, byte[] data) {
}
}

View File

@ -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);