mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 01:44:14 +00:00
feat: support jsontype in execute contract
This commit is contained in:
parent
ac77d55952
commit
802713a001
@ -352,10 +352,9 @@ public class GRPCPool implements ChainOpener {
|
||||
|
||||
}
|
||||
//根据事务类型查找
|
||||
else if(args.has("type")){
|
||||
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);
|
||||
|
@ -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();
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user