use of org.hyperledger.besu.consensus.clique.blockcreation.CliqueMiningCoordinator in project besu by hyperledger.
the class CliqueBesuControllerBuilder method createMiningCoordinator.
@Override
protected MiningCoordinator createMiningCoordinator(final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final TransactionPool transactionPool, final MiningParameters miningParameters, final SyncState syncState, final EthProtocolManager ethProtocolManager) {
final CliqueMinerExecutor miningExecutor = new CliqueMinerExecutor(protocolContext, protocolSchedule, transactionPool.getPendingTransactions(), nodeKey, miningParameters, new CliqueBlockScheduler(clock, protocolContext.getConsensusContext(CliqueContext.class).getValidatorProvider(), localAddress, secondsBetweenBlocks), epochManager);
final CliqueMiningCoordinator miningCoordinator = new CliqueMiningCoordinator(protocolContext.getBlockchain(), miningExecutor, syncState, new CliqueMiningTracker(localAddress, protocolContext));
miningCoordinator.addMinedBlockObserver(ethProtocolManager);
// Clique mining is implicitly enabled.
miningCoordinator.enable();
return miningCoordinator;
}
use of org.hyperledger.besu.consensus.clique.blockcreation.CliqueMiningCoordinator 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