Skip to main content

SQLTransaction

Struct SQLTransaction 

Source
pub struct SQLTransaction<RM>
where RM: DatabasePool + 'static,
{ /* private fields */ }
Expand description

SQL Transaction Writer

Trait Implementations§

Source§

impl<RM> CompletedOperationsTransaction for SQLTransaction<RM>
where RM: DatabasePool + 'static,

Source§

type Err = Error

Completed Operations Database Error
Source§

fn add_completed_operation<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, operation: &'life1 Operation, fee_by_keyset: &'life2 HashMap<Id, Amount>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Add completed operation
Source§

impl<RM> DbTransactionFinalizer for SQLTransaction<RM>
where RM: DatabasePool + 'static,

Source§

type Err = Error

Mint Signature Database Error
Source§

fn commit<'async_trait>( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,

Commits all the changes into the database
Source§

fn rollback<'async_trait>( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,

Rollbacks the write transaction
Source§

impl<RM> KVStoreTransaction<Error> for SQLTransaction<RM>
where RM: DatabasePool + 'static,

Source§

fn kv_read<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, primary_namespace: &'life1 str, secondary_namespace: &'life2 str, key: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Read value from key-value store
Source§

fn kv_write<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, primary_namespace: &'life1 str, secondary_namespace: &'life2 str, key: &'life3 str, value: &'life4 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Write value to key-value store
Source§

fn kv_remove<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, primary_namespace: &'life1 str, secondary_namespace: &'life2 str, key: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Remove value from key-value store
Source§

fn kv_list<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, primary_namespace: &'life1 str, secondary_namespace: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

List keys in a namespace
Source§

impl<RM> MintAuthTransaction<Error> for SQLTransaction<RM>
where RM: DatabasePool + 'static,

Source§

