Search in sources :

Example 1 with PeerExplorer

use of co.rsk.net.discovery.PeerExplorer in project rskj by rsksmart.

the class DefaultConfig method peerExplorer.

@Bean
public PeerExplorer peerExplorer(RskSystemProperties rskConfig) {
    ECKey key = rskConfig.getMyKey();
    Node localNode = new Node(key.getNodeId(), rskConfig.getPublicIp(), rskConfig.getPeerPort());
    NodeDistanceTable distanceTable = new NodeDistanceTable(KademliaOptions.BINS, KademliaOptions.BUCKET_SIZE, localNode);
    long msgTimeOut = rskConfig.peerDiscoveryMessageTimeOut();
    long refreshPeriod = rskConfig.peerDiscoveryRefreshPeriod();
    List<String> initialBootNodes = rskConfig.peerDiscoveryIPList();
    List<Node> activePeers = rskConfig.peerActive();
    if (CollectionUtils.isNotEmpty(activePeers)) {
        for (Node n : activePeers) {
            InetSocketAddress address = n.getAddress();
            initialBootNodes.add(address.getHostName() + ":" + address.getPort());
        }
    }
    return new PeerExplorer(initialBootNodes, localNode, distanceTable, key, msgTimeOut, refreshPeriod);
}
Also used : NodeDistanceTable(co.rsk.net.discovery.table.NodeDistanceTable) PeerExplorer(co.rsk.net.discovery.PeerExplorer) InetSocketAddress(java.net.InetSocketAddress) Node(org.ethereum.net.rlpx.Node) ECKey(org.ethereum.crypto.ECKey) Bean(org.springframework.context.annotation.Bean)

Aggregations

PeerExplorer (co.rsk.net.discovery.PeerExplorer)1 NodeDistanceTable (co.rsk.net.discovery.table.NodeDistanceTable)1 InetSocketAddress (java.net.InetSocketAddress)1 ECKey (org.ethereum.crypto.ECKey)1 Node (org.ethereum.net.rlpx.Node)1 Bean (org.springframework.context.annotation.Bean)1