feat: support jsontype in execute contract

This commit is contained in:
CaiHQ 2021-12-03 11:19:29 +08:00
parent ac77d55952
commit 802713a001
4 changed files with 20 additions and 22 deletions

View File

@ -354,8 +354,7 @@ public class GRPCPool implements ChainOpener {
//根据事务类型查找
else if (args.has("type")) {
index = createIndexIfNotExist(args.get("type").getAsString());
}
else index = logIndex;
} else index = logIndex;
List<byte[]> result;
if (offset < 0) result = index.requestLast(count);
else result = index.request(offset, count);
@ -759,7 +758,7 @@ public class GRPCPool implements ChainOpener {
String s;
for (String info : detailStr) {
if (info.equals("Arg")) {
s = c.getArg();
s = c.getArg().getAsString();
s = JsonUtil.toJson(s);
if (s.length() > 2) {
s = s.substring(1, s.length() - 1);

View File

@ -156,7 +156,7 @@ public class CMActions implements OnHashCallback {
}
if (args.has("operation")) {
cReq.setAction(args.get("operation").getAsString());
cReq.setArg(args.get("arg").getAsString());
cReq.setArg(args.get("arg"));
} else {
JsonObject jo = JsonParser.parseString(args.get("arg").getAsString()).getAsJsonObject();
if (!jo.has("action") || !jo.has("arg")) {
@ -283,16 +283,15 @@ public class CMActions implements OnHashCallback {
if (FUNCINVOKEINFO.getOneFunction(c.getContractID(), desp.functionName) != null) {
ArrayList<javax.json.JsonObject> Records =
ArrayList<JsonObject> Records =
FUNCINVOKEINFO.getOneFunction(c.getContractID(), desp.functionName);
invokeRocords = Records.toString();
// System.out.println(Records.get(0));
if (Records.get(0) != null) {
argTemplate = Records.get(0).get("args").toString();
//resTemplate = Records.get(0).get("res").toString();
argSchema = Records.get(0).get("args").toString();
argTemplate = Records.get(0).get("args").getAsString();
argSchema = Records.get(0).get("args").getAsString();
resSchema = Records.get(0).get("res").toString();
JsonElement argEle = JsonParser.parseString(argSchema);
MockSchemaParser parser = new MockSchemaParser();

View File

@ -154,7 +154,7 @@ public class MultiPointCooperationExecutor implements ContractExecutor {
}
return new String[]{members[val]};
case byTarget:
JsonObject jo = JsonParser.parseString(req.getArg()).getAsJsonObject();
JsonObject jo = req.getArg().getAsJsonObject();
val =
new BigInteger(jo.get("target").getAsString(), 16)
.mod(new BigInteger("" + members.length))

View File

@ -1,9 +1,10 @@
package org.bdware.utils;
import javax.json.*;
import java.util.*;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.bdware.sc.db.FIFOCache;
public class FuncInvokeInfo {
@ -51,13 +52,12 @@ public class FuncInvokeInfo {
}
public void putOneInvoke(
String ContractName, String FunctionName, String ResponseID, String args, String res) {
String ContractName, String FunctionName, String ResponseID, JsonElement args, String res) {
String Key1 = ContractName + "|" + FunctionName;
String Key2 = ResponseID;
JsonObject Record = null; // 一条调用信息{arg:xx,res:xx}
JsonBuilderFactory factory = null;
factory = Json.createBuilderFactory(null);
Record = factory.createObjectBuilder().add("args", args).add("res", res).build();
JsonObject Record =new JsonObject();
Record.add("args",args);
Record.addProperty("res",res);
invokeInfoList.add(Key1, Record);