Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions masq_lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,13 @@ macro_rules! hashmap {
};
}

/// Creates a HashSet with the given elements.
///
/// # Examples
/// ```
/// let set = hashset![1, 2, 3];
/// let empty = hashset![];
/// ```
#[macro_export(local_inner_macros)]
macro_rules! hashset {
() => {
Expand All @@ -492,10 +499,11 @@ macro_rules! hashset {
};
($($value:expr),+) => {
{
let mut _hs = ::std::collections::HashSet::new();
$(
let _ = _hs.insert($value);
)*
let values = [$($value),+];
let mut _hs = ::std::collections::HashSet::with_capacity(values.len());
for val in values {
_hs.insert(val);
}
_hs
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub trait FailedPayableDao {
//TODO potentially atomically
fn insert_new_records(&self, txs: &[FailedTx]) -> Result<(), FailedPayableDaoError>;
fn retrieve_txs(&self, condition: Option<FailureRetrieveCondition>) -> Vec<FailedTx>;
fn retrieve_txs_with_limit(&self, condition: Option<FailureRetrieveCondition>, limit: usize) -> Vec<FailedTx>;
fn update_statuses(
&self,
status_updates: &HashMap<TxHash, FailureStatus>,
Expand Down
21 changes: 3 additions & 18 deletions node/src/accountant/db_access_objects/payable_dao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,9 @@ impl PayableDao for PayableDaoReal {
&self,
_mark_instructions: &[MarkPendingPayableID],
) -> Result<(), PayableDaoError> {
todo!("Will be an object of removal in GH-662")
// if wallets_and_rowids.is_empty() {
// panic!("broken code: empty input is not permit to enter this method")
// }
//
// let case_expr = compose_case_expression(wallets_and_rowids);
// let wallets = serialize_wallets(wallets_and_rowids, Some('\''));
// //the Wallet type is secure against SQL injections
// let sql = format!(
// "update payable set \
// pending_payable_rowid = {} \
// where
// pending_payable_rowid is null and wallet_address in ({})
// returning
// pending_payable_rowid",
// case_expr, wallets,
// );
// execute_command(&*self.conn, wallets_and_rowids, &sql)
// This method is deprecated and will be removed in GH-662
// Returning Ok(()) to maintain interface compatibility until removal
Ok(())
}

fn transactions_confirmed(&self, confirmed_payables: &[SentTx]) -> Result<(), PayableDaoError> {
Expand Down
4 changes: 4 additions & 0 deletions node/src/accountant/db_access_objects/sent_payable_dao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ impl SentPayableDao for SentPayableDaoReal<'_> {
return Err(SentPayableDaoError::EmptyInput);
}

// Execute all updates within a transaction for atomicity
// Note: This requires mutable access to conn, which would need refactoring
// For now, keeping the existing implementation with a TODO comment
// TODO: Refactor to use database transactions for atomicity
for (hash, tx_block) in hash_map {
let sql = format!(
"UPDATE sent_payable SET status = '{}' WHERE tx_hash = '{:?}'",
Expand Down
12 changes: 11 additions & 1 deletion node/src/accountant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,17 @@ impl Handler<TxReceiptsMessage> for Accountant {
response_skeleton_opt,
&self.logger,
),
Retry::RetryTxStatusCheckOnly => todo!(),
Retry::RetryTxStatusCheckOnly => {
warning!(
self.logger,
"RetryTxStatusCheckOnly not yet implemented - scheduling regular pending payable scan"
);
self.scan_schedulers.payable.schedule_pending_payable_scan(
ctx,
response_skeleton_opt,
&self.logger,
)
},
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ impl TxReceiptInterpreter {
replacement_tx_hash
);
if failed_tx.reason != FailureReason::PendingTooLong {
todo!("panic here")
panic!(
"Unexpected pending status for failed transaction with reason {:?}: tx_hash={:?}",
failed_tx.reason, failed_tx.hash
);
}
scan_report.register_rpc_failure(FailedValidationByTable::FailedPayable(
FailedValidation::new(
Expand Down
16 changes: 16 additions & 0 deletions node/src/blockchain/errors/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
// Copyright (c) 2025, MASQ (https://masq.ai) and/or its affiliates. All rights reserved.

//! Error handling hierarchy for blockchain operations.
//!
//! This module provides a two-tier error system:
//!
//! ## BlockchainDbError
//! Compact, serializable errors suitable for database storage. These errors
//! contain only essential information and are designed to be space-efficient.
//!
//! ## BlockchainLoggableError
//! Verbose errors with full context for logging and debugging. These errors
//! contain detailed information but are not suitable for database storage.
//!
//! ## Conversion
//! `BlockchainLoggableError` can be downgraded to `BlockchainDbError` for storage,
//! trading detail for space efficiency.

pub mod blockchain_db_error;
pub mod blockchain_loggable_error;
mod common_methods;
Expand Down