|
|
|
@ -14,8 +14,6 @@ |
|
|
|
|
*/ |
|
|
|
|
package org.hyperledger.besu.ethereum.blockcreation; |
|
|
|
|
|
|
|
|
|
import static org.apache.logging.log4j.LogManager.getLogger; |
|
|
|
|
|
|
|
|
|
import org.hyperledger.besu.ethereum.chain.BlockAddedEvent; |
|
|
|
|
import org.hyperledger.besu.ethereum.chain.BlockAddedObserver; |
|
|
|
|
import org.hyperledger.besu.ethereum.chain.Blockchain; |
|
|
|
@ -33,7 +31,6 @@ import java.util.List; |
|
|
|
|
import java.util.Optional; |
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
|
|
|
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
|
|
import org.apache.tuweni.bytes.Bytes; |
|
|
|
|
|
|
|
|
|
public abstract class AbstractMiningCoordinator< |
|
|
|
@ -46,13 +43,11 @@ public abstract class AbstractMiningCoordinator< |
|
|
|
|
STOPPED |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static final Logger LOG = getLogger(); |
|
|
|
|
|
|
|
|
|
private final Subscribers<MinedBlockObserver> minedBlockObservers = Subscribers.create(); |
|
|
|
|
private final Subscribers<EthHashObserver> ethHashObservers = Subscribers.create(); |
|
|
|
|
private final AbstractMinerExecutor<M> executor; |
|
|
|
|
private final SyncState syncState; |
|
|
|
|
private final Blockchain blockchain; |
|
|
|
|
protected final Blockchain blockchain; |
|
|
|
|
|
|
|
|
|
private State state = State.IDLE; |
|
|
|
|
private boolean isEnabled = false; |
|
|
|
@ -181,10 +176,10 @@ public abstract class AbstractMiningCoordinator< |
|
|
|
|
void inSyncChanged(final boolean inSync) { |
|
|
|
|
synchronized (this) { |
|
|
|
|
if (inSync && startMiningIfPossible()) { |
|
|
|
|
LOG.info("Resuming mining operations"); |
|
|
|
|
onResumeMining(); |
|
|
|
|
} |
|
|
|
|
if (!inSync && haltCurrentMiningOperation()) { |
|
|
|
|
LOG.info("Pausing mining while behind chain head"); |
|
|
|
|
onPauseMining(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|