massa_final_state/
controller_trait.rs1use massa_async_pool::AsyncPool;
2use massa_db_exports::{DBBatch, ShareableMassaDBController};
3use massa_deferred_calls::DeferredCallRegistry;
4use massa_executed_ops::ExecutedDenunciations;
5use massa_hash::Hash;
6use massa_ledger_exports::LedgerController;
7use massa_models::{operation::OperationId, slot::Slot};
8use massa_pos_exports::{PoSFinalState, PosError};
9use massa_versioning::versioning::MipStore;
10
11use crate::{FinalStateError, StateChanges};
12
13#[cfg_attr(feature = "test-exports", mockall::automock)]
15pub trait FinalStateController: Send + Sync {
16 fn get_fingerprint(&self) -> Hash;
19
20 fn get_slot(&self) -> Slot;
22
23 fn get_execution_trail_hash(&self) -> Hash;
25
26 fn reset(&mut self);
30
31 fn compute_initial_draws(&mut self) -> Result<(), FinalStateError>;
33
34 fn finalize(
39 &mut self,
40 slot: Slot,
41 changes: StateChanges,
42 network_versions: Option<(u32, Option<u32>)>,
43 );
44
45 fn recompute_caches(&mut self);
47
48 fn is_db_valid(&self) -> bool;
50
51 fn init_execution_trail_hash_to_batch(&mut self, batch: &mut DBBatch);
53
54 #[allow(clippy::borrowed_box)]
56 fn get_ledger(&self) -> &Box<dyn LedgerController>;
57
58 fn get_ledger_mut(&mut self) -> &mut Box<dyn LedgerController>;
60
61 fn get_async_pool(&self) -> &AsyncPool;
63
64 fn get_pos_state(&self) -> &PoSFinalState;
66
67 fn get_pos_state_mut(&mut self) -> &mut PoSFinalState;
69
70 fn load_initial_deferred_credits(&mut self, batch: &mut DBBatch) -> Result<(), PosError>;
73
74 fn executed_ops_contains(&self, op_id: &OperationId) -> bool;
76
77 fn get_ops_exec_status(&self, batch: &[OperationId]) -> Vec<Option<bool>>;
79
80 fn get_executed_denunciations(&self) -> &ExecutedDenunciations;
82
83 fn get_database(&self) -> &ShareableMassaDBController;
85
86 fn get_last_start_period(&self) -> u64;
88
89 fn set_last_start_period(&mut self, last_start_period: u64);
91
92 fn get_last_slot_before_downtime(&self) -> &Option<Slot>;
94
95 fn set_last_slot_before_downtime(&mut self, last_slot_before_downtime: Option<Slot>);
97
98 fn get_mip_store(&self) -> &MipStore;
100
101 fn get_mip_store_mut(&mut self) -> &mut MipStore;
103
104 fn get_deferred_call_registry(&self) -> &DeferredCallRegistry;
106}