diff --git a/src/main/java/org/bdware/server/GRPCPool.java b/src/main/java/org/bdware/server/GRPCPool.java index 007b9c1..47f43b1 100644 --- a/src/main/java/org/bdware/server/GRPCPool.java +++ b/src/main/java/org/bdware/server/GRPCPool.java @@ -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 result; if (offset < 0) result = index.requestLast(count); else result = index.request(offset, count); @@ -389,9 +388,9 @@ public class GRPCPool implements ChainOpener { try { JsonObject jo = JsonParser.parseString( - new String( - hash2Data.get( - args.get("hash").getAsString().getBytes()))) + new String( + hash2Data.get( + args.get("hash").getAsString().getBytes()))) .getAsJsonObject(); jo.addProperty("action", "onQueryDataByHash"); resultCallback.onResult(JsonUtil.toJson(jo)); @@ -427,9 +426,9 @@ public class GRPCPool implements ChainOpener { try { JsonObject jo = JsonParser.parseString( - new String( - hash2Data.get( - args.get("hash").getAsString().getBytes()))) + new String( + hash2Data.get( + args.get("hash").getAsString().getBytes()))) .getAsJsonObject(); jo.addProperty("action", "onQueryDataByHash"); resultCallback.onResult(JsonUtil.toJson(jo)); @@ -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); diff --git a/src/main/java/org/bdware/server/action/CMActions.java b/src/main/java/org/bdware/server/action/CMActions.java index b4fb46e..ab45649 100644 --- a/src/main/java/org/bdware/server/action/CMActions.java +++ b/src/main/java/org/bdware/server/action/CMActions.java @@ -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 Records = + ArrayList 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(); diff --git a/src/main/java/org/bdware/server/executor/unconsistency/MultiPointCooperationExecutor.java b/src/main/java/org/bdware/server/executor/unconsistency/MultiPointCooperationExecutor.java index dd8ac64..c7ac257 100644 --- a/src/main/java/org/bdware/server/executor/unconsistency/MultiPointCooperationExecutor.java +++ b/src/main/java/org/bdware/server/executor/unconsistency/MultiPointCooperationExecutor.java @@ -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)) diff --git a/src/main/java/org/bdware/utils/FuncInvokeInfo.java b/src/main/java/org/bdware/utils/FuncInvokeInfo.java index b20cf85..d06f98d 100644 --- a/src/main/java/org/bdware/utils/FuncInvokeInfo.java +++ b/src/main/java/org/bdware/utils/FuncInvokeInfo.java @@ -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);