diff --git a/crates/mind-body/src/projection/turn.rs b/crates/mind-body/src/projection/turn.rs index 811d1b9..570cdd9 100644 --- a/crates/mind-body/src/projection/turn.rs +++ b/crates/mind-body/src/projection/turn.rs @@ -153,6 +153,13 @@ pub(crate) fn decide(organs: &Organs, request: &Request, key: &str, now: DateTim Taken { report, record, state } } +/// The send is not handed over: the mark is removed. +fn unmark(send: &mut Value) { + if let Some(fields) = send.as_object_mut() { + fields.remove("handed"); + } +} + /// Settles what `record` owes through `actuator`: each owed send is posted, refused (a refusal is an answer) or, when no answer /// came, still owed. The only receipt is the mouth's answer to a send, an event id; her lines in the room's tail are never one. The /// amendments follow once nothing is owed. A record that owes nothing is the shape the simulator and the mouth share. @@ -202,9 +209,7 @@ pub(crate) fn deliver(actuator: &dyn Actuator, record: &mut Value, pass: Pass, s send["handed"] = json!(true); record["owed"] = json!(still.iter().chain(std::iter::once(&send)).chain(&owed[index + 1..]).collect::>()); if !ahead(record) { - if let Some(fields) = send.as_object_mut() { - fields.remove("handed"); - } + unmark(&mut send); stalled.insert(room.clone()); still.push(send); continue; @@ -220,9 +225,7 @@ pub(crate) fn deliver(actuator: &dyn Actuator, record: &mut Value, pass: Pass, s Sent::NotSent => { stalled.insert(room.clone()); if !handed { - if let Some(fields) = send.as_object_mut() { - fields.remove("handed"); - } + unmark(&mut send); } still.push(send); }