From 5391624c2a7cce15212301e29fce27c1f899e728 Mon Sep 17 00:00:00 2001 From: iko Date: Sun, 9 Jul 2023 12:17:46 +0300 Subject: [PATCH] Simplified %sink (#8) * Simplified %sink * Formatting --- example/urbit/app/journal.hoon | 15 +++++------ example/urbit/lib/sink.hoon | 47 +++++++++++++++++----------------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/example/urbit/app/journal.hoon b/example/urbit/app/journal.hoon index 412b3a1..11ad8f1 100644 --- a/example/urbit/app/journal.hoon +++ b/example/urbit/app/journal.hoon @@ -21,12 +21,11 @@ %- agent:dbug =/ state *state-0 -=/ snik - %+ sink ~[/sync] - |=(stat=versioned-state (tap:j-orm journal.stat)) -=/ sink (snik state) +=* entries (tap:j-orm journal.stat) +=/ snik (sink ~[/sync]) +=/ sink (snik entries) ^- agent:gall - +:: |_ =bowl:gall +* this . def ~(. (default-agent this %|) bowl) @@ -40,7 +39,7 @@ |= old-vase=vase ^- (quip card _this) =/ state !<(versioned-state old-vase) - `this(state state, sink (snik state)) + `this(state state, sink (snik entries)) :: ++ on-poke |= [=mark =vase] @@ -51,7 +50,7 @@ =/ now=@ (unique-time now.bowl log.state) =/ act !<(action vase) =. state (poke-action act) - =^ card sink (sync:sink state) + =^ card sink (sync:sink entries) :_ this(log.state (put:log-orm log.state now act)) ~[(fact:io journal-update+!>(`update`[now act]) ~[/updates]) card] :: @@ -93,7 +92,7 @@ [%all ~] :^ ~ ~ %journal-update !> ^- update - [now %jrnl (tap:j-orm journal.state)] + [now %jrnl entries] :: [%before @ @ ~] =/ before=@ (rash i.t.t.t.path dem) diff --git a/example/urbit/lib/sink.hoon b/example/urbit/lib/sink.hoon index 14b0b7c..fe08349 100644 --- a/example/urbit/lib/sink.hoon +++ b/example/urbit/lib/sink.hoon @@ -1,27 +1,26 @@ /+ noun-diff |% - ++ clog - |$ [stut] - $% - [%flush stut] - [%drain patch:noun-diff] - == - ++ sink - |* [pats=(list path) extract=$-(* *)] - |* stat=* - |@ - ++ sync - |= [stat=_stat] - ^- [card:agent:gall _..sync] - =/ dif - %+ diff:noun-diff (extract ^stat) (extract stat) - :- - ~& [%give %fact pats %noun !>(^-((clog) [%drain dif]))] - [%give %fact pats %noun !>(^-((clog) [%drain dif]))] - ..sync(stat stat) - ++ paths pats - ++ flush - ^- card:agent:gall - [%give %fact pats %noun !>(^-((clog) [%flush (extract stat)]))] - -- +++ clog + |$ [stut] + $% + [%flush stut] + [%drain patch:noun-diff] + == +++ sink + |* pats=(list path) + |* stat=* + |@ + ++ sync + |= [stat=_stat] + ^- [card:agent:gall _..sync] + =/ dif + %+ diff:noun-diff ^stat stat + :- + [%give %fact pats %noun !>(^-((clog) [%drain dif]))] + ..sync(stat stat) + ++ paths pats + ++ flush + ^- card:agent:gall + [%give %fact pats %noun !>(^-((clog) [%flush (extract stat)]))] + -- -- \ No newline at end of file