Skip to content

Commit

Permalink
Optimize transaction service queries
Browse files Browse the repository at this point in the history
Transaction service sql db queries must handle
  `DieselError(DatabaseError(__Unknown, "database is locked"))`. This PR attempts
  to remove situations where that error may occur under highly busy async
  cirumstances, specifically:
- Combine find and update/write type queries into one.
- Add sql transactions around complex tasks.
  • Loading branch information
hansieodendaal committed Oct 5, 2022
1 parent 978ee8f commit 76ed206
Show file tree
Hide file tree
Showing 2 changed files with 521 additions and 354 deletions.
4 changes: 2 additions & 2 deletions base_layer/wallet/src/transaction_service/storage/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub trait TransactionBackend: Send + Sync + Clone {
/// Mark a pending transaction direct send attempt as a success
fn mark_direct_send_success(&self, tx_id: TxId) -> Result<(), TransactionStorageError>;
/// Cancel coinbase transactions at a specific block height
fn cancel_coinbase_transaction_at_block_height(&self, block_height: u64) -> Result<(), TransactionStorageError>;
fn cancel_coinbase_transactions_at_block_height(&self, block_height: u64) -> Result<(), TransactionStorageError>;
/// Find coinbase transaction at a specific block height for a given amount
fn find_coinbase_transaction_at_block_height(
&self,
Expand Down Expand Up @@ -693,7 +693,7 @@ where T: TransactionBackend + 'static
&self,
block_height: u64,
) -> Result<(), TransactionStorageError> {
self.db.cancel_coinbase_transaction_at_block_height(block_height)
self.db.cancel_coinbase_transactions_at_block_height(block_height)
}

pub fn find_coinbase_transaction_at_block_height(
Expand Down
Loading

0 comments on commit 76ed206

Please sign in to comment.