@Test void shouldHandleValidChainFromGenesis() throws Exception { final SignedBlockAndState genesis = chainBuilder.generateGenesis(); chainBuilder.generateBlocksUpToSlot(10); final List<SignedBlockAndState> newBlocksAndStates = chainBuilder .streamBlocksAndStates(genesis.getSlot().plus(UInt64.ONE), chainBuilder.getLatestSlot()) .collect(Collectors.toList()); final SignedBlockAndState lastBlockAndState = newBlocksAndStates.get(newBlocksAndStates.size() - 1); final BeaconState result = StreamingStateRegenerator.regenerate( genesis.getState(), newBlocksAndStates.stream().map(SignedBlockAndState::getBlock)); assertThat(result).isEqualTo(lastBlockAndState.getState()); }
public static BeaconState regenerate( final BeaconState initialState, final Stream<SignedBeaconBlock> blocks) { final StreamingStateRegenerator regenerator = new StreamingStateRegenerator(initialState); blocks.forEach(regenerator::processBlock); return regenerator.state; }
StreamingStateRegenerator { public static BeaconState regenerate( final BeaconState initialState, final Stream<SignedBeaconBlock> blocks) { final StreamingStateRegenerator regenerator = new StreamingStateRegenerator(initialState); blocks.forEach(regenerator::processBlock); return regenerator.state; } }
StreamingStateRegenerator { public static BeaconState regenerate( final BeaconState initialState, final Stream<SignedBeaconBlock> blocks) { final StreamingStateRegenerator regenerator = new StreamingStateRegenerator(initialState); blocks.forEach(regenerator::processBlock); return regenerator.state; } private  StreamingStateRegenerator(final BeaconState preState); }
StreamingStateRegenerator { public static BeaconState regenerate( final BeaconState initialState, final Stream<SignedBeaconBlock> blocks) { final StreamingStateRegenerator regenerator = new StreamingStateRegenerator(initialState); blocks.forEach(regenerator::processBlock); return regenerator.state; } private  StreamingStateRegenerator(final BeaconState preState); static BeaconState regenerate(
      final BeaconState initialState, final Stream<SignedBeaconBlock> blocks); }
StreamingStateRegenerator { public static BeaconState regenerate( final BeaconState initialState, final Stream<SignedBeaconBlock> blocks) { final StreamingStateRegenerator regenerator = new StreamingStateRegenerator(initialState); blocks.forEach(regenerator::processBlock); return regenerator.state; } private  StreamingStateRegenerator(final BeaconState preState); static BeaconState regenerate(
      final BeaconState initialState, final Stream<SignedBeaconBlock> blocks);  }