-
Notifications
You must be signed in to change notification settings - Fork 321
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
Update bdk_electrum
crate to use sync/full-scan structs
#1403
Update bdk_electrum
crate to use sync/full-scan structs
#1403
Conversation
53ed564
to
9033e0e
Compare
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.
Looking good so far.
I made a note related to adding the client
as a parameter to determine_tx_anchor
- you may have already considered this. I see you mentioned potentially doing more batch calls, which is a good idea assuming we can ensure the results are in order consistent with the request.
side note: the commit message could use an extra newline after the subject and before the body.
6f39514
to
bb84d8f
Compare
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.
It's great that the API is simplified now. However, with the current changes, every call to ElectrumExt::full_scan
forces us to download every full tx?
EDIT: Ahh, I see your TODOs in your description.
d008d31
to
2540258
Compare
For the commit message, remember to put a new line between first line and body. |
It seems that you intended the sync flow to be:
However, the downsides of this approach is the following:
Hence, I think it is better to have a transaction cache |
077ea56
to
2905f09
Compare
2905f09
to
49c0c4e
Compare
f0278f5
to
a39a7e9
Compare
RelevantTxids
and track txs in TxGraph
bdk_electrum
crate to use sync/full-scan structs
fdffdd0
to
93a4ae6
Compare
6628855
to
4ccd86a
Compare
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.
ACK 4ccd86a
This comment has been minimized.
This comment has been minimized.
This PR removes `RelevantTxids` from the electrum crate and tracks transactions in a `TxGraph`. This removes the need to separately construct a `TxGraph` after a `full_scan` or `sync`.
When we insert a transaction that is already wrapped in `Arc`, we should reuse the `Arc`.
This transaction cache can be provided so the chain-source can avoid re-fetching transactions.
This needs a rebase, merging #1203 broke this. |
`ElectrumResultExt` trait is also introduced that adds methods which can convert the `Anchor` type for the update `TxGraph`. We also make use of the new `TxCache` fields in `SyncRequest`/`FullScanRequest`. This way, we can avoid re-fetching full transactions from Electrum if not needed. Examples and tests are updated to use the new `ElectrumExt` API.
* Syncing with `example_electrum` now shows progress as a percentage. * Flush stdout more aggressively.
This is more code, but a much more elegant solution than having `ElectrumExt` methods return `SyncResult`/`FullScanResult` and having an `ElectrumResultExt` extention trait.
The previous `TxOut` for transactions received from an external wallet may be optionally added as floating `TxOut`s to `TxGraph` to allow for fee calculation.
323bfc7
to
92fb6cb
Compare
Helper method docs are updated to explain what they are updating. Logic is simplified as we do not need to check whether a tx exists already in `update_graph` before inserting it.
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.
ACK b45897e
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.
ACK b45897e
Tested with examples: example_electrum
and wallet_electrum
Fixes #1265
Possibly fixes #1419
Context
Previous changes such as
CheckPoint
linked list query-able (PR feat(chain): addget
andrange
methods toCheckPoint
#1369)Transaction
s cheaply-clonable (PR Wrap transactions asArc<Transaction>
inTxGraph
#1373)has allowed us to simplify the interaction between chain-source and receiving-structures (
bdk_chain
).The motivation is to accomplish something like this (as mentioned here):
Description
This PR greatly simplifies the API of our Electrum chain-source (
bdk_electrum
) by making use of the aforementioned changes. Instead of referring back to the receivingTxGraph
mid-sync/scan to determine which full transaction to fetch, we provide the Electrum chain-source already-fetched full transactions to start sync/scan (this is cheap, as transactions are wrapped inArc
s since #1373).In addition, an option has been added to include the previous
TxOut
for transactions received from an external wallet for fee calculation.Changelog notice
TxGraph::insert_tx
to take in anything that satisfiesInto<Arc<Transaction>>
. This allows us to reuse theArc
pointer of what is being inserted.tx_cache
field toSyncRequest
andFullScanRequest
.Anchor
type inFullScanResult
generic for more flexibility.ElectrumExt
methods to take inSyncRequest
/FullScanRequest
and returnSyncResult
/FullScanResult
. Also update electrum examples accordingly.ElectrumResultExt
trait which allows us to convert the updateTxGraph
ofSyncResult
/FullScanResult
forbdk_electrum
.full_scan
andsync
to also fetch previousTxOut
s to allow for fee calculation.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features: