use of io.nuls.network.model.NetworkEventResult in project nuls by nuls-io.
the class GetNodesMessageHandler method process.
@Override
public NetworkEventResult process(BaseMessage message, Node node) {
List<Node> nodeList = getAvailableNodes();
NodeMessageBody body = new NodeMessageBody();
body.setNodeList(nodeList);
NodesMessage nodesMessage = new NodesMessage(body);
return new NetworkEventResult(true, nodesMessage);
}
use of io.nuls.network.model.NetworkEventResult in project nuls by nuls-io.
the class GetVersionMessageHandler method process.
@Override
public NetworkEventResult process(BaseMessage message, Node node) {
GetVersionMessage getVersionMessage = (GetVersionMessage) message;
NetworkMessageBody body = getVersionMessage.getMsgBody();
if (body.getBestBlockHeight() < 0) {
// node.setStatus(Node.BAD);
nodeManager.removeNode(node.getId());
return null;
}
node.setBestBlockHeight(body.getBestBlockHeight());
node.setBestBlockHash(body.getBestBlockHash());
NetworkMessageBody myVersionBody = new NetworkMessageBody(NetworkConstant.HANDSHAKE_CLIENT_TYPE, networkParam.getPort(), NulsContext.getInstance().getBestHeight(), NulsContext.getInstance().getBestBlock().getHeader().getHash());
return new NetworkEventResult(true, new VersionMessage(myVersionBody));
}
Aggregations