Search in sources :

Example 1 with NodeStatsReport

use of org.hyperledger.besu.ethstats.report.NodeStatsReport in project besu by hyperledger.

the class EthStatsService method sendNodeStatsReport.

/**
 * Sends information about the node (is mining, is syncing, etc.)
 */
private void sendNodeStatsReport() {
    final boolean isMiningEnabled;
    if (miningCoordinator instanceof CliqueMiningCoordinator) {
        isMiningEnabled = ((CliqueMiningCoordinator) miningCoordinator).isSigner();
    } else {
        isMiningEnabled = miningCoordinator.isMining();
    }
    final boolean isSyncing = syncState.isInSync();
    final long gasPrice = suggestGasPrice(blockchainQueries.getBlockchain().getChainHeadBlock());
    final long hashrate = miningCoordinator.hashesPerSecond().orElse(0L);
    final int peersNumber = protocolManager.ethContext().getEthPeers().peerCount();
    final NodeStatsReport nodeStatsReport = ImmutableNodeStatsReport.builder().id(enodeURL.getNodeId().toHexString()).stats(true, isMiningEnabled, hashrate, peersNumber, gasPrice, isSyncing, 100).build();
    sendMessage(webSocket, new EthStatsRequest(STATS, nodeStatsReport));
}
Also used : CliqueMiningCoordinator(org.hyperledger.besu.consensus.clique.blockcreation.CliqueMiningCoordinator) EthStatsRequest(org.hyperledger.besu.ethstats.request.EthStatsRequest) ImmutableNodeStatsReport(org.hyperledger.besu.ethstats.report.ImmutableNodeStatsReport) NodeStatsReport(org.hyperledger.besu.ethstats.report.NodeStatsReport)

Aggregations

CliqueMiningCoordinator (org.hyperledger.besu.consensus.clique.blockcreation.CliqueMiningCoordinator)1 ImmutableNodeStatsReport (org.hyperledger.besu.ethstats.report.ImmutableNodeStatsReport)1 NodeStatsReport (org.hyperledger.besu.ethstats.report.NodeStatsReport)1 EthStatsRequest (org.hyperledger.besu.ethstats.request.EthStatsRequest)1