@Test void shouldNotResetOnChainSwitchWhenBlocksDoNotLineUpBecauseOfIncompleteBatches() { assertThat(sync.syncToChain(targetChain)).isNotDone(); targetChain = chainWith( new SlotAndBlockRoot(UInt64.valueOf(2000), dataStructureUtil.randomBytes32()), syncSource); assertThat(sync.syncToChain(targetChain)).isNotDone(); final Batch batch0 = batches.get(0); final Batch batch1 = batches.get(1); final Batch batch2 = batches.get(2); final SignedBeaconBlock batch0Block = chainBuilder.generateBlockAtSlot(batch0.getLastSlot()).getBlock(); chainBuilder.generateBlockAtSlot(batch2.getLastSlot()); batches.receiveBlocks(batch0, batch0Block); batches.receiveBlocks(batch1); final Batch batch5 = batches.get(5); assertThat(batch5.getTargetChain()).isEqualTo(targetChain); final SignedBeaconBlock batch5Block = chainBuilder.generateBlockAtSlot(batch5.getLastSlot()).getBlock(); batches.receiveBlocks(batch5, batch5Block); assertNoBatchesImported(); assertThatBatch(batch0).isNotContested(); assertThatBatch(batch1).isNotContested(); assertThatBatch(batch5).isNotContested(); assertBatchActive(batch0); assertBatchActive(batch1); assertBatchActive(batch5); }
@Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } private  BatchSync(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchChain activeBatches,
      final BatchImporter batchImporter,
      final BatchDataRequester batchDataRequester); }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } private  BatchSync(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchChain activeBatches,
      final BatchImporter batchImporter,
      final BatchDataRequester batchDataRequester); static BatchSync create(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchImporter batchImporter,
      final BatchFactory batchFactory,
      final UInt64 batchSize); @Override SafeFuture<SyncResult> syncToChain(final TargetChain targetChain); }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } private  BatchSync(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchChain activeBatches,
      final BatchImporter batchImporter,
      final BatchDataRequester batchDataRequester); static BatchSync create(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchImporter batchImporter,
      final BatchFactory batchFactory,
      final UInt64 batchSize); @Override SafeFuture<SyncResult> syncToChain(final TargetChain targetChain);  }