From dbced77ae48efc0a4448b586f84d9603fa6ee539 Mon Sep 17 00:00:00 2001 From: Neylix Date: Tue, 18 Oct 2022 16:32:16 +0200 Subject: [PATCH] Fix fee calculation crashing on log10(0) --- lib/archethic/mining/fee.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/archethic/mining/fee.ex b/lib/archethic/mining/fee.ex index a8cff7330..b671a22a9 100644 --- a/lib/archethic/mining/fee.ex +++ b/lib/archethic/mining/fee.ex @@ -72,8 +72,8 @@ defmodule Archethic.Mining.Fee do ) do with {:ok, json} <- Jason.decode(content), "non-fungible" <- Map.get(json, "type", "fungible"), - utxos when is_list(utxos) <- Map.get(json, "collection") do - nb_utxos = length(utxos) + utxos when is_list(utxos) <- Map.get(json, "collection"), + nb_utxos when nb_utxos > 0 <- length(utxos) do base_fee = minimum_fee(uco_price_in_usd) (:math.log10(nb_utxos) + 1) * nb_utxos * base_fee else