Skip to content

Commit c0535c3

Browse files
coinage-layer Phase 7 (part 14): op_count_in_flight diagnostic
Adds an aggregator over non-terminal operations: op_count_in_flight() -> usize Counts operations with status in {Preparing, Submitted, InBlock, Finalized, Waiting(_)}. Useful for "how many ops are pending" UI and for tests asserting no in-flight ops remain after a cancellation sweep. (An earlier attempt at op_count_by_kind hit Verus's restriction on deriving PartialEq for enums with payloads. Future work: add an assume_specification for OpKind equality, or refactor to use match arms.) 206 verified, 0 errors.
1 parent 9fbb6ba commit c0535c3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • rust/crates/coinage-layer/src

rust/crates/coinage-layer/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4689,6 +4689,36 @@ impl State {
46894689
c
46904690
}
46914691

4692+
/// Count of operations currently in-flight (non-terminal status).
4693+
pub fn op_count_in_flight(&self) -> (count: usize)
4694+
requires
4695+
self.invariant(),
4696+
ensures
4697+
count <= self.operations@.len(),
4698+
{
4699+
let mut c: usize = 0;
4700+
let mut j: usize = 0;
4701+
while j < self.operations.len()
4702+
invariant
4703+
0 <= j <= self.operations.len(),
4704+
c <= j,
4705+
self.invariant(),
4706+
decreases self.operations.len() - j,
4707+
{
4708+
let op = &self.operations[j];
4709+
let is_terminal = match op.status {
4710+
OpStatus::Done => true,
4711+
OpStatus::Failed => true,
4712+
_ => false,
4713+
};
4714+
if !is_terminal {
4715+
c = c + 1;
4716+
}
4717+
j = j + 1;
4718+
}
4719+
c
4720+
}
4721+
46924722
/// Count of all coins (any state) in purse `p`. Useful diagnostic
46934723
/// for "how cluttered is this purse?". Distinguish from
46944724
/// coin_count_available which excludes locked/spent/pending.

0 commit comments

Comments
 (0)