Skip to content

Commit 80e8cc8

Browse files
Create bridge.rs
1 parent 9dd0508 commit 80e8cc8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/bridge.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use crate::state_machine::{IntentState, TransitionEvent};
2+
use crate::proof::CompletionProof;
3+
pub fn apply_completion_proof(
4+
state: IntentState,
5+
proof: &CompletionProof,
6+
) -> Result<IntentState, &'static str> {
7+
if state != IntentState::Committed {
8+
return Err("Completion proof can only be applied in Committed state");
9+
}
10+
11+
let event = if proof.validate().is_ok() {
12+
TransitionEvent::CompletionProofVerified
13+
} else {
14+
TransitionEvent::ProofInvalid
15+
};
16+
17+
state.transition(event)
18+
}

0 commit comments

Comments
 (0)