~/bend-docscommunity

ustore.bend relies on unsafe/foreign

raw source on the hub · import cswap-bend-cli@0.1.0.0/ustore.bend as Ustore

8 imports
import Base
import ./pollrow.bend as Pollrow
import ./fs/write.bend as FWrite
import ./json.bend as Json
import ./fs.bend as Fs
import ./act.bend as Act
import ./lock.bend as Lock
import ./poll.bend as Poll

Types

type Id source · line 41 · raw

Data

The identity a slot number currently maps to.

type Claim source · line 45 · raw

Data

A fetch lease: the slot and its fencing id.

type RR source · line 146 · raw

Data

type RAd source · line 210 · raw

Data

Definitions

def ActM source · line 25 · raw

@-A:Type -> Type

def ActM.pure source · line 28 · raw

@-A:Type -> @x:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(A)

def ActM.bind source · line 31 · raw

@-A:Type -> @-B:Type -> @m:0x0717344745a30ebad1f19045228e8f18/act.of(A) -> @f:(@_:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)) -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)

def usage_path source · line 34 · raw

@+root:String -> String

def usage_lock source · line 37 · raw

@+root:String -> String

def jv source · line 48 · raw

@+k:String -> @+j:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def jstr source · line 51 · raw

@s:String -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def fl source · line 55 · raw

@+t:U32 -> 0x0717344745a30ebad1f19045228e8f18/json.Json

An epoch as the reference stores it: a float.

def empty_rows source · line 58 · raw

0x0717344745a30ebad1f19045228e8f18/json.Json

def obj_or_empty source · line 61 · raw

@j:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def rows.pick source · line 68 · raw

@ok:Bool -> @+j:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def is_v2 source · line 75 · raw

@j:0x0717344745a30ebad1f19045228e8f18/json.Json -> Bool

def rows_of source · line 83 · raw

@+j:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/json.Json

The accounts object of a parsed usage.json; empty for any other schema.

def rows.parsed source · line 86 · raw

@r:Result<&2, &2, String, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def rows.text source · line 93 · raw

@r:0x0717344745a30ebad1f19045228e8f18/fs.Res(String) -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def read_rows source · line 101 · raw

@+root:String -> IO(0x0717344745a30ebad1f19045228e8f18/json.Json)

A missing, torn or other-version file reads as empty.

def matches source · line 104 · raw

@+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+id:Id -> Bool

def fresh_row source · line 110 · raw

@+id:Id -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def row.if source · line 115 · raw

@ok:Bool -> @+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>

def row.pick source · line 122 · raw

@m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> @+id:Id -> Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>

def row_of source · line 130 · raw

@+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+id:Id -> Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>

The stored row of a slot, only when it belongs to this identity.

def write_rows source · line 135 · raw

@+root:String -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def with_usage_lock source · line 140 · raw

@-A:Type -> @+root:String -> @act:0x0717344745a30ebad1f19045228e8f18/act.of(A) -> 0x0717344745a30ebad1f19045228e8f18/act.of(A)

def read_act source · line 143 · raw

@+root:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def claim_row source · line 149 · raw

@+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+claim:String -> @+now:U32 -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def reserve.take source · line 152 · raw

@+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+id:Id -> @+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+claim:String -> @+now:U32 -> @won:List<&2, Claim> -> RR

def reserve.fresh source · line 157 · raw

@+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+id:Id -> @+claim:String -> @+now:U32 -> @won:List<&2, Claim> -> RR

def reserve.stored source · line 160 · raw

@ok:Bool -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+id:Id -> @+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+claim:String -> @+now:U32 -> @won:List<&2, Claim> -> RR

def reserve.row source · line 167 · raw

@m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+id:Id -> @+claim:String -> @+now:U32 -> @+respect:Bool -> @+repair:Bool -> @won:List<&2, Claim> -> RR

def claim_id source · line 174 · raw

@+slot:String -> @+now:U32 -> @+tick:Nat -> String

def slot_of source · line 177 · raw

@+id:Id -> String

def reserve.go source · line 182 · raw

@ids:List<&2, Id> -> @rr:RR -> @+now:U32 -> @+respect:Bool -> @+repair:Bool -> @+tick:Nat -> RR

def reserve.write source · line 189 · raw

@won:List<&2, Claim> -> @+root:String -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/act.of(List<&2, Claim>)

def reserve.commit source · line 196 · raw

@+root:String -> @rr:RR -> 0x0717344745a30ebad1f19045228e8f18/act.of(List<&2, Claim>)

def reserve.act source · line 201 · raw

@+root:String -> @ids:List<&2, Id> -> @+now:U32 -> @+respect:Bool -> @+repair:Bool -> @+tick:Nat -> 0x0717344745a30ebad1f19045228e8f18/act.of(List<&2, Claim>)

def reserve source · line 207 · raw

@+root:String -> @ids:List<&2, Id> -> @+now:U32 -> @+respect:Bool -> @+repair:Bool -> @+tick:Nat -> 0x0717344745a30ebad1f19045228e8f18/act.of(List<&2, Claim>)

Atomically win the right to fetch: re-check each slot's eligibility and stamp a 90 s lease under the lock (UsageStore.reserve). respect is the on-demand mode (stale AND poll-due), repair also frees a reset-parked plan.