Search in sources :

Example 1 with SystemTimeProvider

use of tech.pegasys.teku.infrastructure.time.SystemTimeProvider in project teku by ConsenSys.

the class RepairCommand method getComputedSlot.

private UInt64 getComputedSlot(final Optional<AnchorPoint> initialAnchor, final Spec spec) {
    final TimeProvider timeProvider = new SystemTimeProvider();
    if (suppliedSlot != null) {
        displaySlotUpdateMessage(suppliedSlot, spec, "WARNING: using a supplied slot");
        return suppliedSlot;
    } else if (initialAnchor.isPresent()) {
        final UInt64 genesisTime = initialAnchor.get().getState().getGenesis_time();
        final int secondsPerEpoch = spec.getGenesisSpec().getSlotsPerEpoch() * spec.getGenesisSpec().getConfig().getSecondsPerSlot();
        final UInt64 oneEpochInFuture = timeProvider.getTimeInSeconds().plus(secondsPerEpoch);
        final UInt64 computedSlot = spec.getCurrentSlot(oneEpochInFuture, genesisTime);
        final String network = eth2NetworkOptions.getNetwork() == null ? "" : eth2NetworkOptions.getNetwork();
        displaySlotUpdateMessage(computedSlot, spec, "Computed " + network + " slot");
        return computedSlot;
    }
    SUB_COMMAND_LOG.exit(1, "Could not compute epoch, please supply an epoch to use for updating slashing protection.");
    throw new IllegalStateException("Should not have got past System.exit.");
}
Also used : SystemTimeProvider(tech.pegasys.teku.infrastructure.time.SystemTimeProvider) TimeProvider(tech.pegasys.teku.infrastructure.time.TimeProvider) SystemTimeProvider(tech.pegasys.teku.infrastructure.time.SystemTimeProvider) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64)

Aggregations

SystemTimeProvider (tech.pegasys.teku.infrastructure.time.SystemTimeProvider)1 TimeProvider (tech.pegasys.teku.infrastructure.time.TimeProvider)1 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)1