Remove impending_requests from Process

This commit is contained in:
Sosthene 2024-12-17 22:36:33 +01:00
parent 1e8a51f37a
commit 123c6946f2

View File

@ -234,13 +234,11 @@ impl ProcessState {
}
/// A process is basically a succession of states
/// If a process has nothing to do with us, impending_requests will be empty
/// The latest state MUST be an empty state with only the commited_in field set at the last unspent outpoint
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize, Tsify)]
#[tsify(into_wasm_abi)]
pub struct Process {
states: Vec<ProcessState>,
impending_requests: Vec<Prd>,
}
impl Process {
@ -253,7 +251,6 @@ impl Process {
};
Self {
states: vec![empty_state],
impending_requests: vec![],
}
}
@ -464,24 +461,6 @@ impl Process {
.find(|s| s.commited_in != latest_outpoint);
}
pub fn insert_impending_request(&mut self, request: Prd) {
self.impending_requests.push(request);
}
pub fn get_impending_requests(&self) -> Vec<&Prd> {
self.impending_requests.iter().collect()
}
pub fn get_impending_requests_mut(&mut self) -> Vec<&mut Prd> {
self.impending_requests.iter_mut().collect()
}
pub fn prune_impending_requests(&mut self) {
self.impending_requests = self.impending_requests.clone().into_iter()
.filter(|r| r.prd_type != PrdType::None)
.collect();
}
pub fn get_state_index(&self, state: &ProcessState) -> Option<usize> {
// Get the commited_in value of the provided state
let target_commited_in = state.commited_in;