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));
}
Aggregations