fn set_active_keyset<'life0, 'async_trait>( &'life0 mut self, 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 add_proof<'life0, 'async_trait>( &'life0 mut self, proof: AuthProof, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add spent AuthProof
Source§

fn update_proof_state<'life0, 'life1, 'async_trait>( &'life0 mut self, y: &'life1 PublicKey, proofs_state: State, ) -> Pin<Box<dyn Future<Output = Result<Option<State>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update AuthProofs state
Source§

fn add_blind_signatures<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, blinded_messages: &'life1 [PublicKey], blind_signatures: &'life2 [BlindSignature], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn add_protected_endpoints<'life0, 'async_trait>( &'life0 mut self, protected_endpoints: HashMap<ProtectedEndpoint, AuthRequired>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add protected endpoints
Source§

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

Removed Protected endpoints
Source§

impl<RM> KeysDatabaseTransaction<'_, Error> for SQLTransaction<RM>
where RM: DatabasePool + 'static,

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 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§

impl<RM> ProofsTransaction for SQLTransaction<RM>
where RM: DatabasePool + 'static,

Source§

fn add_proofs<'life0, 'life1, 'async_trait>( &'life0 mut self, proofs: Proofs, quote_id: Option<QuoteId>, operation: &'life1 Operation, ) -> Pin<Box<dyn Future<Output = Result<Acquired<ProofsWithState>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Adds proofs to the database with initial state Unspent.

This method first checks if any of the proofs already exist in the database. If a proof exists and is spent, returns Error::AttemptUpdateSpentProof. If a proof exists in any other state, returns Error::Duplicate.

On success, returns the proofs wrapped in Acquired<ProofsWithState> with state set to Unspent, indicating the rows are locked for the duration of the transaction.

Source§

fn update_proofs_state<'life0, 'life1, 'async_trait>( &'life0 mut self, proofs: &'life1 mut Acquired<ProofsWithState>, new_state: State, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Updates all proofs to the given state in the database.

Also updates the state field on the ProofsWithState wrapper to reflect the new state after the database update succeeds.

When the new state is Spent, this method also updates the keyset_amounts table to track the total redeemed amount per keyset for analytics purposes.

§Prerequisites

The proofs must have been previously acquired via add_proofs or get_proofs to ensure they are locked within the current transaction.

Source§

type Err = Error

Mint Proof Database Error
Source§

fn remove_proofs<'life0, 'life1, 'async_trait>( &'life0 mut self, ys: &'life1 [PublicKey], _quote_id: Option<QuoteId>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove Proofs
Source§

fn get_proof_ys_by_quote_id<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<Vec<PublicKey>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get ys by quote id
Source§

fn get_proof_ys_by_operation_id<'life0, 'life1, 'async_trait>( &'life0 mut self, operation_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = Result<Vec<PublicKey>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get proof ys by operation id
Source§

fn get_proofs<'life0, 'life1, 'async_trait>( &'life0 mut self, ys: &'life1 [PublicKey], ) -> Pin<Box<dyn Future<Output = Result<Acquired<ProofsWithState>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

get proofs states
Source§

impl<RM> QuotesTransaction for SQLTransaction<RM>
where RM: DatabasePool + 'static,

Source§

type Err = Error

Mint Quotes Database Error
Source§

fn add_melt_request<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, inputs_amount: Amount<CurrencyUnit>, inputs_fee: Amount<CurrencyUnit>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add melt_request with quote_id, inputs_amount, and inputs_fee
Source§

fn add_blinded_messages<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, quote_id: Option<&'life1 QuoteId>, blinded_messages: &'life2 [BlindedMessage], operation: &'life3 Operation, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Add blinded_messages for a quote_id
Source§

fn delete_blinded_messages<'life0, 'life1, 'async_trait>( &'life0 mut self, blinded_secrets: &'life1 [PublicKey], ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete blinded_messages by their blinded secrets
Source§

fn get_melt_request_and_blinded_messages<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<Option<MeltRequestInfo>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get melt_request and associated blinded_messages by quote_id
Source§

fn delete_melt_request<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete melt_request and associated blinded_messages by quote_id
Source§

fn update_mint_quote<'life0, 'life1, 'async_trait>( &'life0 mut self, quote: &'life1 mut Acquired<MintQuote>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persists any pending changes made to the mint quote. Read more
Source§

fn add_mint_quote<'life0, 'async_trait>( &'life0 mut self, quote: MintQuote, ) -> Pin<Box<dyn Future<Output = Result<Acquired<MintQuote>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn add_melt_quote<'life0, 'async_trait>( &'life0 mut self, quote: MeltQuote, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn update_melt_quote_request_lookup_id<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, quote: &'life1 mut Acquired<MeltQuote>, new_request_lookup_id: &'life2 PaymentIdentifier, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Updates the request lookup id for a melt quote. Read more
Source§

fn update_melt_quote_state<'life0, 'life1, 'async_trait>( &'life0 mut self, quote: &'life1 mut Acquired<MeltQuote>, state: MeltQuoteState, payment_proof: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<MeltQuoteState, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn get_mint_quote<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MintQuote>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get MintMintQuote and lock it for update in this transaction
Source§

fn get_melt_quote<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MeltQuote>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get mint::MeltQuote and lock it for update in this transaction
Source§

fn get_melt_quotes_by_request_lookup_id<'life0, 'life1, 'async_trait>( &'life0 mut self, request_lookup_id: &'life1 PaymentIdentifier, ) -> Pin<Box<dyn Future<Output = Result<Vec<Acquired<MeltQuote>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves all melt quotes matching a payment lookup identifier and locks them for update. Read more
Locks a melt quote and all related quotes sharing the same request_lookup_id atomically. Read more
Source§

fn get_mint_quote_by_request<'life0, 'life1, 'async_trait>( &'life0 mut self, request: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MintQuote>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all MintMintQuotes and lock it for update in this transaction
Source§

fn get_mint_quote_by_request_lookup_id<'life0, 'life1, 'async_trait>( &'life0 mut self, request_lookup_id: &'life1 PaymentIdentifier, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MintQuote>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all MintMintQuotes
Source§

impl<RM> SignaturesTransaction for SQLTransaction<RM>
where RM: DatabasePool + 'static,

Source§

type Err = Error

Mint Signature Database Error
Source§

fn add_blind_signatures<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, blinded_messages: &'life1 [PublicKey], blind_signatures: &'life2 [BlindSignature], quote_id: Option<QuoteId>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn get_blind_signatures<'life0, 'life1, 'async_trait>( &'life0 mut self, blinded_messages: &'life1 [PublicKey], ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<BlindSignature>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl<RM> SagaTransaction for SQLTransaction<RM>
where RM: DatabasePool + 'static,

Source§

type Err = Error

Saga Database Error
Source§

fn get_saga<'life0, 'life1, 'async_trait>( &'life0 mut self, operation_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<Saga>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get saga by operation_id
Source§

fn add_saga<'life0, 'life1, 'async_trait>( &'life0 mut self, saga: &'life1 Saga, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add saga
Source§

fn update_saga<'life0, 'life1, 'async_trait>( &'life0 mut self, operation_id: &'life1 Uuid, new_state: SagaStateEnum, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update saga state (only updates state and updated_at fields)
Source§

fn delete_saga<'life0, 'life1, 'async_trait>( &'life0 mut self, operation_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete saga
Source§

impl<RM> Transaction<Error> for SQLTransaction<RM>
where RM: DatabasePool + 'static,

Auto Trait Implementations§

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.

Source§

impl<T> Instrument for T

Source§

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

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

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.

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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