Skip to content

Commit 9d2afab

Browse files
committed
fix: handle negative elapsed time
1 parent cf7f38f commit 9d2afab

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/lambda_ethereum_consensus/beacon/beacon_chain.ex

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,17 @@ defmodule LambdaEthereumConsensus.Beacon.BeaconChain do
170170
def handle_info(:on_tick, state) do
171171
schedule_next_tick()
172172
time = :os.system_time(:second)
173-
ForkChoice.on_tick(time)
174-
175-
# TODO: reduce time between ticks to account for gnosis' 5s slot time.
176-
old_logical_time = compute_logical_time(state)
177173
new_state = %BeaconChainState{state | time: time}
178-
new_logical_time = compute_logical_time(new_state)
179174

180-
if old_logical_time != new_logical_time do
181-
notify_subscribers(new_logical_time)
175+
if time >= state.genesis_time do
176+
ForkChoice.on_tick(time)
177+
# TODO: reduce time between ticks to account for gnosis' 5s slot time.
178+
old_logical_time = compute_logical_time(state)
179+
new_logical_time = compute_logical_time(new_state)
180+
181+
if old_logical_time != new_logical_time do
182+
notify_subscribers(new_logical_time)
183+
end
182184
end
183185

184186
{:noreply, new_state}

0 commit comments

Comments
 (0)