@@ -10,23 +10,22 @@ use mithril_common::StdResult;
1010#[ cfg_attr( test, mockall:: automock) ]
1111#[ async_trait]
1212pub trait TransactionPruner : Send + Sync {
13- /// Prune the transactions older than the given number of blocks (based on the block range root
14- /// stored).
13+ /// Prune the transactions older than the given number of blocks.
1514 async fn prune ( & self , number_of_blocks_to_keep : BlockNumber ) -> StdResult < ( ) > ;
1615}
1716
1817/// A decorator of [TransactionsImporter] that prunes the transactions older than a given number of
1918/// blocks after running the import.
2019///
2120/// If the number of blocks to keep is not provided, no pruning is performed.
22- pub struct TransactionsImporterWithPruneDecorator {
21+ pub struct TransactionsImporterWithPruner {
2322 number_of_blocks_to_keep : Option < BlockNumber > ,
2423 transaction_pruner : Arc < dyn TransactionPruner > ,
2524 wrapped_importer : Arc < dyn TransactionsImporter > ,
2625}
2726
28- impl TransactionsImporterWithPruneDecorator {
29- /// Create a new instance of [TransactionsImporterWithPruneDecorator ].
27+ impl TransactionsImporterWithPruner {
28+ /// Create a new instance of [TransactionsImporterWithPruner ].
3029 pub fn new (
3130 number_of_blocks_to_keep : Option < BlockNumber > ,
3231 transaction_pruner : Arc < dyn TransactionPruner > ,
@@ -41,7 +40,7 @@ impl TransactionsImporterWithPruneDecorator {
4140}
4241
4342#[ async_trait]
44- impl TransactionsImporter for TransactionsImporterWithPruneDecorator {
43+ impl TransactionsImporter for TransactionsImporterWithPruner {
4544 async fn import ( & self , up_to_beacon : ImmutableFileNumber ) -> StdResult < ( ) > {
4645 self . wrapped_importer . import ( up_to_beacon) . await ?;
4746
@@ -71,15 +70,15 @@ mod tests {
7170 }
7271 }
7372
74- impl TransactionsImporterWithPruneDecorator {
75- pub fn new_with_mock < Ti , Pr > (
73+ impl TransactionsImporterWithPruner {
74+ pub fn new_with_mock < P , I > (
7675 number_of_blocks_to_keep : Option < BlockNumber > ,
77- transaction_pruner_mock_config : Pr ,
78- importer_mock_config : Ti ,
76+ transaction_pruner_mock_config : P ,
77+ importer_mock_config : I ,
7978 ) -> Self
8079 where
81- Pr : FnOnce ( & mut MockTransactionPruner ) ,
82- Ti : FnOnce ( & mut MockTransactionImporterImpl ) ,
80+ P : FnOnce ( & mut MockTransactionPruner ) ,
81+ I : FnOnce ( & mut MockTransactionImporterImpl ) ,
8382 {
8483 let mut transaction_pruner = MockTransactionPruner :: new ( ) ;
8584 transaction_pruner_mock_config ( & mut transaction_pruner) ;
@@ -96,7 +95,7 @@ mod tests {
9695
9796 #[ tokio:: test]
9897 async fn test_does_not_prune_if_none_is_configured ( ) {
99- let importer = TransactionsImporterWithPruneDecorator :: new_with_mock (
98+ let importer = TransactionsImporterWithPruner :: new_with_mock (
10099 None ,
101100 |mock| {
102101 mock. expect_prune ( ) . never ( ) ;
@@ -112,7 +111,7 @@ mod tests {
112111 #[ tokio:: test]
113112 async fn test_does_prune_if_a_block_number_is_configured ( ) {
114113 let expected_block_number: BlockNumber = 5 ;
115- let importer = TransactionsImporterWithPruneDecorator :: new_with_mock (
114+ let importer = TransactionsImporterWithPruner :: new_with_mock (
116115 Some ( expected_block_number) ,
117116 |mock| {
118117 mock. expect_prune ( )
0 commit comments