Skip to content

Commit

Permalink
Subset code_change
Browse files Browse the repository at this point in the history
  • Loading branch information
bchamagne committed Feb 16, 2024
1 parent a59424b commit 8a9603f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lib/archethic/beacon_chain/subset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Archethic.BeaconChain.Subset do
alias Archethic.Utils

use GenServer
@vsn 1
@vsn 2

require Logger

Expand Down Expand Up @@ -99,6 +99,28 @@ defmodule Archethic.BeaconChain.Subset do
}}
end

# update the TransactionSummary in memory
def code_change(1, state, _extra) do
state =
update_in(
state,
[Access.key!(:current_slot), Access.key!(:transaction_attestations)],
fn attestations ->
Enum.map(
attestations,
fn attestation = %ReplicationAttestation{transaction_summary: summary} ->
%ReplicationAttestation{
attestation
| transaction_summary: struct(TransactionSummary, Map.from_struct(summary))
}
end
)
end
)

{:ok, state}
end

def code_change(_, state, _extra), do: {:ok, state}

def handle_call(:get_current_slot, _from, state = %{current_slot: current_slot}) do
Expand Down

0 comments on commit 8a9603f

Please sign in to comment.