-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reorder some classes and split some parts of SyncProcessor
- Loading branch information
Showing
30 changed files
with
714 additions
and
697 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
rskj-core/src/main/java/co/rsk/net/sync/DecidingSyncState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package co.rsk.net.sync; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.time.Duration; | ||
|
||
public class DecidingSyncState implements SyncState { | ||
private Duration timeElapsed = Duration.ZERO; | ||
private PeersInformation knownPeers; | ||
private SyncConfiguration syncConfiguration; | ||
private SyncEventsHandler syncEventsHandler; | ||
|
||
public DecidingSyncState(SyncConfiguration syncConfiguration, SyncEventsHandler syncEventsHandler, PeersInformation knownPeers) { | ||
this.syncConfiguration = syncConfiguration; | ||
this.syncEventsHandler = syncEventsHandler; | ||
this.knownPeers = knownPeers; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public SyncStatesIds getId() { | ||
return SyncStatesIds.DECIDING; | ||
} | ||
|
||
@Override | ||
public void newPeerStatus() { | ||
if (knownPeers.count() >= syncConfiguration.getExpectedPeers()) { | ||
syncEventsHandler.canStartSyncing(); | ||
} | ||
} | ||
|
||
@Override | ||
public void tick(Duration duration) { | ||
timeElapsed = timeElapsed.plus(duration); | ||
if (knownPeers.count() > 0 && | ||
timeElapsed.compareTo(syncConfiguration.getTimeoutWaitingPeers()) >= 0) { | ||
|
||
syncEventsHandler.canStartSyncing(); | ||
} | ||
} | ||
} |
50 changes: 0 additions & 50 deletions
50
rskj-core/src/main/java/co/rsk/net/sync/DecidingSyncStatus.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
rskj-core/src/main/java/co/rsk/net/sync/FindingConnectionPointSyncStatus.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
rskj-core/src/main/java/co/rsk/net/sync/SyncEventsHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package co.rsk.net.sync; | ||
|
||
public interface SyncEventsHandler { | ||
void canStartSyncing(); | ||
void stopSyncing(); | ||
} |
Oops, something went wrong.