Wallet sync with the mempool after initial sync#2016
Open
Conversation
c21e435 to
f75e2ee
Compare
f75e2ee to
e9d5aa3
Compare
ImplOfAnImpl
approved these changes
Feb 20, 2026
Comment on lines
+111
to
+135
| token_fee = 1000 | ||
| coins_to_send = 1 | ||
| token_fee_output = { | ||
| "Transfer": [ | ||
| {"Coin": token_fee * ATOMS_PER_COIN}, | ||
| { | ||
| "PublicKey": { | ||
| "key": {"Secp256k1Schnorr": {"pubkey_data": pub_key_bytes}} | ||
| } | ||
| }, | ||
| ], | ||
| } | ||
| tx_fee_output = { | ||
| "Transfer": [ | ||
| {"Coin": coins_to_send * ATOMS_PER_COIN}, | ||
| { | ||
| "PublicKey": { | ||
| "key": {"Secp256k1Schnorr": {"pubkey_data": pub_key_bytes}} | ||
| } | ||
| }, | ||
| ], | ||
| } | ||
| encoded_tx, tx_id = make_tx( | ||
| [reward_input(tip_id)], [token_fee_output] + [tx_fee_output] * 2, 0 | ||
| ) |
Contributor
There was a problem hiding this comment.
- There are no tokens involved in this test.
- The duplication of tx_fee_output looks arbitrary, is it really needed?
I assume this all is due to copy-pasting? Plz clean the test up.
P.S. I can see the same happens in wallet_mempool_events.py, which was added recently. I guess it's also due to copy-paste, if so, plz clean it up too.
| wallet_events: W, | ||
|
|
||
| mempool_events: MempoolEvents, | ||
| finished_initial_sync: bool, |
Contributor
There was a problem hiding this comment.
Use SetFlag to make sure it can only go from false to true?
| if let Err(err) = | ||
| self.wallet.add_mempool_transactions(&txs, &self.wallet_events) | ||
| { | ||
| log::error!("Txs from mempool failed to be added in the wallet because of an error: {err}"); |
Contributor
There was a problem hiding this comment.
"to the wallet".
But IMO it's' too wordy, something like "Error adding mempool transactions: {err}" would be better.
| } | ||
| } | ||
| Err(err) => { | ||
| log::error!("Failed to fetch all transactios from the mempool: {err}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After opening or creating a new wallet and finishing the initial sync with chainstate, fetch and add all transactions from the mempool before proceeding to process mempool events. This will handle any missed transaction events from the mempool while the wallet was closed.