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

[NC-1384] Disable mining while catching up to chain head #125

Merged
merged 27 commits into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ea115ae
[NC-1384] refactoring so we can making block creation depend on eth s…
Errorific Oct 17, 2018
fb73bf3
[NC-1384] dependency issues fixed for distance from head to be discer…
Errorific Oct 19, 2018
5e68c1b
[NC-1384] Changed to passing around the SyncState
Errorific Oct 22, 2018
8216e13
[NC-1384] worked to have a chain of subscribers to get the sync status
Errorific Oct 22, 2018
4df3cf5
[NC-1384] synchronised fixes
Errorific Oct 22, 2018
e2e208d
[NC-1384] tests for chainstate observer
Errorific Oct 22, 2018
1253614
Merge branch 'master' of github.com:PegaSysEng/pantheon into NC-1384
ajsutton Oct 23, 2018
495df3c
[NC-1384] Fix the build.
ajsutton Oct 23, 2018
5094e4b
[NC-1384] Simplify test with mocks. Use the more idiomatic java "lis…
ajsutton Oct 23, 2018
5a259f4
[NC-1384] Ensure we unsubscribe from chain height updates when the sy…
ajsutton Oct 23, 2018
d297b0d
[NC-1384] Fix thread safety in SyncState and ensure we fire an inSync…
ajsutton Oct 23, 2018
17846f3
[NC-1384] Better thread safety fix and avoid exposing BlockAddedObser…
ajsutton Oct 23, 2018
5901910
[NC-1384] Remove PendingBlocks from SyncState.
ajsutton Oct 23, 2018
d17231f
[NC-1384] Add a simple way to check if a BlockAddedEvent results in a…
ajsutton Oct 23, 2018
f469863
[NC-1384] SyncState only needs EthPeers not the whole EthContext.
ajsutton Oct 23, 2018
9b0cb7a
[NC-1384] Treat the absence of a sync target as being in-sync because…
ajsutton Oct 23, 2018
4a5410c
[NC-1384] Use a custom interface for InSyncListener for clarity.
ajsutton Oct 23, 2018
7f0d1fc
[NC-1384] Add tests for SyncState.
ajsutton Oct 23, 2018
783e35a
[NC-1384] Back to using synchronized to ensure the check for current …
ajsutton Oct 23, 2018
355c107
[NC-1384] Add tests for AbstractMiningCoordinator and avoid starting …
ajsutton Oct 23, 2018
c8ee9f2
[NC-1384] Report mining as disabled while we are out of sync.
ajsutton Oct 23, 2018
d184c98
Merge branch 'master' of github.com:PegaSysEng/pantheon into NC-1384
ajsutton Oct 23, 2018
9be5a9b
[NC-1384] Provide a few blocks tolerance with head so we don't interr…
ajsutton Oct 23, 2018
2e69e89
[NC-1384] Get the logic the right way round.
ajsutton Oct 23, 2018
37d52ec
[NC-1384] Remove unused method.
ajsutton Oct 23, 2018
12165e9
Merge branch 'master' of github.com:PegaSysEng/pantheon into NC-1384
ajsutton Oct 24, 2018
1bd840a
Make InSyncListener an inner class since it didn't wind up warranting…
ajsutton Oct 24, 2018
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
Prev Previous commit
Next Next commit
[NC-1384] synchronised fixes
  • Loading branch information
Errorific committed Oct 22, 2018
commit 4df3cf53ba80c074de707031ede4c3a7b6612107
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,20 @@ public void onBlockAdded(final BlockAddedEvent event, final Blockchain blockchai
synchronized (this) {
if (isEnabled && shouldStartNewMiner(event)) {
haltCurrentMiningOperation();
if (syncState.getInSync()) {
if (syncState.isInSync()) {
startAsyncMiningOperation();
}
}
}
}

public void inSyncChanged(final boolean inSync) {
if (isEnabled && inSync) {
startAsyncMiningOperation();
} else if (!inSync) {
haltCurrentMiningOperation();
synchronized (this) {
if (isEnabled && inSync) {
startAsyncMiningOperation();
} else if (!inSync) {
haltCurrentMiningOperation();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
import com.google.common.base.MoreObjects;

public class ChainState {

public interface EstimatedHeightObserver {
void estimatedHeightChanged(long newHeight);
}

// The best block by total difficulty that we know about
private final BestBlock bestBlock = new BestBlock();
// The highest block that we've seen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ public SyncTarget setSyncTarget(final EthPeer peer, final BlockHeader commonAnce
}

private void checkInSync() {
final boolean newInSync = getInSync();
final boolean newInSync = isInSync();

if (newInSync != lastInSync) {
lastInSync = newInSync;
inSyncSubscribers.forEach(c -> c.accept(newInSync));
}
}

public boolean getInSync() {
public boolean isInSync() {
return syncTarget
.map(t -> t.estimatedTargetHeight() <= blockchain.getChainHeadBlockNumber())
.orElse(false);
Expand Down