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());
|
index = createIndexIfNotExist(args.get("type").getAsString());
|
||||||
}
|
} else index = logIndex;
|
||||||
else index = logIndex;
|
|
||||||
List<byte[]> result;
|
List<byte[]> result;
|
||||||
if (offset < 0) result = index.requestLast(count);
|
if (offset < 0) result = index.requestLast(count);
|
||||||
else result = index.request(offset, count);
|
else result = index.request(offset, count);
|
||||||
@ -389,9 +388,9 @@ public class GRPCPool implements ChainOpener {
|
|||||||
try {
|
try {
|
||||||
JsonObject jo =
|
JsonObject jo =
|
||||||
JsonParser.parseString(
|
JsonParser.parseString(
|
||||||
new String(
|
new String(
|
||||||
hash2Data.get(
|
hash2Data.get(
|
||||||
args.get("hash").getAsString().getBytes())))
|
args.get("hash").getAsString().getBytes())))
|
||||||
.getAsJsonObject();
|
.getAsJsonObject();
|
||||||
jo.addProperty("action", "onQueryDataByHash");
|
jo.addProperty("action", "onQueryDataByHash");
|
||||||
resultCallback.onResult(JsonUtil.toJson(jo));
|
resultCallback.onResult(JsonUtil.toJson(jo));
|
||||||
@ -427,9 +426,9 @@ public class GRPCPool implements ChainOpener {
|
|||||||
try {
|
try {
|
||||||
JsonObject jo =
|
JsonObject jo =
|
||||||
JsonParser.parseString(
|
JsonParser.parseString(
|
||||||
new String(
|
new String(
|
||||||
hash2Data.get(
|
hash2Data.get(
|
||||||
args.get("hash").getAsString().getBytes())))
|
args.get("hash").getAsString().getBytes())))
|
||||||
.getAsJsonObject();
|
.getAsJsonObject();
|
||||||
jo.addProperty("action", "onQueryDataByHash");
|
jo.addProperty("action", "onQueryDataByHash");
|
||||||
resultCallback.onResult(JsonUtil.toJson(jo));
|
resultCallback.onResult(JsonUtil.toJson(jo));
|
||||||
@ -759,7 +758,7 @@ public class GRPCPool implements ChainOpener {
|
|||||||
String s;
|
String s;
|
||||||
for (String info : detailStr) {
|
for (String info : detailStr) {
|
||||||
if (info.equals("Arg")) {
|
if (info.equals("Arg")) {
|
||||||
s = c.getArg();
|
s = c.getArg().getAsString();
|
||||||
s = JsonUtil.toJson(s);
|
s = JsonUtil.toJson(s);
|
||||||
if (s.length() > 2) {
|
if (s.length() > 2) {
|
||||||
s = s.substring(1, s.length() - 1);
|
s = s.substring(1, s.length() - 1);
|
||||||
|
@ -156,7 +156,7 @@ public class CMActions implements OnHashCallback {
|
|||||||
}
|
}
|
||||||
if (args.has("operation")) {
|
if (args.has("operation")) {
|
||||||
cReq.setAction(args.get("operation").getAsString());
|
cReq.setAction(args.get("operation").getAsString());
|
||||||
cReq.setArg(args.get("arg").getAsString());
|
cReq.setArg(args.get("arg"));
|
||||||
} else {
|
} else {
|
||||||
JsonObject jo = JsonParser.parseString(args.get("arg").getAsString()).getAsJsonObject();
|
JsonObject jo = JsonParser.parseString(args.get("arg").getAsString()).getAsJsonObject();
|
||||||
if (!jo.has("action") || !jo.has("arg")) {
|
if (!jo.has("action") || !jo.has("arg")) {
|
||||||
@ -283,16 +283,15 @@ public class CMActions implements OnHashCallback {
|
|||||||
|
|
||||||
if (FUNCINVOKEINFO.getOneFunction(c.getContractID(), desp.functionName) != null) {
|
if (FUNCINVOKEINFO.getOneFunction(c.getContractID(), desp.functionName) != null) {
|
||||||
|
|
||||||
ArrayList<javax.json.JsonObject> Records =
|
ArrayList<JsonObject> Records =
|
||||||
FUNCINVOKEINFO.getOneFunction(c.getContractID(), desp.functionName);
|
FUNCINVOKEINFO.getOneFunction(c.getContractID(), desp.functionName);
|
||||||
invokeRocords = Records.toString();
|
invokeRocords = Records.toString();
|
||||||
// System.out.println(Records.get(0));
|
// System.out.println(Records.get(0));
|
||||||
|
|
||||||
if (Records.get(0) != null) {
|
if (Records.get(0) != null) {
|
||||||
|
|
||||||
argTemplate = Records.get(0).get("args").toString();
|
argTemplate = Records.get(0).get("args").getAsString();
|
||||||
//resTemplate = Records.get(0).get("res").toString();
|
argSchema = Records.get(0).get("args").getAsString();
|
||||||
argSchema = Records.get(0).get("args").toString();
|
|
||||||
resSchema = Records.get(0).get("res").toString();
|
resSchema = Records.get(0).get("res").toString();
|
||||||
JsonElement argEle = JsonParser.parseString(argSchema);
|
JsonElement argEle = JsonParser.parseString(argSchema);
|
||||||
MockSchemaParser parser = new MockSchemaParser();
|
MockSchemaParser parser = new MockSchemaParser();
|
||||||
|
@ -154,7 +154,7 @@ public class MultiPointCooperationExecutor implements ContractExecutor {
|
|||||||
}
|
}
|
||||||
return new String[]{members[val]};
|
return new String[]{members[val]};
|
||||||
case byTarget:
|
case byTarget:
|
||||||
JsonObject jo = JsonParser.parseString(req.getArg()).getAsJsonObject();
|
JsonObject jo = req.getArg().getAsJsonObject();
|
||||||
val =
|
val =
|
||||||
new BigInteger(jo.get("target").getAsString(), 16)
|
new BigInteger(jo.get("target").getAsString(), 16)
|
||||||
.mod(new BigInteger("" + members.length))
|
.mod(new BigInteger("" + members.length))
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package org.bdware.utils;
|
package org.bdware.utils;
|
||||||
|
|
||||||
import javax.json.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import org.bdware.sc.db.FIFOCache;
|
import org.bdware.sc.db.FIFOCache;
|
||||||
|
|
||||||
public class FuncInvokeInfo {
|
public class FuncInvokeInfo {
|
||||||
@ -51,13 +52,12 @@ public class FuncInvokeInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void putOneInvoke(
|
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 Key1 = ContractName + "|" + FunctionName;
|
||||||
String Key2 = ResponseID;
|
String Key2 = ResponseID;
|
||||||
JsonObject Record = null; // 一条调用信息{arg:xx,res:xx}
|
JsonObject Record =new JsonObject();
|
||||||
JsonBuilderFactory factory = null;
|
Record.add("args",args);
|
||||||
factory = Json.createBuilderFactory(null);
|
Record.addProperty("res",res);
|
||||||
Record = factory.createObjectBuilder().add("args", args).add("res", res).build();
|
|
||||||
|
|
||||||
invokeInfoList.add(Key1, Record);
|
invokeInfoList.add(Key1, Record);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user