-
Notifications
You must be signed in to change notification settings - Fork 329
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
Simplified EsploraExt
API
#1380
Conversation
1bb6193
to
abddc33
Compare
abddc33
to
f04207d
Compare
@notmandatory ready for you to base #1194 on! |
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.
Left some comments so I can understand a few things better before giving a full review.
I finished rebasing #1194 on this PR and everything is working fine. |
@notmandatory I forgot to mention I also need to rebase this PR on master 😬 |
e59a142
to
a9aa7c4
Compare
91e8c91
to
bf74f18
Compare
eaebdee
to
e5c81a2
Compare
76e1d97
to
954b6b5
Compare
This creates a checkpoint linked list which contains all blocks.
Previously, we would update the `TxGraph` and `KeychainTxOutIndex` first, then create a second update for `LocalChain`. This required locking the receiving structures 3 times (instead of twice, which is optimal). This PR eliminates this requirement by making use of the new `query` method of `CheckPoint`. Examples are also updated to use the new API.
These methods are no longer needed as we can determine missing heights directly from the `CheckPoint` tip.
This gets the genesis hash of the env blockchain.
We ensure that calling `finalize_chain_update` does not result in a chain which removed previous heights and all anchor heights are included.
Since we want to keep these methods private.
Co-authored-by: LLFourn <[email protected]>
64bc6ca
to
7554b1a
Compare
Co-authored-by: LLFourn <[email protected]>
7554b1a
to
72fe65b
Compare
690cccb
to
a504a1d
Compare
The intention is to remove the `Update::introduce_older_blocks` parameter and update the local chain directly with `CheckPoint`. This simplifies the API and there is a way to do this efficiently.
a504a1d
to
77d3595
Compare
`merge_chains` now returns a tuple of the resultant checkpoint AND changeset. This is arguably a more readable/understandable setup. To do this, we had to create `CheckPoint::apply_changeset` which is kept as a private method. Thank you @ValuedMammal for the suggestion. Co-authored-by: valuedvalued mammal <[email protected]>
877f728
to
96a9aa6
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 96a9aa6
Fixes #1354
Description
Built on top of both #1369 and #1373, we simplify the
EsploraExt
API by removing theupdate_local_chain
method and havingfull_scan
andsync
update the local chain in the same call. Thefull_scan
andsync
methods now takes in an additional input (local_tip
) which provides us with the view of theLocalChain
before the update. These methods now return structsFullScanUpdate
andSyncUpdate
.The examples are updated to use this new API.
TxGraph::missing_heights
andtx_graph::ChangeSet::missing_heights_from
are no longer needed, therefore they are removed.Additionally, we used this opportunity to simplify the logic which updates
LocalChain
. We got rid of thelocal_chain::Update
struct (which contained the updateCheckPoint
tip and abool
which signaled whether we want to introduce blocks below point of agreement). It turns out we can use something likeCheckPoint::insert
so the chain source can craft an update based on the old tip. This way, we can make better use ofmerge_chains
' optimization that compares theArc
pointers of the local and update chain (before we were crafting the update chain NOT based on top of the previous local chain). With this, we no longer need theUpdate::introduce_older_block
field since the logic will naturally break when we reach a matchingArc
pointer.Notes to the reviewers
LocalChain
's update now happens withinEsploraExt::full_scan
andEsploraExt::sync
. Creating theLocalChain
update is now split into two methods (fetch_latest_blocks
andchain_update
) that are called before and after fetching transactions and anchors.bdk_esplora
. One for blocking and one for async.Changelog notice
EsploraExt
API so that sync only requires one round of fetching data. Thelocal_chain_update
method is removed and thelocal_tip
parameter is added to thefull_scan
andsync
methods.TxGraph::missing_heights
andtx_graph::ChangeSet::missing_heights_from
methods.CheckPoint::insert
which allows convenient checkpoint-insertion. This is intended for use by chain-sources when crafting an update.merge_chains
to also return the resultantCheckPoint
tip.LocalChain
logic - use the updateCheckPoint
as the newCheckPoint
tip when possible.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features: