org.tron.p2p.discover.NodeManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of libp2p Show documentation
Show all versions of libp2p Show documentation
libp2p is a p2p network SDK implemented in java language.
The newest version!
package org.tron.p2p.discover;
import java.util.List;
import org.tron.p2p.base.Parameter;
import org.tron.p2p.discover.protocol.kad.KadService;
import org.tron.p2p.discover.socket.DiscoverServer;
public class NodeManager {
private static DiscoverService discoverService;
private static DiscoverServer discoverServer;
public static void init() {
discoverService = new KadService();
discoverService.init();
if (Parameter.p2pConfig.isDiscoverEnable()) {
discoverServer = new DiscoverServer();
discoverServer.init(discoverService);
}
}
public static void close() {
if (discoverService != null) {
discoverService.close();
}
if (discoverServer != null) {
discoverServer.close();
}
}
public static List getConnectableNodes() {
return discoverService.getConnectableNodes();
}
public static Node getHomeNode() {
return discoverService.getPublicHomeNode();
}
public static List getTableNodes() {
return discoverService.getTableNodes();
}
public static List getAllNodes() {
return discoverService.getAllNodes();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy