pub struct Tracker { /* private fields */ }Expand description
Tracker of a set of Address, indexing and counting registrations
§Implementation design
Each Address is stored internally as a ScriptPubKey.
This prevents inter-network duplication and optimizes UTXOs filtering efficiency.
But consequently the address network prefix gets lost and must be globally provided when querying for addresses by indexes.
Implementations§
Source§impl Tracker
impl Tracker
Sourcepub const MAX_ADDRESS_UPPER_BOUND: usize = 14_680_063usize
pub const MAX_ADDRESS_UPPER_BOUND: usize = 14_680_063usize
The upper bound of the maximum address count
Sourcepub const DEFAULT_MAX_ADDRESSES: usize = 1_835_007usize
pub const DEFAULT_MAX_ADDRESSES: usize = 1_835_007usize
Expanded count for a maximum of 1M addresses
Sourcepub const fn expand_max_addresses(max_addresses: usize) -> usize
pub const fn expand_max_addresses(max_addresses: usize) -> usize
Computes the optimal expanded max address count fitting in the actual allocated size of the internal storage structure
Sourcepub fn new(max_addresses: Option<usize>) -> Self
pub fn new(max_addresses: Option<usize>) -> Self
Creates a new Tracker instance. If max_addresses is Some, uses it to prealloc
the internal index as well as for bounding the index size. Otherwise, performs no
prealloc while bounding the index size by Tracker::DEFAULT_MAX_ADDRESSES
pub fn data(&self) -> TrackerReadGuard<'_>
pub fn get(&self, spk: &ScriptPublicKey) -> Option<(Index, RefCount)>
pub fn get_address(&self, address: &Address) -> Option<(Index, RefCount)>
pub fn get_address_at_index( &self, index: Index, prefix: Prefix, ) -> Option<Address>
pub fn contains<T: Indexer>(&self, indexes: &T, spk: &ScriptPublicKey) -> bool
pub fn contains_address<T: Indexer>( &self, indexes: &T, address: &Address, ) -> bool
Sourcepub fn unregistering_indexes(
&self,
indexes: &Indexes,
addresses: &[Address],
) -> Indexes
pub fn unregistering_indexes( &self, indexes: &Indexes, addresses: &[Address], ) -> Indexes
Returns an index set containing the indexes of all the addresses both registered in the tracker and in indexes.
Sourcepub fn register<T: Indexer>(
&self,
indexes: &mut T,
addresses: Vec<Address>,
) -> Result<Vec<Address>>
pub fn register<T: Indexer>( &self, indexes: &mut T, addresses: Vec<Address>, ) -> Result<Vec<Address>>
Tries to register an Address vector into an Indexer. The addresses are first registered in the tracker if unknown
yet and their reference count is increased when successfully inserted in the Indexer.
On success, returns the addresses that were actually inserted in the Indexer.
Fails if the maximum capacity gets reached, leaving the tracker unchanged.
Sourcepub fn unregister<T: Indexer>(
&self,
indexes: &mut T,
addresses: Vec<Address>,
) -> Vec<Address>
pub fn unregister<T: Indexer>( &self, indexes: &mut T, addresses: Vec<Address>, ) -> Vec<Address>
Unregisters an Address vector from an Indexer. The addresses, when existing both in the tracker
and the Indexer, are first removed from the Indexer and on success get their reference count
decreased.
Returns the addresses that where successfully unregistered from the Indexer.
Sourcepub fn unregister_indexes(&self, indexes: &mut Indexes)
pub fn unregister_indexes(&self, indexes: &mut Indexes)
Unregisters all indexes contained in indexes, draining it in the process.
pub fn to_addresses(&self, indexes: &[Index], prefix: Prefix) -> Vec<Address>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
pub fn addresses_preallocation(&self) -> Option<usize>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Tracker
impl !RefUnwindSafe for Tracker
impl Send for Tracker
impl Sync for Tracker
impl Unpin for Tracker
impl UnwindSafe for Tracker
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<S> CastArc for Swhere
S: CastFromSync + ?Sized,
impl<S> CastArc for Swhere
S: CastFromSync + ?Sized,
Source§impl<T> CastFrom for Twhere
T: Any + 'static,
impl<T> CastFrom for Twhere
T: Any + 'static,
Source§fn ref_any(&self) -> &(dyn Any + 'static)
fn ref_any(&self) -> &(dyn Any + 'static)
Any, which is backed by the type implementing this trait.Source§fn mut_any(&mut self) -> &mut (dyn Any + 'static)
fn mut_any(&mut self) -> &mut (dyn Any + 'static)
Any, which is backed by the type implementing this trait.Source§impl<T> CastFromSync for T
impl<T> CastFromSync for T
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>
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>
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