Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix replication chain ingestion #821

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/archethic/replication.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,19 @@ defmodule Archethic.Replication do
tx
|> stream_previous_chain(download_nodes)
|> Stream.reject(&Enum.empty?/1)
|> Stream.each(&TransactionChain.write/1)
|> Stream.flat_map(& &1)
|> Stream.each(fn tx = %Transaction{address: address} ->
TransactionChain.write_transaction(tx)

# There is some case where a transaction is not replicated while it should
# because of some latency or network issue. So when we replicate a past chain
# we also ingest the transaction if we are storage node of it

if address
samuelmanzanera marked this conversation as resolved.
Show resolved Hide resolved
|> Election.chain_storage_nodes(download_nodes)
|> Utils.key_in_node_list?(Crypto.first_node_public_key()),
do: ingest_transaction(tx, false)
end)
|> Stream.run()

TransactionChain.write_transaction(tx)
Expand Down