-
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
rename scan to scan_with_keychain #1117
Changes from all commits
7e91849
2fa5fc6
9655e31
2a9a2e0
25fb58a
95d0826
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,59 +139,47 @@ pub trait ElectrumExt { | |
/// | ||
/// - `prev_tip`: the most recent blockchain tip present locally | ||
/// - `keychain_spks`: keychains that we want to scan transactions for | ||
/// - `txids`: transactions for which we want updated [`Anchor`]s | ||
/// - `outpoints`: transactions associated with these outpoints (residing, spending) that we | ||
/// want to included in the update | ||
/// | ||
/// The scan for each keychain stops after a gap of `stop_gap` script pubkeys with no associated | ||
/// transactions. `batch_size` specifies the max number of script pubkeys to request for in a | ||
/// single batch request. | ||
448-OG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fn scan<K: Ord + Clone>( | ||
/// Note that scanning with keychain is very inefficient and should be used only when restoring | ||
/// from seed words. | ||
fn scan_with_keychain<K: Ord + Clone>( | ||
&self, | ||
prev_tip: Option<CheckPoint>, | ||
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>, | ||
txids: impl IntoIterator<Item = Txid>, | ||
outpoints: impl IntoIterator<Item = OutPoint>, | ||
448-OG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
stop_gap: usize, | ||
batch_size: usize, | ||
) -> Result<(ElectrumUpdate, BTreeMap<K, u32>), Error>; | ||
|
||
/// Convenience method to call [`scan`] without requiring a keychain. | ||
/// Convenience method to call [`scan_with_keychain`] without requiring a keychain. | ||
/// | ||
/// [`scan`]: ElectrumExt::scan | ||
fn scan_without_keychain( | ||
/// [`scan_with_keychain`]: ElectrumExt::scan_with_keychain | ||
fn sync( | ||
448-OG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
&self, | ||
prev_tip: Option<CheckPoint>, | ||
misc_spks: impl IntoIterator<Item = ScriptBuf>, | ||
txids: impl IntoIterator<Item = Txid>, | ||
outpoints: impl IntoIterator<Item = OutPoint>, | ||
_txids: impl IntoIterator<Item = Txid>, | ||
_outpoints: impl IntoIterator<Item = OutPoint>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why don't we completely remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are used in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
batch_size: usize, | ||
) -> Result<ElectrumUpdate, Error> { | ||
let spk_iter = misc_spks | ||
.into_iter() | ||
.enumerate() | ||
.map(|(i, spk)| (i as u32, spk)); | ||
|
||
let (electrum_update, _) = self.scan( | ||
prev_tip, | ||
[((), spk_iter)].into(), | ||
txids, | ||
outpoints, | ||
usize::MAX, | ||
batch_size, | ||
)?; | ||
let (electrum_update, _) = | ||
self.scan_with_keychain(prev_tip, [((), spk_iter)].into(), usize::MAX, batch_size)?; | ||
|
||
Ok(electrum_update) | ||
} | ||
} | ||
|
||
impl ElectrumExt for Client { | ||
fn scan<K: Ord + Clone>( | ||
fn scan_with_keychain<K: Ord + Clone>( | ||
&self, | ||
prev_tip: Option<CheckPoint>, | ||
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>, | ||
txids: impl IntoIterator<Item = Txid>, | ||
outpoints: impl IntoIterator<Item = OutPoint>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we are removing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes the separate method is |
||
stop_gap: usize, | ||
batch_size: usize, | ||
) -> Result<(ElectrumUpdate, BTreeMap<K, u32>), Error> { | ||
|
@@ -201,8 +189,8 @@ impl ElectrumExt for Client { | |
.collect::<BTreeMap<K, _>>(); | ||
let mut scanned_spks = BTreeMap::<(K, u32), (ScriptBuf, bool)>::new(); | ||
|
||
let txids = txids.into_iter().collect::<Vec<_>>(); | ||
let outpoints = outpoints.into_iter().collect::<Vec<_>>(); | ||
let txids = Vec::<_>::new(); | ||
let outpoints = Vec::<_>::new(); | ||
|
||
let (electrum_update, keychain_update) = loop { | ||
let (tip, _) = construct_update_tip(self, prev_tip.clone())?; | ||
|
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 these changes on coin selection slipped in because of the rebase. You have to remove them. There is more other files. Just cross check
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.
These changes were as a result of running clippy. If you run clippy on master you will get recommendations to remove them. Since in rust tuple struct
LargestFirstCoinSelection
you dont need to call::default()
to initialize itThere 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.
Generally it's better to handle fixing clippy changes in a separate commit or PR to make the review easier. Also a nit on commit messages, instead of
BREAKING CHANGE:
I'd use the notationrefactor!(<module name>): ...
. See: https://www.conventionalcommits.org/en/v1.0.0/And as @LLFourn mentioned we may end up incorporating this rename into another PR but if you have time it wouldn't hurt to fix this one up in case we can use it.