Refactor handle_obliteration

This commit is contained in:
NicolasCantu 2025-03-26 12:36:06 +01:00
parent 614849db78
commit d2a3147120

View File

@ -74,9 +74,7 @@ impl ProcessState {
} }
/// This is a simplified and streamlined validation for obliteration state /// This is a simplified and streamlined validation for obliteration state
fn handle_obliteration(&self, members_list: &OutPointMemberMap) -> anyhow::Result<()> { fn handle_obliteration(&self, apophis: &RoleDefinition, members_list: &OutPointMemberMap) -> anyhow::Result<()> {
// We need an Apophis role
if let Some(apophis) = self.roles.get(SpecialRoles::APOPHIS.to_string().as_str()) {
// Apophis should have only one rule // Apophis should have only one rule
if apophis.validation_rules.len() != 1 { return Err(anyhow::Error::msg("Should have only one rule")); }; if apophis.validation_rules.len() != 1 { return Err(anyhow::Error::msg("Should have only one rule")); };
let obliteration_rule = apophis.validation_rules.get(0).unwrap(); let obliteration_rule = apophis.validation_rules.get(0).unwrap();
@ -99,9 +97,6 @@ impl ProcessState {
} else { } else {
Err(anyhow::Error::msg("Apophis is not satisfied")) Err(anyhow::Error::msg("Apophis is not satisfied"))
} }
} else {
Err(anyhow::Error::msg("Missing an apophis role"))
}
} }
pub fn is_valid(&self, previous_state: Option<&ProcessState>, members_list: &OutPointMemberMap) -> anyhow::Result<()> { pub fn is_valid(&self, previous_state: Option<&ProcessState>, members_list: &OutPointMemberMap) -> anyhow::Result<()> {