@Test void shouldStartNonFinalizedSyncWhenNoSuitableFinalizedTargetChainAvailable() { when(finalizedChainSelector.selectTargetChain(false)).thenReturn(Optional.empty()); when(nonfinalizedChainSelector.selectTargetChain(false)).thenReturn(Optional.of(targetChain)); when(sync.syncToChain(targetChain)).thenReturn(new SafeFuture<>()); onTargetChainsUpdated(); ignoreFuture(verify(sync).syncToChain(targetChain)); }
public void onTargetChainsUpdated() { eventThread.checkOnEventThread(); final boolean currentlySyncing = isSyncActive(); final Optional<InProgressSync> newSync = selectNewSyncTarget(currentlySyncing); if (newSync.isEmpty() && currentlySyncing) { return; } if (!currentlySyncing && newSync.isPresent()) { notifySubscribers(true); } currentSync = newSync; }
SyncController { public void onTargetChainsUpdated() { eventThread.checkOnEventThread(); final boolean currentlySyncing = isSyncActive(); final Optional<InProgressSync> newSync = selectNewSyncTarget(currentlySyncing); if (newSync.isEmpty() && currentlySyncing) { return; } if (!currentlySyncing && newSync.isPresent()) { notifySubscribers(true); } currentSync = newSync; } }
SyncController { public void onTargetChainsUpdated() { eventThread.checkOnEventThread(); final boolean currentlySyncing = isSyncActive(); final Optional<InProgressSync> newSync = selectNewSyncTarget(currentlySyncing); if (newSync.isEmpty() && currentlySyncing) { return; } if (!currentlySyncing && newSync.isPresent()) { notifySubscribers(true); } currentSync = newSync; } SyncController(
      final EventThread eventThread,
      final Executor subscriberExecutor,
      final RecentChainData recentChainData,
      final ChainSelector finalizedTargetChainSelector,
      final ChainSelector nonfinalizedTargetChainSelector,
      final Sync sync); }
SyncController { public void onTargetChainsUpdated() { eventThread.checkOnEventThread(); final boolean currentlySyncing = isSyncActive(); final Optional<InProgressSync> newSync = selectNewSyncTarget(currentlySyncing); if (newSync.isEmpty() && currentlySyncing) { return; } if (!currentlySyncing && newSync.isPresent()) { notifySubscribers(true); } currentSync = newSync; } SyncController(
      final EventThread eventThread,
      final Executor subscriberExecutor,
      final RecentChainData recentChainData,
      final ChainSelector finalizedTargetChainSelector,
      final ChainSelector nonfinalizedTargetChainSelector,
      final Sync sync); void onTargetChainsUpdated(); boolean isSyncActive(); SyncingStatus getSyncStatus(); long subscribeToSyncChanges(final SyncSubscriber subscriber); void unsubscribeFromSyncChanges(final long subscriberId); }
SyncController { public void onTargetChainsUpdated() { eventThread.checkOnEventThread(); final boolean currentlySyncing = isSyncActive(); final Optional<InProgressSync> newSync = selectNewSyncTarget(currentlySyncing); if (newSync.isEmpty() && currentlySyncing) { return; } if (!currentlySyncing && newSync.isPresent()) { notifySubscribers(true); } currentSync = newSync; } SyncController(
      final EventThread eventThread,
      final Executor subscriberExecutor,
      final RecentChainData recentChainData,
      final ChainSelector finalizedTargetChainSelector,
      final ChainSelector nonfinalizedTargetChainSelector,
      final Sync sync); void onTargetChainsUpdated(); boolean isSyncActive(); SyncingStatus getSyncStatus(); long subscribeToSyncChanges(final SyncSubscriber subscriber); void unsubscribeFromSyncChanges(final long subscriberId);  }