Search in sources :

Example 1 with NodeEvent

use of io.nuls.network.message.entity.NodeEvent in project nuls by nuls-io.

the class GetNodeEventHandler method process.

@Override
public NetworkEventResult process(BaseEvent event, Node node) {
    GetNodeEvent getNodeEvent = (GetNodeEvent) event;
    // String key = event.getHeader().getEventType() + "-" + node.getIp();
    // if (cacheService.existEvent(key)) {
    // getNetworkService().removeNode(node.getId());
    // return null;
    // }
    // cacheService.putEvent(key, event, false);
    List<Node> list = getAvailableNodes(getNodeEvent.getLength(), node.getId());
    NodeEvent replyEvent = new NodeEvent(list);
    return new NetworkEventResult(true, replyEvent);
}
Also used : GetNodeEvent(io.nuls.network.message.entity.GetNodeEvent) NodeEvent(io.nuls.network.message.entity.NodeEvent) Node(io.nuls.network.entity.Node) GetNodeEvent(io.nuls.network.message.entity.GetNodeEvent) NetworkEventResult(io.nuls.network.message.NetworkEventResult)

Example 2 with NodeEvent

use of io.nuls.network.message.entity.NodeEvent in project nuls by nuls-io.

the class NodeEventHandler method process.

@Override
public NetworkEventResult process(BaseEvent networkEvent, Node node) {
    NodeEvent event = (NodeEvent) networkEvent;
    for (Node newNode : event.getEventBody().getNodes()) {
        newNode.setType(Node.OUT);
        newNode.setStatus(Node.WAIT);
        getNetworkService().addNodeToGroup(NetworkConstant.NETWORK_NODE_OUT_GROUP, newNode);
    }
    return null;
}
Also used : NodeEvent(io.nuls.network.message.entity.NodeEvent) Node(io.nuls.network.entity.Node)

Aggregations

Node (io.nuls.network.entity.Node)2 NodeEvent (io.nuls.network.message.entity.NodeEvent)2 NetworkEventResult (io.nuls.network.message.NetworkEventResult)1 GetNodeEvent (io.nuls.network.message.entity.GetNodeEvent)1