From eaf080b3b4dd9a659853315fc65227d08704a364 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 12 Apr 2018 16:47:44 +0200 Subject: [PATCH] Adapt state. --- app/hall.hoon | 96 +++++++++++++++++++++++++++++++++++++++++++++++++-- app/talk.hoon | 61 ++++++++++++++++++++++++++++++-- 2 files changed, 151 insertions(+), 6 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index b9c9936c15..f3bdba91e7 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -117,7 +117,7 @@ :> # :> functional cores and arms. :: -|_ {bol/bowl:gall $0 state} +|_ {bol/bowl:gall $1 state} :: :> # %transition :> prep transition @@ -127,7 +127,41 @@ :: => |% ++ states - $%({$0 s/state}) + $%({$1 s/state} {$0 s/state-0}) + :: + ++ state-0 + (cork state |=(a/state a(stories (~(run by stories.a) story-0)))) + ++ story-0 + %+ cork story + |= a/story + %= a + shape *config-0 + mirrors (~(run by mirrors.a) config-0) + peers (~(run by peers.a) |=(a/(list query) (turn a query-0))) + == + ++ query-0 + $? $: $circle + nom/name + wer/(unit circle) + wat/(set circle-data) + ran/range-0 + == + query + == + ++ config-0 + {src/(set source-0) cap/cord tag/tags fit/filter con/control} + ++ source-0 + {cir/circle ran/range-0} + ++ range-0 + %- unit + $: hed/place-0 + tal/(unit place-0) + == + ++ place-0 + $% {$da @da} + {$ud @ud} + {$sd @sd} + == -- =| mos/(list move) |= old/(unit states) @@ -136,8 +170,64 @@ %- pre-bake ta-done:ta-init:ta ?- -.u.old - $0 + $1 [mos ..prep(+<+ u.old)] + :: + $0 + =- $(old `[%1 s.u.old(stories -)]) + |^ %- ~(run by stories.s.u.old) + |= soy/story-0 + ^- story + %= soy + shape (prep-config shape.soy) + mirrors (~(run by mirrors.soy) prep-config) + peers %- ~(run by peers.soy) + |= a/(list query-0) + ^- (list query) + (murn a prep-query) + == + :: + ++ prep-config + |= cof/config-0 + ^- config + %= cof + src + %- ~(gas in *(set source)) + (murn ~(tap in src.cof) prep-source) + == + :: + ++ prep-source + |= src/source-0 + ^- (unit source) + =+ nan=(prep-range ran.src) + ?~ nan + ~& [%forgetting-source src] + ~ + `src(ran u.nan) + :: + ++ prep-query + |= que/query-0 + ^- (unit query) + ?. ?=($circle -.que) `que + =+ nan=(prep-range ran.que) + ?~ nan + ~& [%forgetting-query que] + ~ + `que(ran u.nan) + :: + ++ prep-range + |= ran/range-0 + ^- (unit range) + ?~ ran `ran + :: ranges with a relative end aren't stored because they end + :: immediately, so if we find one we can safely discard it. + ?: ?=({$~ {$sd @sd}} tal.u.ran) ~ + :: we replace relative range starts with the current date. + :: this is practically correct. + ?: ?=({$sd @sd} hed.u.ran) + `ran(hed.u [%da now.bol]) + `ran + -- == :: :> # %engines diff --git a/app/talk.hoon b/app/talk.hoon index 00d63b0a86..17684be676 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -113,7 +113,7 @@ :> # :> functional cores and arms. :: -|_ {bol/bowl:gall $0 state} +|_ {bol/bowl:gall $1 state} :: :> # %transition :> prep transition @@ -124,7 +124,24 @@ :: => |% ++ states - $%({$0 s/state}) + $%({$1 s/state} {$0 s/state-0}) + :: + ++ state-0 + (cork state |=(a/state a(mirrors (~(run by mirrors.a) config-0)))) + ++ config-0 + {src/(set source-0) cap/cord tag/tags fit/filter con/control} + ++ source-0 + {cir/circle ran/range-0} + ++ range-0 + %- unit + $: hed/place-0 + tal/(unit place-0) + == + ++ place-0 + $% {$da @da} + {$ud @ud} + {$sd @sd} + == -- =| mos/(list move) |= old/(unit states) @@ -132,8 +149,46 @@ ?~ old ta-done:ta-init:ta ?- -.u.old - $0 + $1 [mos ..prep(+<+ u.old)] + :: + $0 + =. mos [[ost.bol %pull /server/inbox server ~] peer-inbox mos] + =- $(old `[%1 s.u.old(mirrors -)]) + |^ + (~(run by mirrors.s.u.old) prep-config) + :: + ++ prep-config + |= cof/config-0 + ^- config + %= cof + src + %- ~(gas in *(set source)) + (murn ~(tap in src.cof) prep-source) + == + :: + ++ prep-source + |= src/source-0 + ^- (unit source) + =+ nan=(prep-range ran.src) + ?~ nan + ~& [%forgetting-source src] + ~ + `src(ran u.nan) + :: + ++ prep-range + |= ran/range-0 + ^- (unit range) + ?~ ran `ran + :: ranges with a relative end aren't stored because they end + :: immediately, so if we find one we can safely discard it. + ?: ?=({$~ {$sd @sd}} tal.u.ran) ~ + :: we replace relative range starts with the current date. + :: this is practically correct. + ?: ?=({$sd @sd} hed.u.ran) + `ran(hed.u [%da now.bol]) + `ran + -- == :: :> #