MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / validate_can_apply_with_frontier

Function validate_can_apply_with_frontier

atomic-core/src/apply/change.rs:279–305  ·  view source on GitHub ↗

Validate application and return the verified causal knowledge for conflict checks.

(
    txn: &T,
    view: &ViewState,
    change_id: NodeId,
    change_hash: &Hash,
    change: &Change,
)

Source from the content-addressed store, hash-verified

277
278/// Validate application and return the verified causal knowledge for conflict checks.
279pub 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)]
308mod tests {

Callers 2

validate_can_applyFunction · 0.85

Calls 3

is_change_on_viewFunction · 0.85
verify_dependenciesFunction · 0.85
verify_causal_frontierFunction · 0.85

Tested by

no test coverage detected