-
Notifications
You must be signed in to change notification settings - Fork 30
docs(wallet): add sync
operation to bdk_wallet
examples
#274
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
base: master
Are you sure you want to change the base?
Conversation
sync
operation to bdk_wallet
examples for electrum
and esplora
sync
operation to bdk_wallet
examples
Pull Request Test Coverage Report for Build 16172743430Details
💛 - Coveralls |
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.
cACK 8e1a6ef
I left a few comments that I think are applicable. Also, I was unable to test the electrum example locally (I guess it's a local problem on my end).
I think it's a good opportunity to also add a forced eviction, and show that to the user. WDYT?
Any reason to not add the sync usage to blocking esplora example ?
client.populate_tx_cache(wallet.tx_graph().full_txs().map(|tx_node| tx_node.tx)); | ||
|
||
let sync_update = client.sync(sync_request, BATCH_SIZE, false)?; | ||
wallet.apply_update(sync_update)?; |
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 think it's a good idea to also persist here. wdyt ?
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.
Oh yes, I will do that. Thank you!
.inspect(|sync_item, sync_progress| { | ||
let progress_percent = | ||
(100 * sync_progress.consumed()) as f32 / sync_progress.total() as f32; | ||
eprintln!("[ SCANNING {:03.0}%] {}", progress_percent, sync_item) |
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.
Good! I personally think this approach is good, but I'm wondering if it's too verbose.
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.
Okay
@@ -92,5 +97,29 @@ fn main() -> Result<(), anyhow::Error> { | |||
client.transaction_broadcast(&tx)?; | |||
println!("Tx broadcasted! Txid: {}", tx.compute_txid()); | |||
|
|||
println!("=== Performing Partial Sync ==="); | |||
std::io::stdout().flush().expect("must flush"); |
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.
Is this strictly needed?
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 do think so because the progress update may appear before the performing partial sync
message if it is not flushed (when using eprintln
). I will update this, so it is consistent.
Alright, I will do that.
No reason, I will also add that. Thank you for the review. I will make updates. |
98cb6b9
to
4130f46
Compare
I have added the eviction logic that identifies transactions that were unconfirmed before a partial sync but are no longer canonical after the sync.
I have also added the sync to the esplora blocking example. Another thing I considered was reducing the output of the full scan by a multiple of say 5 or 10 as it is getting lengthy. |
- add partial syncing to electrum, esplora_async and esplora_blocking examples - add applying evicted txns to wallet in electrum, esplora_async and esplora_blocking examples
4130f46
to
50dacbf
Compare
Description
This PR adds
sync
operation tobdk_wallet
examples forelectrum
andesplora
clients.Fixes #253
Checklists
All Submissions:
just p
before pushing