Skip to main content

KeysDatabaseTransaction

Trait KeysDatabaseTransaction 

Source
pub trait KeysDatabaseTransaction<'a, Error>: DbTransactionFinalizer<Err = Error> {
    // Required methods
    fn set_active_keyset<'life0, 'async_trait>(
        &'life0 mut self,
        unit: CurrencyUnit,
        id: Id,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_keyset_info<'life0, 'async_trait>(
        &'life0 mut self,
        keyset: MintKeySetInfo,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn next_derivation_index<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        unit: &'life1 CurrencyUnit,
    ) -> Pin<Box<dyn Future<Output = Result<u32, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_keyset_infos_by_unit<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        unit: &'life1 CurrencyUnit,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MintKeySetInfo>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_active_keysets<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<HashMap<CurrencyUnit, Id>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_keyset_infos<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MintKeySetInfo>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn keysets_epoch<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

KeysDatabaseWriter

Required Methods§

Source

fn set_active_keyset<'life0, 'async_trait>( &'life0 mut self, unit: CurrencyUnit, id: Id, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add Active Keyset

Source

fn add_keyset_info<'life0, 'async_trait>( &'life0 mut self, keyset: MintKeySetInfo, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn next_derivation_index<'life0, 'life1, 'async_trait>( &'life0 mut self, unit: &'life1 CurrencyUnit, ) -> Pin<Box<dyn Future<Output = Result<u32, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Allocate the next derivation-path index for a unit.

Returns max(derivation_path_index) + 1 for the unit (1 when the unit has no keysets yet). The transaction holds the global keyset advisory lock (taken when it begins), so all keyset transactions serialize and two signatory instances rotating the same unit cannot allocate the same index and derive divergent keysets. This is the authoritative index source; callers must not compute it from process-local state.

Source

fn get_keyset_infos_by_unit<'life0, 'life1, 'async_trait>( &'life0 mut self, unit: &'life1 CurrencyUnit, ) -> Pin<Box<dyn Future<Output = Result<Vec<MintKeySetInfo>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read a unit’s keyset infos inside the transaction, under the global keyset advisory lock the transaction holds.

Boot-time reactivation uses this to pick a unit’s highest-index keyset and reassign the active pointer as one atomic step. Both happen inside the transaction, under the global keyset lock, so a peer rotation cannot commit a higher keyset between the read and the reassignment and get clobbered back to the older one.

Source

fn get_active_keysets<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<CurrencyUnit, Id>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read all active keyset pointers inside the transaction.

Keyset reads go through a transaction, which holds the global keyset lock, so no other keyset transaction can commit between reads. The signatory uses these transaction reads to reload its in-memory keysets, so the collision check and default amounts see peers’ committed rotations rather than a stale snapshot.

Source

fn get_keyset_infos<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Vec<MintKeySetInfo>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read all keyset infos inside the transaction. See get_active_keysets for why keyset reads go through the transaction.

Source

fn keysets_epoch<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read the keyset epoch inside the transaction.

Transaction-scoped counterpart of KeysDatabase::keysets_epoch, used to gate the reload under the global lock.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§