@Test public void shouldHandleSingleStep() { final StateRootRecorder stateRootRecorder = new StateRootRecorder(slot, (stateRoot, slot) -> stateRoots.put(slot, stateRoot)); stateRootRecorder.acceptNextState(state); assertThat(stateRoots).containsOnlyKeys(slot); }
public void acceptNextState(final BeaconState state) { if (slot.plus(slotsPerHistoricalRoot).compareTo(state.getSlot()) < 0) { final UInt64 floor = state.getSlot().minus(slotsPerHistoricalRoot); LOG.warn("Missing state root mappings from slot {} to {}", slot, floor); slot = floor; } while (slot.compareTo(state.getSlot()) < 0) { stateRootConsumer.accept( state.getState_roots().get(slot.mod(slotsPerHistoricalRoot).intValue()), slot); slot = slot.plus(UInt64.ONE); } stateRootConsumer.accept(state.hash_tree_root(), state.getSlot()); }
StateRootRecorder { public void acceptNextState(final BeaconState state) { if (slot.plus(slotsPerHistoricalRoot).compareTo(state.getSlot()) < 0) { final UInt64 floor = state.getSlot().minus(slotsPerHistoricalRoot); LOG.warn("Missing state root mappings from slot {} to {}", slot, floor); slot = floor; } while (slot.compareTo(state.getSlot()) < 0) { stateRootConsumer.accept( state.getState_roots().get(slot.mod(slotsPerHistoricalRoot).intValue()), slot); slot = slot.plus(UInt64.ONE); } stateRootConsumer.accept(state.hash_tree_root(), state.getSlot()); } }
StateRootRecorder { public void acceptNextState(final BeaconState state) { if (slot.plus(slotsPerHistoricalRoot).compareTo(state.getSlot()) < 0) { final UInt64 floor = state.getSlot().minus(slotsPerHistoricalRoot); LOG.warn("Missing state root mappings from slot {} to {}", slot, floor); slot = floor; } while (slot.compareTo(state.getSlot()) < 0) { stateRootConsumer.accept( state.getState_roots().get(slot.mod(slotsPerHistoricalRoot).intValue()), slot); slot = slot.plus(UInt64.ONE); } stateRootConsumer.accept(state.hash_tree_root(), state.getSlot()); } StateRootRecorder(final UInt64 slot, final BiConsumer<Bytes32, UInt64> stateRootConsumer); }
StateRootRecorder { public void acceptNextState(final BeaconState state) { if (slot.plus(slotsPerHistoricalRoot).compareTo(state.getSlot()) < 0) { final UInt64 floor = state.getSlot().minus(slotsPerHistoricalRoot); LOG.warn("Missing state root mappings from slot {} to {}", slot, floor); slot = floor; } while (slot.compareTo(state.getSlot()) < 0) { stateRootConsumer.accept( state.getState_roots().get(slot.mod(slotsPerHistoricalRoot).intValue()), slot); slot = slot.plus(UInt64.ONE); } stateRootConsumer.accept(state.hash_tree_root(), state.getSlot()); } StateRootRecorder(final UInt64 slot, final BiConsumer<Bytes32, UInt64> stateRootConsumer); void acceptNextState(final BeaconState state); }
StateRootRecorder { public void acceptNextState(final BeaconState state) { if (slot.plus(slotsPerHistoricalRoot).compareTo(state.getSlot()) < 0) { final UInt64 floor = state.getSlot().minus(slotsPerHistoricalRoot); LOG.warn("Missing state root mappings from slot {} to {}", slot, floor); slot = floor; } while (slot.compareTo(state.getSlot()) < 0) { stateRootConsumer.accept( state.getState_roots().get(slot.mod(slotsPerHistoricalRoot).intValue()), slot); slot = slot.plus(UInt64.ONE); } stateRootConsumer.accept(state.hash_tree_root(), state.getSlot()); } StateRootRecorder(final UInt64 slot, final BiConsumer<Bytes32, UInt64> stateRootConsumer); void acceptNextState(final BeaconState state);  }