Skip to content

Commit

Permalink
Simplified %sink (#8)
Browse files Browse the repository at this point in the history
* Simplified %sink

* Formatting
  • Loading branch information
ilyakooo0 authored Jul 9, 2023
1 parent 8168841 commit 5391624
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
15 changes: 7 additions & 8 deletions example/urbit/app/journal.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand All @@ -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]
::
Expand Down Expand Up @@ -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)
Expand Down
47 changes: 23 additions & 24 deletions example/urbit/lib/sink.hoon
Original file line number Diff line number Diff line change
@@ -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)]))]
--
--

0 comments on commit 5391624

Please sign in to comment.