Validate application and return the verified causal knowledge for conflict checks.
(
txn: &T,
view: &ViewState,
change_id: NodeId,
change_hash: &Hash,
change: &Change,
)
| 277 | |
| 278 | /// Validate application and return the verified causal knowledge for conflict checks. |
| 279 | pub fn validate_can_apply_with_frontier<T: ViewTxnT + GraphTxnT>( |
| 280 | txn: &T, |
| 281 | view: &ViewState, |
| 282 | change_id: NodeId, |
| 283 | change_hash: &Hash, |
| 284 | change: &Change, |
| 285 | ) -> Result<VerifiedCausalFrontier, LocalApplyError> { |
| 286 | // Check if already applied |
| 287 | if is_change_on_view(txn, view, change_id).map_err(|e| LocalApplyError::Internal { |
| 288 | message: format!("Failed to check view: {}", e), |
| 289 | })? { |
| 290 | return Err(LocalApplyError::ChangeAlreadyApplied { hash: *change_hash }); |
| 291 | } |
| 292 | |
| 293 | // Check dependencies |
| 294 | let missing = verify_dependencies(txn, change).map_err(|e| LocalApplyError::Internal { |
| 295 | message: format!("Failed to verify dependencies: {}", e), |
| 296 | })?; |
| 297 | |
| 298 | if let Some(first_missing) = missing.first() { |
| 299 | return Err(LocalApplyError::DependencyMissing { |
| 300 | hash: *first_missing, |
| 301 | }); |
| 302 | } |
| 303 | |
| 304 | verify_causal_frontier(txn, change) |
| 305 | } |
| 306 | |
| 307 | #[cfg(test)] |
| 308 | mod tests { |
no test coverage detected