front: support startMulitipoint with args

fix: ContractClient missing arguments error
update: @Router arguments format
fix: ContractStatusRecorder null exception
This commit is contained in:
CaiHQ 2022-06-26 17:54:29 +08:00
parent b468f5947f
commit bfd389f30e

View File

@ -128,29 +128,16 @@ public class MultiPointCooperationExecutor extends AbstractContextContractExecut
return new String[]{members[val]}; return new String[]{members[val]};
case byFunc: case byFunc:
ContractClient client = cmActions.getManager().getClient(req.getContractID()); ContractClient client = cmActions.getManager().getClient(req.getContractID());
JsonArray membersArr = new JsonArray(members.length);
for (String member : members) {
membersArr.add(member);
}
JsonObject arg = new JsonObject(); JsonObject arg = new JsonObject();
arg.addProperty("funcName", routeInfo.funcName); arg.addProperty("funcName", routeInfo.funcName);
// func myFunc (currentNode, members, membersCount, sourceArg) // func myFunc (requester, sourceArg)
JsonArray funcArgs = new JsonArray(); JsonArray funcArgs = new JsonArray();
funcArgs.add(globalConf.getNodeID()); funcArgs.add(req.getRequester());
funcArgs.add(membersArr);
funcArgs.add(membersArr.size());
funcArgs.add(req.getArg()); funcArgs.add(req.getArg());
arg.add("funcArgs", funcArgs); arg.add("funcArgs", funcArgs);
String routeResultStr = client.executeMethod("", "invokeFunctionWithoutLimit", arg.toString()); String routeResultStr = client.executeMethod("", "invokeFunctionWithoutLimit", arg.toString());
JsonObject routeResult = JsonUtil.parseString(routeResultStr).getAsJsonObject(); String[] routeResult = JsonUtil.fromJson(routeResultStr, String[].class);
List<String> nodes = new ArrayList<>(); return routeResult;
for (String key: routeResult.keySet()) {
nodes.add(routeResult.get(key).getAsString());
}
return nodes.toArray(new String[]{});
default: default:
return members; return members;
} }