MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / pre_validate

Function pre_validate

nodedb-crdt/src/pre_validate.rs:34–49  ·  view source on GitHub ↗

Pre-validate a proposed change against the leader's current state. This is called on the Control Plane before submitting to Raft. It uses the same validator but doesn't touch the DLQ — that's only for actual commit-time rejections.

(
    validator: &Validator,
    state: &CrdtState,
    change: &ProposedChange,
)

Source from the content-addressed store, hash-verified

32/// It uses the same validator but doesn't touch the DLQ — that's only
33/// for actual commit-time rejections.
34pub fn pre_validate(
35 validator: &Validator,
36 state: &CrdtState,
37 change: &ProposedChange,
38) -> PreValidationResult {
39 match validator.validate(state, change) {
40 ValidationOutcome::Accepted => PreValidationResult::Proceed,
41 ValidationOutcome::Rejected(violations) => {
42 let v = &violations[0];
43 PreValidationResult::FastReject {
44 constraint: v.constraint_name.clone(),
45 reason: v.reason.clone(),
46 }
47 }
48 }
49}
50
51#[cfg(test)]
52mod tests {

Callers 3

pre_validateMethod · 0.85

Calls 2

validateMethod · 0.45
cloneMethod · 0.45