Search in sources :

Example 1 with CliqueMiningCoordinator

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;
}
Also used : CliqueMiningCoordinator(org.hyperledger.besu.consensus.clique.blockcreation.CliqueMiningCoordinator) CliqueMinerExecutor(org.hyperledger.besu.consensus.clique.blockcreation.CliqueMinerExecutor) CliqueMiningTracker(org.hyperledger.besu.consensus.clique.CliqueMiningTracker) CliqueBlockScheduler(org.hyperledger.besu.consensus.clique.blockcreation.CliqueBlockScheduler) CliqueContext(org.hyperledger.besu.consensus.clique.CliqueContext)

Example 2 with CliqueMiningCoordinator

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));
}
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)2 CliqueContext (org.hyperledger.besu.consensus.clique.CliqueContext)1 CliqueMiningTracker (org.hyperledger.besu.consensus.clique.CliqueMiningTracker)1 CliqueBlockScheduler (org.hyperledger.besu.consensus.clique.blockcreation.CliqueBlockScheduler)1 CliqueMinerExecutor (org.hyperledger.besu.consensus.clique.blockcreation.CliqueMinerExecutor)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