Struct AddressCacheInner

Source
pub(crate) struct AddressCacheInner<D: AddressCacheDatabase> {
    pub(crate) database: D,
    pub(crate) address_map: HashMap<Hash, CachedAddress>,
    pub(crate) script_set: HashSet<Hash>,
    pub(crate) utxo_index: HashMap<OutPoint, Hash>,
}

Fields§

§database: D

A database that will be used to persist all needed to get our address history

§address_map: HashMap<Hash, CachedAddress>

Maps a hash to a cached address struct, this is basically an in-memory version of our database, used for speeding up processing a block. This hash is the electrum’s script hash

§script_set: HashSet<Hash>

Holds all scripts we are interested in

§utxo_index: HashMap<OutPoint, Hash>

Keeps track of all utxos we own, and the script hash they belong to

Implementations§

Source§

impl<D: AddressCacheDatabase> AddressCacheInner<D>

Source

pub(crate) fn block_process( &mut self, block: &Block, height: u32, ) -> Vec<(Transaction, TxOut)>

Iterates through a block, finds transactions destined to ourselves. Returns all transactions we found.

Source

pub(crate) fn new(database: D) -> AddressCacheInner<D>

Source

pub(crate) fn get_address_utxos( &self, script_hash: &Hash, ) -> Option<Vec<(TxOut, OutPoint)>>

Source

pub(crate) fn get_transaction(&self, txid: &Txid) -> Option<CachedTransaction>

Source

pub(crate) fn get_address_history( &self, script_hash: &Hash, ) -> Option<Vec<CachedTransaction>>

Returns all transactions this address has, both input and outputs

Source

pub(crate) fn get_merkle_proof(&self, txid: &Txid) -> Option<MerkleProof>

Get Merkle Proof

Returns none if a given Txid is an unconfirmed transaction or unrelated with your wallet, defined by the xpubs, descriptors and addresses in your config.toml.

Source

pub(crate) fn cache_address(&mut self, script_pk: ScriptBuf)

Adds a new address to track, should be called at wallet setup and every once in a while to cache new addresses, as we use the first ones. Only requires a script to cache.

Source

pub(crate) fn setup(&self) -> Result<(), WatchOnlyError<D::Error>>

Setup is the first command that should be executed. In a new cache. It sets our wallet’s state, like the height we should start scanning and the wallet’s descriptor.

Source

pub(crate) fn derive_addresses( &mut self, ) -> Result<(), WatchOnlyError<D::Error>>

Source

pub(crate) fn maybe_derive_addresses(&mut self)

Source

pub(crate) fn find_unconfirmed( &self, ) -> Result<Vec<Transaction>, WatchOnlyError<D::Error>>

Source

pub(crate) fn find_spend( &self, transaction: &Transaction, ) -> Vec<(usize, TxOut)>

Source

pub(crate) fn cache_mempool_transaction( &mut self, transaction: &Transaction, ) -> Vec<TxOut>

Source

pub(crate) fn save_mempool_tx( &mut self, hash: Hash, transaction_to_cache: CachedTransaction, )

Source

pub(crate) fn save_non_mempool_tx( &mut self, transaction: &Transaction, is_spend: bool, value: u64, index: usize, hash: Hash, transaction_to_cache: CachedTransaction, )

Source

pub(crate) fn cache_transaction( &mut self, transaction: &Transaction, height: u32, value: u64, merkle_block: MerkleProof, position: u32, index: usize, is_spend: bool, hash: Hash, )

Caches a new transaction. This method may be called for addresses we don’t follow yet, this automatically makes we follow this address.

Auto Trait Implementations§

§

impl<D> Freeze for AddressCacheInner<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for AddressCacheInner<D>
where D: RefUnwindSafe,

§

impl<D> Send for AddressCacheInner<D>
where D: Send,

§

impl<D> Sync for AddressCacheInner<D>
where D: Sync,

§

impl<D> Unpin for AddressCacheInner<D>
where D: Unpin,

§

impl<D> UnwindSafe for AddressCacheInner<D>
where D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more