Skip to content

Commit

Permalink
Fix TransactionInput.set_spent to compare only using from and type
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmanzanera authored and Neylix committed Mar 8, 2024
1 parent 2635749 commit ae07c88
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/archethic/transaction_chain/transaction_input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,8 @@ defmodule Archethic.TransactionChain.TransactionInput do
"""
@spec set_spent(t(), list(t())) :: t()
def set_spent(input = %__MODULE__{}, genesis_inputs) do
spent? =
genesis_inputs
|> MapSet.new()
|> MapSet.member?(input)
|> Kernel.not()

def set_spent(input = %__MODULE__{type: type, from: from}, genesis_inputs) do
spent? = not Enum.any?(genesis_inputs, &(&1.type == type and &1.from == from))
%{input | spent?: spent?}
end
end

0 comments on commit ae07c88

Please sign in to comment.