feat(agent-backend): add event publishing

prune CMActions; add NodeCenterClientController.publishEventFromCenter
This commit is contained in:
Frank.R.Wu 2022-03-24 12:51:14 +08:00
parent 90cdabfa92
commit 7791c78c58
2 changed files with 8 additions and 13 deletions

View File

@ -21,9 +21,7 @@ import org.bdware.server.GRPCPool;
import org.bdware.server.GlobalConf;
import org.bdware.server.action.p2p.MasterClientTCPAction;
import org.bdware.server.trustedmodel.AgentManager;
import org.bdware.server.trustedmodel.ContractExecutor;
import org.bdware.server.trustedmodel.KillUnitContractInfo;
import org.bdware.server.trustedmodel.SelfAdaptiveShardingExecutor;
import org.bdware.server.ws.ContractManagerFrameHandler;
import org.bdware.units.NetworkManager;
import org.bdware.units.function.CommunicationManager;
@ -533,16 +531,6 @@ public class CMActions implements OnHashCallback {
}
}
@Action(async = true, userPermission = 0)
public void checkBlocks(JsonObject args, final ResultCallback rcb) {
ContractExecutor executor = CMActions.manager.getExecutor(args.get("contractID").getAsString());
try {
ReplyUtil.simpleReply(rcb, "onCheckBlocks", ((SelfAdaptiveShardingExecutor) executor).checkCache());
} catch (Exception e) {
ReplyUtil.simpleReply(rcb, "onCheckBlocks", "error! " + e.getMessage());
}
}
// 节点管理者
@Action(userPermission = 1L << 19)
public void listAllContractProcess(JsonObject args, ResultCallback resultCallback) {

View File

@ -12,6 +12,7 @@ import org.bdware.sc.conn.ByteUtil;
import org.bdware.sc.conn.ResultCallback;
import org.bdware.sc.db.CMTables;
import org.bdware.sc.db.KeyValueDBUtil;
import org.bdware.sc.event.REvent;
import org.bdware.sc.units.MultiContractMeta;
import org.bdware.sc.util.JsonUtil;
import org.bdware.server.GlobalConf;
@ -51,7 +52,6 @@ public class NodeCenterClientController implements NodeCenterConn {
ReceiveFileThread receiveFileThread = new ReceiveFileThread();
public NodeCenterClientController(String nodeID) {
this.nodeID = nodeID;
this.neighbors = new NetNeighbors();
}
@ -226,6 +226,13 @@ public class NodeCenterClientController implements NodeCenterConn {
LOGGER.info("update " + info.size() + " contracts in node center");
}
@Action(async = true)
public void publishEventFromCenter(JsonObject jo, ResultCallback rcb) {
if (jo.has("event")) {
CMActions.manager.deliverEvent(JsonUtil.fromJson(jo.get("event").getAsString(), REvent.class));
}
}
@Action(async = true)
public void requestReadMe(JsonObject jo, ResultCallback cb) throws IOException {
JsonObject resp = new JsonObject();