Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
SWvheerden committed Sep 5, 2022
1 parent ce4d372 commit ad2d93e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
4 changes: 4 additions & 0 deletions base_layer/core/src/mempool/mempool_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ impl MempoolStorage {
warn!(target: LOG_TARGET, "Validation failed due to consensus rule: {}", msg);
Ok(TxStorageResponse::NotStoredConsensus)
},
Err(ValidationError::DuplicateKernelError(msg)) => {
warn!(target: LOG_TARGET, "Validation failed due to duplicate kernel: {}", msg);
Ok(TxStorageResponse::NotStoredConsensus)
},
Err(e) => {
warn!(target: LOG_TARGET, "Validation failed due to error: {}", e);
Ok(TxStorageResponse::NotStored)
Expand Down
1 change: 1 addition & 0 deletions base_layer/core/tests/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,7 @@ async fn consensus_validation_unique_excess_sig() {
// trying to submit a transaction with an existing excess signature already in the chain is an error
let tx = Arc::new(tx1);
let response = mempool.insert(tx).await.unwrap();
dbg!(&response);
assert!(matches!(response, TxStorageResponse::NotStoredConsensus));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use std::{
convert::{TryFrom, TryInto},
sync::{Arc, RwLock, Mutex},
sync::{Arc, Mutex, RwLock},
};

use chacha20poly1305::XChaCha20Poly1305;
Expand Down Expand Up @@ -663,10 +663,12 @@ impl OutputManagerBackend for OutputManagerSqliteDatabase {
let start = Instant::now();
let conn = self.database_connection.get_pooled_connection()?;
let acquire_lock = start.elapsed();
// We need to ensure that this whole encumber operation happens inside of a mutex to ensure thread safety as the transaction first check checks if it can encumber then encumbers them.
let _guard = self.encumber_lock.lock().map_err(|e| OutputManagerStorageError::UnexpectedResult(format!(
"Encumber lock poisoned: {}", e
)))?;
// We need to ensure that this whole encumber operation happens inside of a mutex to ensure thread safety as the
// transaction first check checks if it can encumber then encumbers them.
let _guard = self
.encumber_lock
.lock()
.map_err(|e| OutputManagerStorageError::UnexpectedResult(format!("Encumber lock poisoned: {}", e)))?;

let mut outputs_to_be_spent = Vec::with_capacity(outputs_to_send.len());

Expand Down Expand Up @@ -721,10 +723,12 @@ impl OutputManagerBackend for OutputManagerSqliteDatabase {
let conn = self.database_connection.get_pooled_connection()?;
let acquire_lock = start.elapsed();

// We need to ensure that this whole encumber operation happens inside of a mutex to ensure thread safety as the transaction first check checks if it can encumber then encumbers them.
let _guard = self.encumber_lock.lock().map_err(|e| OutputManagerStorageError::UnexpectedResult(format!(
"Encumber lock poisoned: {}", e
)))?;
// We need to ensure that this whole encumber operation happens inside of a mutex to ensure thread safety as the
// transaction first check checks if it can encumber then encumbers them.
let _guard = self
.encumber_lock
.lock()
.map_err(|e| OutputManagerStorageError::UnexpectedResult(format!("Encumber lock poisoned: {}", e)))?;
let outputs_to_be_received =
OutputSql::find_by_tx_id_and_status(tx_id, OutputStatus::ShortTermEncumberedToBeReceived, &conn)?;
for o in &outputs_to_be_received {
Expand Down

0 comments on commit ad2d93e

Please sign in to comment.