State.record_switch: def of cswap-bend-cli@0.1.0.0 Import: import cswap-bend-cli@0.1.0.0/daemon/state.bend as State Lines 90-99 of cswap-bend-cli@0.1.0.0/daemon/state.bend: https://jend.leeeet.dev/read.txt?path=cswap-bend-cli@0.1.0.0/daemon/state.bend&start_line=90&end_line=99 import Base import cswap-bend-cli@0.1.0.0/json.bend as Json # What `_perform` records after a switch. `left_headroom` is centi-percent, # `left_recovery` unix seconds (None for the reference's inf). def record_switch(+st: Json.Json, +now: U32, +to: String, +from: Maybe<&2, U32>, +left_headroom: Maybe<&2, U32>, +left_recovery: Maybe<&2, U32>, +trigger: String) -> Json.Json: Json.set("leftTrigger", Json.JStr{trigger}, Json.set("leftRecoveryAt", opt(left_recovery, u => fl(u)), Json.set("leftHeadroom", opt(left_headroom, h => cents_json(h)), Json.set("lastSwitchFrom", opt(from, n => int_json(n)), Json.set("lastSwitchTo", Json.JStr{to}, Json.set("lastSwitchAt", fl(now), Json.set("schemaVersion", Json.JNum{"1"}, obj_or_empty(st)))))))) Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/daemon/state.bend&name=cents_json https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/daemon/state.bend&name=fl https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/daemon/state.bend&name=int_json https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/daemon/state.bend&name=obj_or_empty https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/daemon/state.bend&name=opt https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/json.bend&name=Json https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/json.bend&name=set