Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions lib/ae_mdw/sync/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -491,22 +491,31 @@ defmodule AeMdw.Sync.Server do
|> List.flatten()
|> maybe_add_accounts_balance_mutations()

{{height, _mbi}, _block, _mutations} = List.last(blocks_mutations)
Log.info("[sync_mem] exec until height=#{height}")
# An empty batch (no blocks to apply - e.g. a resume/extension check that
# turns out to have nothing new past the already-synced height) is a
# legitimate no-op, not an error - List.last/1 would return nil and crash
# the match below if this weren't guarded.
case List.last(blocks_mutations) do
nil ->
state

{{height, _mbi}, _block, _mutations} ->
Log.info("[sync_mem] exec until height=#{height}")

{ts, new_state} =
:timer.tc(fn ->
all_mutations =
Enum.map(blocks_mutations, fn {_height, _block, mutations} -> mutations end)

{ts, new_state} =
:timer.tc(fn ->
all_mutations =
Enum.map(blocks_mutations, fn {_height, _block, mutations} -> mutations end)
State.commit_mem(state, all_mutations)
end)

State.commit_mem(state, all_mutations)
end)
:ok = profile_sync("sync_mem", height, ts, blocks_mutations, gens_in_batch)

:ok = profile_sync("sync_mem", height, ts, blocks_mutations, gens_in_batch)
broadcast_blocks(gens_mutations)

broadcast_blocks(gens_mutations)

new_state
new_state
end
end

defp spawn_task(fun) do
Expand Down
Loading