@@ -46,9 +46,7 @@ defmodule Archethic.TransactionChain do
4646 FirstTransactionAddress
4747 }
4848
49- alias __MODULE__ . MemTables.KOLedger
5049 alias __MODULE__ . MemTables.PendingLedger
51- # alias __MODULE__.MemTablesLoader
5250
5351 alias __MODULE__ . Transaction
5452 alias __MODULE__ . TransactionData
@@ -160,28 +158,17 @@ defmodule Archethic.TransactionChain do
160158
161159 @ doc """
162160 Get a transaction
163-
164- A lookup is performed into the KO ledger to determine if the transaction is invalid
165161 """
166162 @ spec get_transaction ( binary ( ) , fields :: list ( ) ) ::
167- { :ok , Transaction . t ( ) }
168- | { :error , :transaction_not_exists }
169- | { :error , :invalid_transaction }
170- def get_transaction ( address , fields \\ [ ] , storage_type \\ :chain ) when is_list ( fields ) do
171- if KOLedger . has_transaction? ( address ) do
172- { :error , :invalid_transaction }
173- else
174- DB . get_transaction ( address , fields , storage_type )
175- end
176- end
163+ { :ok , Transaction . t ( ) } | { :error , :transaction_not_exists }
164+ def get_transaction ( address , fields \\ [ ] , storage_type \\ :chain ) when is_list ( fields ) ,
165+ do: DB . get_transaction ( address , fields , storage_type )
177166
178167 @ doc """
179168 Get the last transaction from a given chain address
180169 """
181170 @ spec get_last_transaction ( binary ( ) , list ( ) ) ::
182- { :ok , Transaction . t ( ) }
183- | { :error , :transaction_not_exists }
184- | { :error , :invalid_transaction }
171+ { :ok , Transaction . t ( ) } | { :error , :transaction_not_exists }
185172 def get_last_transaction ( address , fields \\ [ ] ) when is_binary ( address ) and is_list ( fields ) do
186173 { address , _ } = get_last_address ( address )
187174 get_transaction ( address , fields )
@@ -258,13 +245,6 @@ defmodule Archethic.TransactionChain do
258245 @ spec get_size ( binary ( ) ) :: non_neg_integer ( )
259246 defdelegate get_size ( address ) , to: DB , as: :chain_size
260247
261- @ doc """
262- Get the details from a ko transaction address
263- """
264- @ spec get_ko_details ( binary ( ) ) ::
265- { ValidationStamp . t ( ) , inconsistencies :: list ( ) , errors :: list ( ) }
266- defdelegate get_ko_details ( address ) , to: KOLedger , as: :get_details
267-
268248 @ doc """
269249 List of all the counter signatures regarding a given transaction
270250 """
@@ -365,11 +345,7 @@ defmodule Archethic.TransactionChain do
365345 address :: Crypto . prepended_hash ( ) ,
366346 storage_nodes :: list ( Node . t ( ) ) ,
367347 opts :: search_options ( )
368- ) ::
369- { :ok , Transaction . t ( ) }
370- | { :error , :transaction_not_exists }
371- | { :error , :invalid_transaction }
372- | { :error , :network_issue }
348+ ) :: { :ok , Transaction . t ( ) } | { :error , :transaction_not_exists } | { :error , :network_issue }
373349 def fetch_transaction ( address , nodes , opts \\ [ ] ) do
374350 with :hybrid <- Keyword . get ( opts , :search_mode , :hybrid ) ,
375351 { :ok , tx } <- get_transaction ( address ) do
@@ -424,14 +400,8 @@ defmodule Archethic.TransactionChain do
424400 timeout: timeout ,
425401 acceptance_resolver: acceptance_resolver
426402 ) do
427- { :ok , % NotFound { } } ->
428- { :error , :transaction_not_exists }
429-
430- { :ok , % Error { } } ->
431- { :error , :invalid_transaction }
432-
433- res ->
434- res
403+ { :ok , % NotFound { } } -> { :error , :transaction_not_exists }
404+ res -> res
435405 end
436406 end
437407 end
@@ -1064,30 +1034,18 @@ defmodule Archethic.TransactionChain do
10641034 storage_type \\ :chain
10651035 ) do
10661036 DB . write_transaction ( tx , storage_type )
1067- |> tap ( fn _ ->
1068- KOLedger . remove_transaction ( address )
1037+ |> tap ( fn
1038+ :ok ->
1039+ Logger . info ( "Transaction stored" ,
1040+ transaction_address: Base . encode16 ( address ) ,
1041+ transaction_type: type
1042+ )
10691043
1070- Logger . info ( "Transaction stored" ,
1071- transaction_address: Base . encode16 ( address ) ,
1072- transaction_type: type
1073- )
1044+ _ ->
1045+ :skip
10741046 end )
10751047 end
10761048
1077- @ doc """
1078- Write an invalid transaction
1079- """
1080- @ spec write_ko_transaction ( transaction :: Transaction . t ( ) , errors :: list ( ) ) :: :ok
1081- defdelegate write_ko_transaction ( tx , additional_errors \\ [ ] ) ,
1082- to: KOLedger ,
1083- as: :add_transaction
1084-
1085- @ doc """
1086- Determine if the transaction already be validated and is invalid
1087- """
1088- @ spec transaction_ko? ( address :: binary ( ) ) :: boolean ( )
1089- defdelegate transaction_ko? ( address ) , to: KOLedger , as: :has_transaction?
1090-
10911049 @ doc """
10921050 Determine if a transaction address has already sent a counter signature (approval) to another transaction
10931051 """
0 commit comments