mirror of
https://gitee.com/BDWare/cm
synced 2025-01-25 09:14:03 +00:00
feat: support requestID auto append in agent websocket
This commit is contained in:
parent
e11d151b55
commit
6a35a67631
@ -1295,7 +1295,7 @@ public class ContractManager {
|
|||||||
if (client.contractMeta.sigRequired) {
|
if (client.contractMeta.sigRequired) {
|
||||||
if (!request.verifySignature()) {
|
if (!request.verifySignature()) {
|
||||||
cr = new ContractResult(Status.Error, new JsonPrimitive("sign verified failed"));
|
cr = new ContractResult(Status.Error, new JsonPrimitive("sign verified failed"));
|
||||||
rcb.onResult(JsonUtil.toJson(cr));
|
rcb.onResult(JsonUtil.parseObject(cr));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1307,19 +1307,20 @@ public class ContractManager {
|
|||||||
new ResultCallback() {
|
new ResultCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onResult(String result) {
|
public void onResult(String result) {
|
||||||
|
//TODO????
|
||||||
client.traffic += result.length();
|
client.traffic += result.length();
|
||||||
client.contractStatus = ContractStatus.Executed;
|
client.contractStatus = ContractStatus.Executed;
|
||||||
|
|
||||||
String finalRet = result;
|
JsonObject finalRet = JsonUtil.parseString(result);
|
||||||
if (client.getContractCopies() == 1) {
|
if (client.getContractCopies() == 1) {
|
||||||
finalRet =
|
finalRet =
|
||||||
extractEventsFromContractResult(
|
extractEventsFromContractResult(
|
||||||
cb, result, client, request, start);
|
cb, finalRet, client, request, start);
|
||||||
}
|
}
|
||||||
rcb.onResult(finalRet);
|
rcb.onResult(finalRet);
|
||||||
if (finalRet.length() == result.length()) {
|
if (finalRet != null) {
|
||||||
chainOpener.writeContractResultToLocalAndLedger(
|
chainOpener.writeContractResultToLocalAndLedger(
|
||||||
finalRet,
|
finalRet.toString(),
|
||||||
client,
|
client,
|
||||||
request,
|
request,
|
||||||
cb,
|
cb,
|
||||||
@ -1334,6 +1335,7 @@ public class ContractManager {
|
|||||||
totalCounter.inc();
|
totalCounter.inc();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
// if (ignoreLog) {
|
// if (ignoreLog) {
|
||||||
// rcb.onResult(
|
// rcb.onResult(
|
||||||
@ -1367,14 +1369,11 @@ public class ContractManager {
|
|||||||
|
|
||||||
client.traffic += result.length();
|
client.traffic += result.length();
|
||||||
|
|
||||||
String finalRet = result;
|
|
||||||
if (client.getContractCopies() == 1) {
|
if (client.getContractCopies() == 1) {
|
||||||
finalRet = extractEventsFromContractResult(ocb, result, client, request, start);
|
extractEventsFromContractResult(ocb, JsonUtil.parseString(result), client, request, start);
|
||||||
}
|
}
|
||||||
if (finalRet.length() == result.length()) {
|
|
||||||
chainOpener.writeContractResultToLocalAndLedger(
|
chainOpener.writeContractResultToLocalAndLedger(
|
||||||
result, client, request, ocb, start, System.currentTimeMillis() - start);
|
result, client, request, ocb, start, System.currentTimeMillis() - start);
|
||||||
}
|
|
||||||
contractCounter.inc();
|
contractCounter.inc();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1384,21 +1383,19 @@ public class ContractManager {
|
|||||||
*
|
*
|
||||||
* @author Kaidong Wu
|
* @author Kaidong Wu
|
||||||
*/
|
*/
|
||||||
public String extractEventsFromContractResult(
|
public JsonObject extractEventsFromContractResult(
|
||||||
OnHashCallback ocb,
|
OnHashCallback ocb,
|
||||||
String result,
|
JsonObject result,
|
||||||
ContractClient client,
|
ContractClient client,
|
||||||
ContractRequest request,
|
ContractRequest request,
|
||||||
long startTime) {
|
long startTime) {
|
||||||
String ret = result;
|
|
||||||
try {
|
try {
|
||||||
ContractResult cr = JsonUtil.fromJson(result, ContractResult.class);
|
ContractResult cr = JsonUtil.fromJson(result, ContractResult.class);
|
||||||
if (null != cr.events && !cr.events.isEmpty()) {
|
if (null != cr.events && !cr.events.isEmpty()) {
|
||||||
List<REvent> msgList = cr.events;
|
List<REvent> msgList = cr.events;
|
||||||
cr.events = null;
|
cr.events = null;
|
||||||
ret = JsonUtil.toJson(cr);
|
|
||||||
chainOpener.writeContractResultToLocalAndLedger(
|
chainOpener.writeContractResultToLocalAndLedger(
|
||||||
ret,
|
result.toString(),
|
||||||
client,
|
client,
|
||||||
request,
|
request,
|
||||||
(reqID, hashStr) -> {
|
(reqID, hashStr) -> {
|
||||||
@ -1431,7 +1428,7 @@ public class ContractManager {
|
|||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
return ret;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int countEvents() {
|
public int countEvents() {
|
||||||
@ -1550,9 +1547,10 @@ public class ContractManager {
|
|||||||
new JsonPrimitive(
|
new JsonPrimitive(
|
||||||
"Contract " + cr.getContractID() + " doesn't exists!!"));
|
"Contract " + cr.getContractID() + " doesn't exists!!"));
|
||||||
}
|
}
|
||||||
rcb.onResult(JsonUtil.toJson(result));
|
rcb.onResult(JsonUtil.parseObject(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ContractClient getByName(String contractName) {
|
private ContractClient getByName(String contractName) {
|
||||||
return statusRecorder.getContractClient(contractName);
|
return statusRecorder.getContractClient(contractName);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user