@@ -10,23 +10,22 @@ use mithril_common::StdResult;
10
10
#[ cfg_attr( test, mockall:: automock) ]
11
11
#[ async_trait]
12
12
pub 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.
15
14
async fn prune ( & self , number_of_blocks_to_keep : BlockNumber ) -> StdResult < ( ) > ;
16
15
}
17
16
18
17
/// A decorator of [TransactionsImporter] that prunes the transactions older than a given number of
19
18
/// blocks after running the import.
20
19
///
21
20
/// If the number of blocks to keep is not provided, no pruning is performed.
22
- pub struct TransactionsImporterWithPruneDecorator {
21
+ pub struct TransactionsImporterWithPruner {
23
22
number_of_blocks_to_keep : Option < BlockNumber > ,
24
23
transaction_pruner : Arc < dyn TransactionPruner > ,
25
24
wrapped_importer : Arc < dyn TransactionsImporter > ,
26
25
}
27
26
28
- impl TransactionsImporterWithPruneDecorator {
29
- /// Create a new instance of [TransactionsImporterWithPruneDecorator ].
27
+ impl TransactionsImporterWithPruner {
28
+ /// Create a new instance of [TransactionsImporterWithPruner ].
30
29
pub fn new (
31
30
number_of_blocks_to_keep : Option < BlockNumber > ,
32
31
transaction_pruner : Arc < dyn TransactionPruner > ,
@@ -41,7 +40,7 @@ impl TransactionsImporterWithPruneDecorator {
41
40
}
42
41
43
42
#[ async_trait]
44
- impl TransactionsImporter for TransactionsImporterWithPruneDecorator {
43
+ impl TransactionsImporter for TransactionsImporterWithPruner {
45
44
async fn import ( & self , up_to_beacon : ImmutableFileNumber ) -> StdResult < ( ) > {
46
45
self . wrapped_importer . import ( up_to_beacon) . await ?;
47
46
@@ -71,15 +70,15 @@ mod tests {
71
70
}
72
71
}
73
72
74
- impl TransactionsImporterWithPruneDecorator {
75
- pub fn new_with_mock < Ti , Pr > (
73
+ impl TransactionsImporterWithPruner {
74
+ pub fn new_with_mock < P , I > (
76
75
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 ,
79
78
) -> Self
80
79
where
81
- Pr : FnOnce ( & mut MockTransactionPruner ) ,
82
- Ti : FnOnce ( & mut MockTransactionImporterImpl ) ,
80
+ P : FnOnce ( & mut MockTransactionPruner ) ,
81
+ I : FnOnce ( & mut MockTransactionImporterImpl ) ,
83
82
{
84
83
let mut transaction_pruner = MockTransactionPruner :: new ( ) ;
85
84
transaction_pruner_mock_config ( & mut transaction_pruner) ;
@@ -96,7 +95,7 @@ mod tests {
96
95
97
96
#[ tokio:: test]
98
97
async fn test_does_not_prune_if_none_is_configured ( ) {
99
- let importer = TransactionsImporterWithPruneDecorator :: new_with_mock (
98
+ let importer = TransactionsImporterWithPruner :: new_with_mock (
100
99
None ,
101
100
|mock| {
102
101
mock. expect_prune ( ) . never ( ) ;
@@ -112,7 +111,7 @@ mod tests {
112
111
#[ tokio:: test]
113
112
async fn test_does_prune_if_a_block_number_is_configured ( ) {
114
113
let expected_block_number: BlockNumber = 5 ;
115
- let importer = TransactionsImporterWithPruneDecorator :: new_with_mock (
114
+ let importer = TransactionsImporterWithPruner :: new_with_mock (
116
115
Some ( expected_block_number) ,
117
116
|mock| {
118
117
mock. expect_prune ( )
0 commit comments