pub struct KeyScanner { /* private fields */ }Expand description
Incremental key scanner using EC point addition.
KeyScanner efficiently generates sequential keys by adding or subtracting
a constant value from a base key, which is faster than generating random keys.
§Example
use rustywallet_batch::prelude::*;
use rustywallet_keys::prelude::PrivateKey;
let base = PrivateKey::from_hex(
"0000000000000000000000000000000000000000000000000000000000000001"
).unwrap();
// Scan forward from base key
let scanner = KeyScanner::new(base.clone())
.direction(ScanDirection::Forward);
for key in scanner.scan_range(10) {
println!("{}", key.unwrap().to_hex());
}
// Scan backward
let scanner = KeyScanner::new(base)
.direction(ScanDirection::Backward);Implementations§
Source§impl KeyScanner
impl KeyScanner
Sourcepub fn new(base_key: PrivateKey) -> Self
pub fn new(base_key: PrivateKey) -> Self
Create a new key scanner starting from the given base key.
Sourcepub fn direction(self, direction: ScanDirection) -> Self
pub fn direction(self, direction: ScanDirection) -> Self
Set the scanning direction.
Sourcepub fn scan_range(self, count: usize) -> KeyStream ⓘ
pub fn scan_range(self, count: usize) -> KeyStream ⓘ
Scan a range of keys starting from the base key.
Returns a KeyStream that yields keys incrementally.
Sourcepub fn scan_until<F>(self, predicate: F) -> KeyStream ⓘ
pub fn scan_until<F>(self, predicate: F) -> KeyStream ⓘ
Scan keys until a predicate returns true.
Returns a KeyStream that yields keys until the predicate matches.
Trait Implementations§
Source§impl Clone for KeyScanner
impl Clone for KeyScanner
Source§fn clone(&self) -> KeyScanner
fn clone(&self) -> KeyScanner
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for KeyScanner
impl RefUnwindSafe for KeyScanner
impl Send for KeyScanner
impl Sync for KeyScanner
impl Unpin for KeyScanner
impl UnwindSafe for KeyScanner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more