@Test void streamIntermediateSteps_shouldStreamParentBlocksUpToInitialStartingPoint() { chainBuilder.generateBlocksUpToSlot(5); final List<Bytes32> expectedIntermediateSteps = chainBuilder .streamBlocksAndStates(3, 4) .map(SignedBlockAndState::getRoot) .collect(Collectors.toList()); Collections.reverse(expectedIntermediateSteps); final StateGenerationTask task = createTask(3, 5); final Stream<Bytes32> intermediateSteps = task.streamIntermediateSteps(); assertThat(intermediateSteps).containsExactlyElementsOf(expectedIntermediateSteps); }
@Override public Stream<Bytes32> streamIntermediateSteps() { final Bytes32 rootParent = tree.getParent(tree.getRootHash()).orElseThrow(); return Stream.iterate( tree.getParent(blockRoot), Optional::isPresent, current -> current.flatMap(tree::getParent)) .flatMap(Optional::stream) .filter(ancestorRoot -> !ancestorRoot.equals(rootParent)); }
StateGenerationTask implements CacheableTask<Bytes32, SignedBlockAndState> { @Override public Stream<Bytes32> streamIntermediateSteps() { final Bytes32 rootParent = tree.getParent(tree.getRootHash()).orElseThrow(); return Stream.iterate( tree.getParent(blockRoot), Optional::isPresent, current -> current.flatMap(tree::getParent)) .flatMap(Optional::stream) .filter(ancestorRoot -> !ancestorRoot.equals(rootParent)); } }
StateGenerationTask implements CacheableTask<Bytes32, SignedBlockAndState> { @Override public Stream<Bytes32> streamIntermediateSteps() { final Bytes32 rootParent = tree.getParent(tree.getRootHash()).orElseThrow(); return Stream.iterate( tree.getParent(blockRoot), Optional::isPresent, current -> current.flatMap(tree::getParent)) .flatMap(Optional::stream) .filter(ancestorRoot -> !ancestorRoot.equals(rootParent)); } StateGenerationTask(
      final Bytes32 blockRoot,
      final HashTree tree,
      final SignedBlockAndState baseBlockAndState,
      final Optional<Bytes32> epochBoundaryRoot,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateAndBlockProvider); }
StateGenerationTask implements CacheableTask<Bytes32, SignedBlockAndState> { @Override public Stream<Bytes32> streamIntermediateSteps() { final Bytes32 rootParent = tree.getParent(tree.getRootHash()).orElseThrow(); return Stream.iterate( tree.getParent(blockRoot), Optional::isPresent, current -> current.flatMap(tree::getParent)) .flatMap(Optional::stream) .filter(ancestorRoot -> !ancestorRoot.equals(rootParent)); } StateGenerationTask(
      final Bytes32 blockRoot,
      final HashTree tree,
      final SignedBlockAndState baseBlockAndState,
      final Optional<Bytes32> epochBoundaryRoot,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateAndBlockProvider); @Override Bytes32 getKey(); @Override Stream<Bytes32> streamIntermediateSteps(); @Override StateGenerationTask rebase(final SignedBlockAndState newBaseBlockAndState); @Override SafeFuture<Optional<SignedBlockAndState>> performTask(); }
StateGenerationTask implements CacheableTask<Bytes32, SignedBlockAndState> { @Override public Stream<Bytes32> streamIntermediateSteps() { final Bytes32 rootParent = tree.getParent(tree.getRootHash()).orElseThrow(); return Stream.iterate( tree.getParent(blockRoot), Optional::isPresent, current -> current.flatMap(tree::getParent)) .flatMap(Optional::stream) .filter(ancestorRoot -> !ancestorRoot.equals(rootParent)); } StateGenerationTask(
      final Bytes32 blockRoot,
      final HashTree tree,
      final SignedBlockAndState baseBlockAndState,
      final Optional<Bytes32> epochBoundaryRoot,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateAndBlockProvider); @Override Bytes32 getKey(); @Override Stream<Bytes32> streamIntermediateSteps(); @Override StateGenerationTask rebase(final SignedBlockAndState newBaseBlockAndState); @Override SafeFuture<Optional<SignedBlockAndState>> performTask();  }