Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Reduce log level when block miner is interrupted #1006

Merged
merged 4 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ public void cancel() {
isCancelled.set(true);
}

@Override
public boolean isCancelled() {
return isCancelled.get();
}

protected void throwIfStopped() throws CancellationException {
if (isCancelled.get()) {
throw new CancellationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
public interface AsyncBlockCreator extends BlockCreator {

void cancel();

boolean isCancelled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ public BlockMiner(
public void run() {

boolean blockMined = false;
while (!blockMined) {
while (!blockMined && !blockCreator.isCancelled()) {
try {
blockMined = mineBlock();
} catch (final CancellationException ex) {
LOG.debug("Block creation process cancelled.");
break;
} catch (final InterruptedException ex) {
LOG.error("Block mining was interrupted.", ex);
LOG.debug("Block mining was interrupted.", ex);
Thread.currentThread().interrupt();
} catch (final Exception ex) {
LOG.error("Block mining threw an unhandled exception.", ex);
}
Expand Down