From 77f17dfc31394b6d34e2d1478e161da18ceb3f9b Mon Sep 17 00:00:00 2001 From: bchamagne Date: Tue, 19 Dec 2023 11:07:12 +0100 Subject: [PATCH] lint --- lib/archethic/mining/distributed_workflow.ex | 2 +- lib/archethic/mining/standalone_workflow.ex | 2 +- lib/archethic/mining/validation_context.ex | 9 +-------- lib/archethic/p2p/message/replicate_transaction.ex | 2 +- .../api/jsonrpc/methods/estimate_transaction_fee.ex | 9 +-------- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/lib/archethic/mining/distributed_workflow.ex b/lib/archethic/mining/distributed_workflow.ex index 28e314a1a..fe2fec28c 100644 --- a/lib/archethic/mining/distributed_workflow.ex +++ b/lib/archethic/mining/distributed_workflow.ex @@ -212,7 +212,7 @@ defmodule Archethic.Mining.DistributedWorkflow do P2P.list_nodes() else resolved_addresses - |> Enum.map(fn {_origin, resolved} -> resolved end) + |> Map.values() |> Election.io_storage_nodes(authorized_nodes) end diff --git a/lib/archethic/mining/standalone_workflow.ex b/lib/archethic/mining/standalone_workflow.ex index 0baef13ce..a4d951861 100644 --- a/lib/archethic/mining/standalone_workflow.ex +++ b/lib/archethic/mining/standalone_workflow.ex @@ -85,7 +85,7 @@ defmodule Archethic.Mining.StandaloneWorkflow do P2P.list_nodes() else resolved_addresses - |> Enum.map(fn {_origin, resolved} -> resolved end) + |> Map.values() |> Election.io_storage_nodes(authorized_nodes) end diff --git a/lib/archethic/mining/validation_context.ex b/lib/archethic/mining/validation_context.ex index ac59b973f..ec5abf074 100644 --- a/lib/archethic/mining/validation_context.ex +++ b/lib/archethic/mining/validation_context.ex @@ -1427,16 +1427,9 @@ defmodule Archethic.Mining.ValidationContext do defp resolved_recipients(recipients, resolved_addresses) do Enum.reduce(recipients, [], fn r = %Recipient{address: address}, acc -> - resolved = get_resolved_address_for_address(resolved_addresses, address) + resolved = Map.get(resolved_addresses, address) [%Recipient{r | address: resolved} | acc] end) |> Enum.reverse() end - - defp get_resolved_address_for_address(resolved_addresses, address) do - Enum.find_value(resolved_addresses, fn - {^address, resolved} -> resolved - _ -> false - end) - end end diff --git a/lib/archethic/p2p/message/replicate_transaction.ex b/lib/archethic/p2p/message/replicate_transaction.ex index 24cef1f9f..eef68d3c4 100644 --- a/lib/archethic/p2p/message/replicate_transaction.ex +++ b/lib/archethic/p2p/message/replicate_transaction.ex @@ -41,7 +41,7 @@ defmodule Archethic.P2P.Message.ReplicateTransaction do io_storage_nodes = resolved_addresses - |> Enum.map(fn {_origin, resolved} -> resolved end) + |> Map.values() |> Enum.concat([LedgerOperations.burning_address()]) |> Election.io_storage_nodes(P2P.authorized_and_available_nodes(validation_time)) diff --git a/lib/archethic_web/api/jsonrpc/methods/estimate_transaction_fee.ex b/lib/archethic_web/api/jsonrpc/methods/estimate_transaction_fee.ex index 820fcb570..a4b3a6c31 100644 --- a/lib/archethic_web/api/jsonrpc/methods/estimate_transaction_fee.ex +++ b/lib/archethic_web/api/jsonrpc/methods/estimate_transaction_fee.ex @@ -68,16 +68,9 @@ defmodule ArchethicWeb.API.JsonRPC.Method.EstimateTransactionFee do resolved_addresses = TransactionChain.resolve_transaction_addresses(tx, timestamp) Enum.reduce(recipients, [], fn r = %Recipient{address: address}, acc -> - resolved = get_resolved_address_for_address(resolved_addresses, address) + resolved = Map.get(resolved_addresses, address) [%Recipient{r | address: resolved} | acc] end) |> Enum.reverse() end - - defp get_resolved_address_for_address(resolved_addresses, address) do - Enum.find_value(resolved_addresses, fn - {^address, resolved} -> resolved - _ -> false - end) - end end