Skip to content

Commit

Permalink
Set before? flag to true for all beacon election
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix committed Apr 7, 2023
1 parent 521df5f commit 4cec057
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
11 changes: 8 additions & 3 deletions lib/archethic/beacon_chain.ex
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,12 @@ defmodule Archethic.BeaconChain do
if unsubscribe?, do: Update.unsubscribe()

Enum.map(list_subsets(), fn subset ->
nodes = Election.beacon_storage_nodes(subset, date, P2P.authorized_and_available_nodes())
nodes =
Election.beacon_storage_nodes(
subset,
date,
P2P.authorized_and_available_nodes(date, true)
)

nodes =
Enum.reject(nodes, fn node -> node.first_public_key == Crypto.first_node_public_key() end)
Expand Down Expand Up @@ -330,10 +335,10 @@ defmodule Archethic.BeaconChain do
@spec list_transactions_summaries_from_current_slot(DateTime.t()) ::
list(TransactionSummary.t())
def list_transactions_summaries_from_current_slot(date = %DateTime{} \\ DateTime.utc_now()) do
authorized_nodes = P2P.authorized_and_available_nodes()

next_summary_date = next_summary_date(DateTime.truncate(date, :millisecond))

authorized_nodes = P2P.authorized_and_available_nodes(next_summary_date, true)

# get the subsets to request per node
list_subsets()
|> Enum.map(fn subset ->
Expand Down
2 changes: 1 addition & 1 deletion lib/archethic/beacon_chain/network_coordinates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ defmodule Archethic.BeaconChain.NetworkCoordinates do
"""
@spec fetch_network_stats(DateTime.t()) :: Nx.Tensor.t()
def fetch_network_stats(summary_time = %DateTime{}) do
authorized_nodes = P2P.authorized_and_available_nodes()
authorized_nodes = P2P.authorized_and_available_nodes(summary_time, true)

sorted_node_list = P2P.list_nodes() |> Enum.sort_by(& &1.first_public_key)
nb_nodes = length(sorted_node_list)
Expand Down
2 changes: 1 addition & 1 deletion lib/archethic/beacon_chain/slot.ex
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ defmodule Archethic.BeaconChain.Slot do
"""
@spec involved_nodes(t()) :: list(Node.t())
def involved_nodes(%__MODULE__{subset: subset, slot_time: slot_time}) do
node_list = P2P.authorized_and_available_nodes(slot_time)
node_list = P2P.authorized_and_available_nodes(slot_time, true)

Election.beacon_storage_nodes(
subset,
Expand Down
8 changes: 5 additions & 3 deletions lib/archethic/beacon_chain/subset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,14 @@ defmodule Archethic.BeaconChain.Subset do

tx_summary_message = TransactionSummaryMessage.from_transaction_summary(tx_summary)

next_slot_time = BeaconChain.next_slot(timestamp)

# Do not notify beacon storage nodes as they are already aware of the transaction
beacon_storage_nodes =
Election.beacon_storage_nodes(
BeaconChain.subset_from_address(address),
BeaconChain.next_slot(timestamp),
P2P.authorized_and_available_nodes(timestamp)
next_slot_time,
P2P.authorized_and_available_nodes(next_slot_time, true)
)
|> Enum.map(& &1.first_public_key)

Expand Down Expand Up @@ -428,7 +430,7 @@ defmodule Archethic.BeaconChain.Subset do
end

defp beacon_summary_node?(subset, summary_time, node_public_key) do
node_list = P2P.authorized_and_available_nodes(summary_time)
node_list = P2P.authorized_and_available_nodes(summary_time, true)

Election.beacon_storage_nodes(
subset,
Expand Down

0 comments on commit 4cec057

Please sign in to comment.