Search in sources :

Example 1 with EthereumChannelInitializer

use of org.ethereum.net.server.EthereumChannelInitializer in project rskj by rsksmart.

the class PeerClient method connectAsync.

public ChannelFuture connectAsync(String host, int port, String remoteId, boolean discoveryMode) {
    ethereumListener.trace("Connecting to: " + host + ":" + port);
    EthereumChannelInitializer ethereumChannelInitializer = ethereumChannelInitializerFactory.newInstance(remoteId);
    ethereumChannelInitializer.setPeerDiscoveryMode(discoveryMode);
    Bootstrap b = new Bootstrap();
    b.group(workerGroup);
    b.channel(NioSocketChannel.class);
    b.option(ChannelOption.SO_KEEPALIVE, true);
    b.option(ChannelOption.MESSAGE_SIZE_ESTIMATOR, DefaultMessageSizeEstimator.DEFAULT);
    b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.peerConnectionTimeout());
    b.remoteAddress(host, port);
    b.handler(ethereumChannelInitializer);
    // Start the client.
    return b.connect();
}
Also used : EthereumChannelInitializer(org.ethereum.net.server.EthereumChannelInitializer) Bootstrap(io.netty.bootstrap.Bootstrap)

Example 2 with EthereumChannelInitializer

use of org.ethereum.net.server.EthereumChannelInitializer in project rskj by rsksmart.

the class PeerClient method connectAsync.

public ChannelFuture connectAsync(String host, int port, String remoteId) {
    ethereumListener.trace("Connecting to: " + host + ":" + port);
    EthereumChannelInitializer ethereumChannelInitializer = ethereumChannelInitializerFactory.newInstance(remoteId);
    Bootstrap b = new Bootstrap();
    b.group(workerGroup);
    b.channel(NioSocketChannel.class);
    b.option(ChannelOption.SO_KEEPALIVE, true);
    b.option(ChannelOption.MESSAGE_SIZE_ESTIMATOR, DefaultMessageSizeEstimator.DEFAULT);
    b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.peerConnectionTimeout());
    b.remoteAddress(host, port);
    b.handler(ethereumChannelInitializer);
    // Start the client.
    return b.connect();
}
Also used : EthereumChannelInitializer(org.ethereum.net.server.EthereumChannelInitializer) Bootstrap(io.netty.bootstrap.Bootstrap)

Aggregations

Bootstrap (io.netty.bootstrap.Bootstrap)2 EthereumChannelInitializer (org.ethereum.net.server.EthereumChannelInitializer)2