Skip to content

Commit

Permalink
Add Logger when forward fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix committed Jun 30, 2023
1 parent 4be6582 commit ac890d1
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions lib/archethic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ defmodule Archethic do
)
end

defp forward_transaction(tx, welcome_node_key, contract_context) do
defp forward_transaction(
tx = %Transaction{address: address, type: type},
welcome_node_key,
contract_context
) do
%Node{network_patch: welcome_node_patch} = P2P.get_node_info!(welcome_node_key)

nodes =
Expand All @@ -157,13 +161,22 @@ defmodule Archethic do

TaskSupervisor
|> Task.Supervisor.start_child(fn ->
:ok =
%NewTransaction{
transaction: tx,
welcome_node: welcome_node_key,
contract_context: contract_context
}
|> do_forward_transaction(nodes)
message = %NewTransaction{
transaction: tx,
welcome_node: welcome_node_key,
contract_context: contract_context
}

case do_forward_transaction(message, nodes) do
{:error, _} ->
Logger.warning("Forward transaction did not succeed",
transaction_address: Base.encode16(address),
transaction_type: type
)

_ ->
:ok
end
end)

:ok
Expand Down

0 comments on commit ac890d1

Please sign in to comment.