Skip to content
Snippets Groups Projects
Commit 83c05d00 authored by ABDELGHANI Nassim's avatar ABDELGHANI Nassim Committed by ABDELGHANI Nassim
Browse files

check size before checking transaction rules

parent 69a9c2cb
No related branches found
No related tags found
1 merge request!46Resolve "Validation locale"
......@@ -36,8 +36,10 @@ defmodule IndexRules do
# Rule: For each OutputBase:
# if BaseDelta > 0, then it must be inferior or equal to the sum of all preceding BaseDelta
# Rule: The sum of all inputs in CommonBase must equal the sum of all outputs in CommonBase
if :ets.info(local_sindex)[:size] > 0 do
commonBase =
:ets.match(local_sindex, {:_, %{base: :"$1"}})
|> IO.inspect()
|> Enum.map(fn [base] -> String.to_integer(base) end)
|> Enum.min()
......@@ -93,6 +95,9 @@ defmodule IndexRules do
else
false
end
else
true
end
end
defp getTransactionDepth(local_sindex, txHash, local_depth) do
......@@ -119,11 +124,15 @@ defmodule IndexRules do
end
defp checkMaxTransactionChainingDepth(local_sindex) do
if :ets.info(local_sindex)[:size] > 0 do
:ets.match(local_sindex, {:_, %{tx: :"$1"}})
|> Enum.map(fn [txHash] -> txHash end)
|> Enum.uniq()
|> Enum.map(fn txHash -> getTransactionDepth(local_sindex, txHash, 0) end)
|> Enum.max() <= 5
else
true
end
end
def check(local_iindex, local_mindex, local_cindex, local_sindex) do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment