fix: fix bugs in event mechanism

fix bugs in event delivering cross nodes
This commit is contained in:
Frank.R.Wu 2021-11-26 15:54:35 +08:00
parent 5b4221dd29
commit cf885a53fa
4 changed files with 7 additions and 5 deletions

View File

@ -1877,7 +1877,7 @@ public class ContractManager {
return ret; return ret;
} }
public String deliverEMessage(REvent msg) { public String deliverEvent(REvent msg) {
eventBroker.handle(msg); eventBroker.handle(msg);
return "success"; return "success";
} }

View File

@ -96,6 +96,6 @@ public class ManagerHandler extends MsgHandler {
@Description("Deliver event message") @Description("Deliver event message")
public void deliverEMessage(GetMessage msg, ResultCallback cb) { public void deliverEMessage(GetMessage msg, ResultCallback cb) {
REvent eMsg = JsonUtil.fromJson(msg.arg, REvent.class); REvent eMsg = JsonUtil.fromJson(msg.arg, REvent.class);
cb.onResult(cm.deliverEMessage(eMsg)); cb.onResult(cm.deliverEvent(eMsg));
} }
} }

View File

@ -5,6 +5,8 @@ import org.bdware.sc.units.TrustfulExecutorConnection;
public interface CommitAlgorithm { public interface CommitAlgorithm {
void onMessage(Node node, byte[] msg); void onMessage(Node node, byte[] msg);
void setCommitter(Committer c); void setCommitter(Committer c);
void setConnection(TrustfulExecutorConnection c); void setConnection(TrustfulExecutorConnection c);
} }

View File

@ -5,12 +5,12 @@ import org.bdware.sc.conn.Node;
import java.util.List; import java.util.List;
public interface TrustfulExecutorConnection<T extends Node> { public interface TrustfulExecutorConnection<T extends Node> {
public void sendMessage(T node, byte[] msg); void sendMessage(T node, byte[] msg);
default public void broadcast(byte[] msg) { default void broadcast(byte[] msg) {
for (T t : getNodes()) for (T t : getNodes())
sendMessage(t, msg); sendMessage(t, msg);
} }
public List<T> getNodes(); List<T> getNodes();
} }