Skip to content

Commit

Permalink
remove pmap
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorv-2204 committed Aug 18, 2022
1 parent e31956e commit 8eb1a90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
17 changes: 8 additions & 9 deletions lib/archethic/bootstrap.ex
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,8 @@ defmodule Archethic.Bootstrap do
nodes = Archethic.P2P.authorized_and_available_nodes()
Logger.debug("Resync Starting")

Archethic.Utils.async_no_link_pmap(
type_list,
&fn type = &1 ->
Logger.debug("Resync #{type}")

Enum.each(type_list, fn type ->
Task.Supervisor.async_nolink(Archethic.TaskSupervisor, fn ->
try do
TransactionChain.list_addresses_by_type(type)
|> Enum.at(0)
Expand All @@ -237,14 +234,16 @@ defmodule Archethic.Bootstrap do
:ok
rescue
error ->
Logger.debug("Resync of chain #{type} failed #{error} ")
Logger.debug("Resync Nodes did not respond", error: error)

:ok
end
end
)
end)
end)
rescue
error ->
Logger.debug("Resync failed nodes NA. #{error}")
Logger.debug("Resync Failed - Nodes N/A ", error: error)

:ok
end
end
Expand Down
7 changes: 0 additions & 7 deletions lib/archethic/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,4 @@ defmodule Archethic.Utils do
end)
end)
end

@spec async_no_link_pmap(any, any) :: list
def async_no_link_pmap(collection, func) do
collection
|> Enum.map(&Task.Supervisor.async_nolink(Archethic.TaskSupervisor, fn -> func.(&1) end))
|> Task.await_many()
end
end

0 comments on commit 8eb1a90

Please sign in to comment.