mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 01:44:14 +00:00
fix: fix bugs in event mechanism
fix bugs in event delivering cross nodes
This commit is contained in:
parent
789a896cca
commit
7efdeff5bc
@ -271,8 +271,8 @@ public class NodeCenterClientController implements NodeCenterConn {
|
||||
}
|
||||
|
||||
@Action(async = true)
|
||||
public void receiveEMsg(JsonObject jo, ResultCallback cb) {
|
||||
CMActions.manager.deliverEMessage(
|
||||
public void deliverEvent(JsonObject jo, ResultCallback cb) {
|
||||
CMActions.manager.deliverEvent(
|
||||
JsonUtil.fromJson(jo.get("data").getAsString(), REvent.class));
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.bdware.sc.ContractManager;
|
||||
import org.bdware.sc.ContractResult;
|
||||
import org.bdware.sc.bean.ContractRequest;
|
||||
import org.bdware.sc.bean.FunctionDesp;
|
||||
import org.bdware.sc.bean.SM2Verifiable;
|
||||
import org.bdware.sc.conn.OnHashCallback;
|
||||
import org.bdware.sc.conn.ResultCallback;
|
||||
import org.bdware.sc.units.MultiContractMeta;
|
||||
@ -224,11 +225,12 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
static class Block {
|
||||
static class Block extends SM2Verifiable {
|
||||
String prevHash = "0";
|
||||
String hash;
|
||||
String checkPoint;
|
||||
String body;
|
||||
String nodePubKey;
|
||||
ContractRequest[] requests;
|
||||
long timestamp;
|
||||
|
||||
@ -244,10 +246,11 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor {
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
this.body = merkle(requests);
|
||||
this.hash = computeHash();
|
||||
doSignature(CMActions.manager.nodeCenterConn.getNodeKeyPair());
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return computeHash().equals(hash) && body.equals(merkle(this.requests));
|
||||
return computeHash().equals(hash) && body.equals(merkle(this.requests)) && verifySignature();
|
||||
}
|
||||
|
||||
private String computeHash() {
|
||||
@ -280,5 +283,19 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor {
|
||||
return reqQueue.poll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPublicKey() {
|
||||
return nodePubKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPublicKey(String pubkey) {
|
||||
this.nodePubKey = pubkey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentStr() {
|
||||
return this.hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user