Search in sources :

Example 1 with NodeInfo

use of org.hyperledger.besu.ethstats.authentication.NodeInfo in project besu by hyperledger.

the class EthStatsService method sendHello.

/**
 * Sends a hello request to the ethstats server in order to log in.
 */
private void sendHello() {
    try {
        final Optional<Integer> port = enodeURL.getListeningPort();
        final Optional<BigInteger> chainId = genesisConfigOptions.getChainId();
        if (port.isPresent() && chainId.isPresent()) {
            final String os = PlatformDetector.getOSType();
            final String arch = PlatformDetector.getArch();
            final NodeInfo nodeInfo = ImmutableNodeInfo.of(netstatsUrl.getNodeName(), clientVersion, String.valueOf(port.get()), chainId.get().toString(), protocolManager.getSupportedCapabilities().toString(), "No", os, arch, "0.1.1", true, netstatsUrl.getContact());
            final EthStatsRequest hello = new EthStatsRequest(HELLO, ImmutableAuthenticationData.of(enodeURL.getNodeId().toHexString(), nodeInfo, netstatsUrl.getSecret()));
            sendMessage(webSocket, hello, isSucceeded -> {
                if (!isSucceeded) {
                    retryConnect();
                }
            });
        } else {
            throw new NoSuchElementException();
        }
    } catch (NoSuchElementException e) {
        LOG.error("Failed to find required parameters for ethstats request : {}", e.getMessage());
        retryConnect();
    }
}
Also used : BigInteger(java.math.BigInteger) EthStatsRequest(org.hyperledger.besu.ethstats.request.EthStatsRequest) ImmutableNodeInfo(org.hyperledger.besu.ethstats.authentication.ImmutableNodeInfo) NodeInfo(org.hyperledger.besu.ethstats.authentication.NodeInfo) BigInteger(java.math.BigInteger) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

BigInteger (java.math.BigInteger)1 NoSuchElementException (java.util.NoSuchElementException)1 ImmutableNodeInfo (org.hyperledger.besu.ethstats.authentication.ImmutableNodeInfo)1 NodeInfo (org.hyperledger.besu.ethstats.authentication.NodeInfo)1 EthStatsRequest (org.hyperledger.besu.ethstats.request.EthStatsRequest)1