Skip to content
Snippets Groups Projects

[enh] add `get_written_transactions_for_bma()` and `get_pending_transactions_for_bma()`

Merged Benoit Lavenier requested to merge fix/2/add_get_transactions_for_bma into master
+ 72
7
@@ -85,16 +85,48 @@ pub trait DuniterModule: 'static + Sized {
async fn start(self) -> anyhow::Result<()>;
// Needed for BMA only, will be removed when the migration is complete.
/// Get TX full history of a pubkey. Needed for BMA only
#[doc(hidden)]
fn get_transactions_history_for_bma(
fn get_txs_history_bma(
_dbs_pool: &fast_threadpool::ThreadPoolSyncHandler<SharedDbs<FileBackend>>,
_profile_path_opt: Option<&Path>,
_pubkey: PublicKey,
) -> KvResult<Option<TxsHistoryForBma>> {
Ok(None)
}
// Needed for BMA only, will be removed when the migration is complete.
/// Get TX history of a pubkey from a block range. Needed for BMA only
#[doc(hidden)]
fn get_tx_history_bma_written_by_blocks(
_profile_path_opt: Option<&Path>,
_pubkey: PublicKey,
_from: Option<u32>,
_to: Option<u32>,
) -> KvResult<Option<TxsHistoryForBma>> {
Ok(None)
}
/// Get TX history of a pubkey from a median_time range. Needed for BMA only
#[doc(hidden)]
fn get_tx_history_bma_written_by_times(
_profile_path_opt: Option<&Path>,
_pubkey: PublicKey,
_from: Option<u64>,
_to: Option<u64>,
) -> KvResult<Option<TxsHistoryForBma>> {
Ok(None)
}
/// Get TX inside the mempool of a pubkey. Needed for BMA only
#[doc(hidden)]
fn get_txs_history_bma_mempool(
_dbs_pool: &fast_threadpool::ThreadPoolSyncHandler<SharedDbs<FileBackend>>,
_pubkey: PublicKey,
) -> KvResult<Option<TxsHistoryForBma>> {
Ok(None)
}
// Needed for BMA only
#[doc(hidden)]
fn get_tx_by_hash(
_dbs_pool: &fast_threadpool::ThreadPoolSyncHandler<SharedDbs<FileBackend>>,
@@ -269,22 +301,55 @@ macro_rules! plug_duniter_modules {
Ok(())
}
// Needed for BMA only, will be removed when the migration is complete.
// Needed for BMA only
#[allow(dead_code)]
#[doc(hidden)]
fn get_transactions_history_for_bma(
fn get_txs_history_bma(
dbs_pool: &fast_threadpool::ThreadPoolSyncHandler<SharedDbs<FileBackend>>,
profile_path_opt: Option<&Path>,
pubkey: PublicKey,
) -> KvResult<TxsHistoryForBma> {
$(
if let Some(txs_history) = <$M>::get_transactions_history_for_bma(dbs_pool, profile_path_opt, pubkey)? {
if let Some(txs_history) = <$M>::get_txs_history_bma(dbs_pool, profile_path_opt, pubkey)? {
return Ok(txs_history);
}
)*
Ok(TxsHistoryForBma::default())
}
// Needed for BMA only, will be removed when the migration is complete.
// Needed for BMA only
#[allow(dead_code)]
#[doc(hidden)]
fn get_written_transactions_for_bma(
profile_path_opt: Option<&Path>,
pubkey: PublicKey,
start_block: u32,
end_block: u32,
) -> KvResult<TxsHistoryForBma> {
$(
if let Some(txs_history) = <$M>::get_written_transactions_for_bma(profile_path_opt, pubkey, start_block, end_block)? {
return Ok(txs_history);
}
)*
Ok(TxsHistoryForBma::default())
}
// Needed for BMA only
#[allow(dead_code)]
#[doc(hidden)]
fn get_pending_transactions_for_bma(
dbs_pool: &fast_threadpool::ThreadPoolSyncHandler<SharedDbs<FileBackend>>,
pubkey: PublicKey,
) -> KvResult<TxsHistoryForBma> {
$(
if let Some(txs_history) = <$M>::get_pending_transactions_for_bma(dbs_pool, pubkey)? {
return Ok(txs_history);
}
)*
Ok(TxsHistoryForBma::default())
}
// Needed for BMA only
#[allow(dead_code)]
#[doc(hidden)]
fn get_tx_by_hash(
Loading