massa_pool_exports/
controller_traits.rs1use massa_models::{
4 block_id::BlockId,
5 denunciation::{Denunciation, DenunciationPrecursor},
6 endorsement::EndorsementId,
7 operation::OperationId,
8 slot::Slot,
9};
10use massa_storage::Storage;
11use massa_time::MassaTime;
12
13use crate::error::PoolError;
14
15#[cfg_attr(feature = "test-exports", mockall_wrap::wrap, mockall::automock)]
17pub trait PoolController: Send + Sync {
18 fn add_operations(&mut self, ops: Storage) -> Result<(), PoolError>;
21
22 fn add_endorsements(&mut self, endorsements: Storage);
24
25 fn add_denunciation_precursor(&self, denunciation_precursor: DenunciationPrecursor);
27
28 fn notify_final_cs_periods(&mut self, final_cs_periods: &[u64]);
30
31 fn get_block_operations(
33 &self,
34 slot: &Slot,
35 timeout: Option<MassaTime>,
36 ) -> Result<(Vec<OperationId>, Storage), PoolError>;
37
38 fn get_block_endorsements(
40 &self,
41 target_block: &BlockId,
42 slot: &Slot,
43 timeout: Option<MassaTime>,
44 ) -> Result<(Vec<Option<EndorsementId>>, Storage), PoolError>;
45
46 fn get_block_denunciations(
48 &self,
49 target_slot: &Slot,
50 timeout: Option<MassaTime>,
51 ) -> Result<Vec<Denunciation>, PoolError>;
52
53 fn get_endorsement_count(&self, timeout: Option<MassaTime>) -> Result<usize, PoolError>;
55
56 fn get_operation_count(&self, timeout: Option<MassaTime>) -> Result<usize, PoolError>;
58
59 fn contains_endorsements(
61 &self,
62 endorsements: &[EndorsementId],
63 timeout: Option<MassaTime>,
64 ) -> Result<Vec<bool>, PoolError>;
65
66 fn contains_operations(
68 &self,
69 operations: &[OperationId],
70 timeout: Option<MassaTime>,
71 ) -> Result<Vec<bool>, PoolError>;
72
73 fn get_denunciation_count(&self, timeout: Option<MassaTime>) -> Result<usize, PoolError>;
75
76 fn clone_box(&self) -> Box<dyn PoolController>;
79
80 fn get_final_cs_periods(&self) -> Vec<u64>;
82}
83
84impl Clone for Box<dyn PoolController> {
87 fn clone(&self) -> Box<dyn PoolController> {
88 self.clone_box()
89 }
90}
91
92pub trait PoolManager: Send + Sync {
94 fn stop(&mut self);
96}