-
Notifications
You must be signed in to change notification settings - Fork 21
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
Replicate only missing transactions #443 #453
Replicate only missing transactions #443 #453
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The process to get the last local transaction address should also be done in the replication process. Maybe in TransactionContext.stream_transaction_chain
lib/archethic.ex
Outdated
""" | ||
@spec get_last_transaction_address_locally(address :: binary()) :: | ||
{:ok, binary()} | {:error, :not_found} | {:error, :network_issue} | ||
def get_last_transaction_address_locally(address) when is_binary(address) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function may be in TransactionChain module, same for get_genesis_transaction_address
, fetch_transaction_chain_locally
and available_loccaly?
as we request an information of a transaction chain
lib/archethic.ex
Outdated
def available_locally?(address) when is_binary(address) do | ||
case get_last_transaction_address_locally(address) do | ||
{:ok, last_address} -> {true, last_address} | ||
{:error, :not_found} -> {false, nil} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also catch {:error, :network_issue}
Also in case of wrong result, you can juste return false, nil is not used after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right
lib/archethic.ex
Outdated
|
||
chain_page = | ||
paging_address | ||
|> TransactionChain.stream_remotely(nodes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function aims to get the local transaction chain, but you get it remotely so it's not the local chain.
You should use TransactionChain.get
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am querying the same node via P2P.message abstraction.
It twill be more secure rather than directly querying the DB.
lib/archethic/transaction_chain.ex
Outdated
@doc """ | ||
Retrieve the genesis address of a chain | ||
""" | ||
@spec resolve_last_address(binary()) :: {:ok, binary()} | {:error, :network_issue} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spec definition so not martch the function name.
Same for fetch_genesis_address_remotely
36e9584
to
9689fc5
Compare
- included new method fetch chain efficiently - add checks before fetching txn chain - resolve tests
9d7c6cf
to
cbe81d5
Compare
Description
Fixes # (#443)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Checklist: