diff --git a/module/src/lib.rs b/module/src/lib.rs index 7ef782f4cadc0d0162b57dc663ca4d72c8e9ba66..841b1ebfb248cb7bf4f1c5f61e0a425a93a3dff2 100644 --- a/module/src/lib.rs +++ b/module/src/lib.rs @@ -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 (written and pending) 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_txs_history_bma_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_txs_history_bma_by_times( + _profile_path_opt: Option<&Path>, + _pubkey: PublicKey, + _from: Option<u64>, + _to: Option<u64>, + ) -> KvResult<Option<TxsHistoryForBma>> { + Ok(None) + } + + /// Get mempool TX 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,72 @@ 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_txs_history_bma_by_blocks( + profile_path_opt: Option<&Path>, + pubkey: PublicKey, + from: Option<u32>, + to: Option<u32>, + ) -> KvResult<TxsHistoryForBma> { + $( + if let Some(txs_history) = <$M>::get_txs_history_bma_by_blocks(profile_path_opt, pubkey, from, to)? { + return Ok(txs_history); + } + )* + Ok(TxsHistoryForBma::default()) + } + + // Needed for BMA only + #[allow(dead_code)] + #[doc(hidden)] + fn get_txs_history_bma_by_times( + profile_path_opt: Option<&Path>, + pubkey: PublicKey, + from: Option<u64>, + to: Option<u64>, + ) -> KvResult<TxsHistoryForBma> { + $( + if let Some(txs_history) = <$M>::get_txs_history_bma_by_times(profile_path_opt, pubkey, from, to)? { + return Ok(txs_history); + } + )* + Ok(TxsHistoryForBma::default()) + } + + // Needed for BMA only + #[allow(dead_code)] + #[doc(hidden)] + fn get_txs_history_bma_mempool( + dbs_pool: &fast_threadpool::ThreadPoolSyncHandler<SharedDbs<FileBackend>>, + pubkey: PublicKey, + ) -> KvResult<TxsHistoryForBma> { + $( + if let Some(txs_history) = <$M>::get_txs_history_bma_mempool(dbs_pool, pubkey)? { + return Ok(txs_history); + } + )* + Ok(TxsHistoryForBma::default()) + } + + // Needed for BMA only #[allow(dead_code)] #[doc(hidden)] fn get_tx_by_hash(