big merge, including some Alef and Zuse work

This commit is contained in:
Ted Blackman 2019-10-30 16:12:57 -04:00
commit 21dabb8895
27 changed files with 1973 additions and 3624 deletions

View File

@ -61,23 +61,45 @@
=. this =. this
?+ -.q.i.ufs.afs this ?+ -.q.i.ufs.afs this
%restore (handle-restore who.afs) %restore (handle-restore who.afs)
%send (handle-send i.ufs.afs) %send (handle-send who.afs i.ufs.afs)
== ==
$(ufs.afs t.ufs.afs) $(ufs.afs t.ufs.afs)
:: ::
++ handle-restore ++ handle-restore
|= who=@p |= who=@p
%- emit-aqua-events %- emit-aqua-events
[%event who [//newt/0v1n.2m9vh %barn ~]]~ [%event who [//newt/0v1n.2m9vh %born ~]]~
:: ::
++ handle-send ++ handle-send
|= [way=wire %send lan=lane:ames pac=@] |= [sndr=ship way=wire %send lan=lane:ames pac=@]
^+ this ^+ this
=/ hear [//newt/0v1n.2m9vh %hear lan pac] =/ rcvr=ship (lane-to-ship lan)
=? ships =(~ ships) =/ hear-lane (ship-to-lane sndr)
.^((list ship) %gx /(scot %p our)/aqua/(scot %da now)/ships/noun) => ?. ?| =(rcvr ~linnup-torsyx-linnup-torsyx)
=(sndr ~linnup-torsyx-linnup-torsyx)
==
.
~> %slog.0^leaf/"aqua: {(scow %p sndr)} -> {(scow %p rcvr)}"
.
%- emit-aqua-events %- emit-aqua-events
%+ turn ships [%event rcvr //newt/0v1n.2m9vh %hear hear-lane pac]~
|= who=ship :: +lane-to-ship: decode a ship from an aqua lane
[%event who hear] ::
++ lane-to-ship
|= =lane:ames
^- ship
::
?- -.lane
%& p.lane
%| `ship``@`p.lane
==
:: +ship-to-lane: encode a lane to look like it came from .ship
::
:: Never shows up as a galaxy, because Vere wouldn't know that either.
::
++ ship-to-lane
|= =ship
^- lane:ames
::
[%| `address:ames``@`ship]
-- --

View File

@ -359,7 +359,7 @@
%^ slum installed.boot-ova.pil now.hid %^ slum installed.boot-ova.pil now.hid
=/ vane =/ vane
?+ v ~|([%unknown-vane v] !!) ?+ v ~|([%unknown-vane v] !!)
%a %ames %a %alef
%b %behn %b %behn
%c %clay %c %clay
%d %dill %d %dill
@ -428,7 +428,7 @@
^- (list unix-event) ^- (list unix-event)
:~ [/ %wack 0] :: eny :~ [/ %wack 0] :: eny
[/ %whom who.ae] :: eny [/ %whom who.ae] :: eny
[//newt/0v1n.2m9vh %barn ~] [//newt/0v1n.2m9vh %born ~]
[//behn/0v1n.2m9vh %born ~] [//behn/0v1n.2m9vh %born ~]
:^ //term/1 %boot & :^ //term/1 %boot &
?~ keys.ae ?~ keys.ae

View File

@ -306,7 +306,7 @@
=* walk-loop $ =* walk-loop $
?: (gth number.state number.id.latest-block) ?: (gth number.state number.id.latest-block)
;< now=@da bind:m get-time:stdio ;< now=@da bind:m get-time:stdio
;< ~ bind:m (wait-effect:stdio (add now ~m5)) ;< ~ bind:m (wait-effect:stdio (add now ~s5))
(pure:m state) (pure:m state)
;< =block bind:m (get-block-by-number url.state number.state) ;< =block bind:m (get-block-by-number url.state number.state)
;< [=new=pending-udiffs new-blocks=(lest ^block)] bind:m ;< [=new=pending-udiffs new-blocks=(lest ^block)] bind:m

View File

@ -128,6 +128,109 @@
~& > %bud-done ~& > %bud-done
(send-hi ~bud ~dev) (send-hi ~bud ~dev)
(pure:m ~) (pure:m ~)
::
:+ %hi-marbud-az
~[~bud ~marbud]
=. eth-node (spawn:eth-node ~marbud)
;< [eth-node=_eth-node ~] bind:m
%+ (wrap-philter ,_eth-node ,~)
router:eth-node
;< ~ bind:m (raw-real-ship:eth-node ~marbud)
~& > 'MARBUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~bud)
~& > 'BUD-DONE'
(send-hi ~bud ~marbud)
(pure:m ~)
::
:+ %hi-uncle-az
~[~bud ~marbud ~dev]
=. eth-node (spawn:eth-node ~marbud)
=. eth-node (spawn:eth-node ~dev)
;< [eth-node=_eth-node ~] bind:m
%+ (wrap-philter ,_eth-node ,~)
router:eth-node
;< ~ bind:m (raw-real-ship:eth-node ~bud)
~& > 'BUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~marbud)
~& > 'MARBUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~dev)
~& > 'BUD-DONE'
(send-hi ~marbud ~dev)
~& > 'HI DONE'
(pure:m ~)
::
:+ %hi-nephew-az
~[~bud ~marbud ~dev]
=. eth-node (spawn:eth-node ~marbud)
=. eth-node (spawn:eth-node ~dev)
;< [eth-node=_eth-node ~] bind:m
%+ (wrap-philter ,_eth-node ,~)
router:eth-node
;< ~ bind:m (raw-real-ship:eth-node ~bud)
~& > 'BUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~marbud)
~& > 'MARBUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~dev)
~& > 'BUD-DONE'
(send-hi ~dev ~marbud)
~& > 'HI DONE'
(pure:m ~)
::
:+ %hi-cousin-az
~[~bud ~marbud ~dev ~mardev]
=. eth-node (spawn:eth-node ~marbud)
=. eth-node (spawn:eth-node ~dev)
=. eth-node (spawn:eth-node ~mardev)
;< [eth-node=_eth-node ~] bind:m
%+ (wrap-philter ,_eth-node ,~)
router:eth-node
;< ~ bind:m (raw-real-ship:eth-node ~bud)
~& > 'BUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~marbud)
~& > 'MARBUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~dev)
~& > 'BUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~mardev)
~& > 'MARDEV-DONE'
(send-hi ~mardev ~marbud)
~& > 'HI DONE'
(pure:m ~)
::
:+ %hi-linnup-az
~[~bud ~marbud ~linnup-torsyx]
=. eth-node (spawn:eth-node ~marbud)
=. eth-node (spawn:eth-node ~linnup-torsyx)
;< [eth-node=_eth-node ~] bind:m
%+ (wrap-philter ,_eth-node ,~)
router:eth-node
;< ~ bind:m (raw-real-ship:eth-node ~bud)
~& > 'BUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~marbud)
~& > 'MARBUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~linnup-torsyx)
~& > 'LINNUP DONE'
;< ~ bind:m (send-hi ~linnup-torsyx ~marbud)
~& > 'HI DONE-------------------------------'
(pure:m ~)
(pure:m ~)
::
:+ %hi-linnup-az-backward
~[~bud ~marbud ~linnup-torsyx]
=. eth-node (spawn:eth-node ~marbud)
=. eth-node (spawn:eth-node ~linnup-torsyx)
;< [eth-node=_eth-node ~] bind:m
%+ (wrap-philter ,_eth-node ,~)
router:eth-node
;< ~ bind:m (raw-real-ship:eth-node ~linnup-torsyx)
~& > 'LINNUP DONE'
;< ~ bind:m (raw-real-ship:eth-node ~marbud)
~& > 'MARBUD-DONE'
;< ~ bind:m (raw-real-ship:eth-node ~bud)
~& > 'BUD-DONE'
;< ~ bind:m (send-hi ~linnup-torsyx ~marbud)
~& > 'HI DONE-------------------------------'
(pure:m ~)
(pure:m ~)
:: ::
:+ %moon-az :+ %moon-az
~[~bud ~marbud ~linnup-torsyx ~linnup-torsyx-linnup-torsyx ~dev] ~[~bud ~marbud ~linnup-torsyx ~linnup-torsyx-linnup-torsyx ~dev]
@ -193,18 +296,27 @@
%+ (wrap-philter ,_eth-node ,~) %+ (wrap-philter ,_eth-node ,~)
router:eth-node router:eth-node
;< ~ bind:m (raw-real-ship:eth-node ~bud) ;< ~ bind:m (raw-real-ship:eth-node ~bud)
~& > 'BUD DONE'
;< ~ bind:m (raw-real-ship:eth-node ~dev) ;< ~ bind:m (raw-real-ship:eth-node ~dev)
~& > 'DEV DONE'
;< ~ bind:m (raw-real-ship:eth-node ~marbud) ;< ~ bind:m (raw-real-ship:eth-node ~marbud)
~& > 'MARBUD DONE'
;< ~ bind:m (raw-real-ship:eth-node ~mardev) ;< ~ bind:m (raw-real-ship:eth-node ~mardev)
~& > 'MARDEV DONE'
(send-hi ~marbud ~mardev) (send-hi ~marbud ~mardev)
~& > 'HI MARBUD MARDEV'
;< eth-node=_eth-node bind:m ;< eth-node=_eth-node bind:m
(breach-and-hear:eth-node our.hid ~mardev ~marbud) (breach-and-hear:eth-node our.hid ~mardev ~marbud)
~& > 'BREACH MARDEV'
;< [eth-node=_eth-node ~] bind:m ;< [eth-node=_eth-node ~] bind:m
%+ (wrap-philter ,_eth-node ,~) %+ (wrap-philter ,_eth-node ,~)
router:eth-node router:eth-node
;< ~ bind:m (send-hi-not-responding ~marbud ~mardev) ;< ~ bind:m (send-hi-not-responding ~marbud ~mardev)
~& > 'HI NOT RESPONDING'
;< ~ bind:m (raw-real-ship:eth-node ~mardev) ;< ~ bind:m (raw-real-ship:eth-node ~mardev)
~& > 'MARDEV RE DONE'
(wait-for-dojo ~marbud "hi ~mardev successful") (wait-for-dojo ~marbud "hi ~mardev successful")
~& > 'DONE'
(pure:m ~) (pure:m ~)
:: ::
:+ %breach-sync :+ %breach-sync
@ -298,9 +410,11 @@
;< [eth-node=_eth-node ~] bind:m ;< [eth-node=_eth-node ~] bind:m
%+ (wrap-philter ,_eth-node ,~) %+ (wrap-philter ,_eth-node ,~)
router:eth-node router:eth-node
;< ~ bind:m (raw-real-ship:eth-node ~bud) ;< ~ bind:m (raw-real-ship:eth-node ~bud)
~& > 'BUD RE DONE' ~& > 'BUD RE DONE'
;< ~ bind:m (just-events (dojo ~bud "|merge %base ~marbud %kids, =gem %this")) ;< ~ bind:m (send-hi ~bud ~marbud)
~& > 'BUD HI MARBUD'
;< ~ bind:m (just-events (dojo ~bud "|merge %base ~marbud %kids, =gem %this"))
~& > 'THIS MERGE STARTED DONE' ~& > 'THIS MERGE STARTED DONE'
;< file=@t bind:m (touch-file ~bud %base) ;< file=@t bind:m (touch-file ~bud %base)
~& > 'TOUCH-1 DONE' ~& > 'TOUCH-1 DONE'

86
pkg/arvo/app/ping.hoon Normal file
View File

@ -0,0 +1,86 @@
=* point point:able:kale
::
=> |%
+$ app-state ~
+$ move [=bone =card]
+$ card
$% [%poke =wire [=ship app=term] =action]
[%wait =wire date=@da]
==
+$ action
$% [%noun ~]
==
--
::
=> |%
:: +print-error: maybe +slog
::
++ print-error
|= [=tape error=(unit tang)]
^+ same
?~ error same
%- (slog leaf+tape u.error) same
--
::
|_ [=bowl:gall state=app-state]
::
+| %entry-points
::
:: +prep: (re)load, initializing on startup
::
++ prep
|= old=(unit app-state)
^- [(list move) _app-core]
:: reload; no-op
::
?^ old
[~ app-core(state u.old)]
:: first load; galaxies no-op; everyone else pings sponsor
::
?: =(%czar (clan:title our.bowl))
[~ app-core]
~> %slog.0^leaf/"ping: prep {<our.bowl>}"
send-ping
:: +coup-ping-send: handle ames ack
::
++ coup-ping-send
|= [=wire error=(unit tang)]
^- [(list move) _app-core]
::
%- (print-error "ping: coup" error)
set-timer
:: +wake: handle timer firing
::
++ wake-ping-wait
|= [=wire error=(unit tang)]
^- [(list move) _app-core]
::
%- (print-error "ping: wake" error)
send-ping
:: +poke-noun: handle request; no-op to ack, crash to nack
::
++ poke-noun
|= *
[~ app-core]
::
+| %helpers
::
++ app-core .
:: +set-timer: send a move to behn to set a timer
::
++ set-timer
^- [(list move) _app-core]
::
:_ app-core
[ost.bowl %wait /ping-wait `@da`(add ~s30 now.bowl)]~
:: +send-ping: scry our sponsor from jael and poke their %ping app
::
++ send-ping
^- [(list move) _app-core]
::
=/ sponsor=ship (sein:title [our now our]:bowl)
::
~> %slog.0^leaf/"ping: {<our.bowl>} -> {<sponsor>}"
:_ app-core
[ost.bowl %poke /ping-send [sponsor %ping] %noun ~]~
--

View File

@ -25,9 +25,9 @@
:~ :: sys/zuse: standard library :~ :: sys/zuse: standard library
:: ::
[%$ /zuse] [%$ /zuse]
:: sys/vane/ames: network :: sys/vane/alef: network
:: ::
[%a /vane/ames] [%a /vane/alef]
:: sys/vane/behn: timer :: sys/vane/behn: timer
:: ::
[%b /vane/behn] [%b /vane/behn]
@ -49,7 +49,7 @@
:: sys/vane/iris: http client :: sys/vane/iris: http client
:: ::
[%i /vane/iris] [%i /vane/iris]
:: sys/vane/jael: security :: sys/vane/kale: security
:: ::
[%j /vane/jael] [%j /vane/jael]
== ==

View File

@ -349,8 +349,15 @@
|= [our=@p now=@da ship=@p =life] |= [our=@p now=@da ship=@p =life]
^- @udpoint ^- @udpoint
:: ::
=/ d=deed:ames =/ d=[=^life =pass]
.^(deed:ames j+/(scot %p our)/deed/(scot %da now)/(scot %p ship)/(scot %ud life)) =/ scry-path=path
:~ %k
(scot %p our)
(scot %da now)
(scot %p ship)
(scot %ud life)
==
.^([^life pass] scry-path)
:: we have the deed which has pass, which is several numbers +cat-ed :: we have the deed which has pass, which is several numbers +cat-ed
:: together; pull out the keys :: together; pull out the keys
:: ::
@ -370,7 +377,7 @@
[participants keys] [participants keys]
:: ::
=/ =life =/ =life
.^(life j+/(scot %p our)/life/(scot %da now)/(scot %p i.invited)) .^(life k+/(scot %p our)/life/(scot %da now)/(scot %p i.invited))
:: ::
?: =(life 0) ?: =(life 0)
$(invited t.invited) $(invited t.invited)
@ -429,11 +436,11 @@
:: get our ships' current life :: get our ships' current life
:: ::
=/ our-life=life =/ our-life=life
.^(life %j /(scot %p our)/life/(scot %da now)/(scot %p our)) .^(life %k /(scot %p our)/life/(scot %da now)/(scot %p our))
:: get our ships' secret keyfile ring :: get our ships' secret keyfile ring
:: ::
=/ secret-ring=ring =/ secret-ring=ring
.^(ring %j /(scot %p our)/vein/(scot %da now)/(scot %ud our-life)) .^(ring %k /(scot %p our)/vein/(scot %da now)/(scot %ud our-life))
:: fetch the encoded auth seed from the ring :: fetch the encoded auth seed from the ring
:: ::
=/ secret-auth-seed=@ =/ secret-auth-seed=@

View File

@ -256,14 +256,10 @@
++ slur-e ~/(%slur-e |=({gat/vase hil/mill} =+(%e (slur gat hil)))) ++ slur-e ~/(%slur-e |=({gat/vase hil/mill} =+(%e (slur gat hil))))
++ slur-f ~/(%slur-f |=({gat/vase hil/mill} =+(%f (slur gat hil)))) ++ slur-f ~/(%slur-f |=({gat/vase hil/mill} =+(%f (slur gat hil))))
++ slur-g ~/(%slur-g |=({gat/vase hil/mill} =+(%g (slur gat hil)))) ++ slur-g ~/(%slur-g |=({gat/vase hil/mill} =+(%g (slur gat hil))))
++ slur-i ~/(%slur-i |=({gat/vase hil/mill} =+(%i (slur gat hil))))
++ slur-j ~/(%slur-j |=({gat/vase hil/mill} =+(%j (slur gat hil)))) ++ slur-j ~/(%slur-j |=({gat/vase hil/mill} =+(%j (slur gat hil))))
++ slur-k ~/(%slur-k |=({gat/vase hil/mill} =+(%k (slur gat hil))))
++ slur-z ~/(%slur-z |=({gat/vase hil/mill} =+(%z (slur gat hil)))) ++ slur-z ~/(%slur-z |=({gat/vase hil/mill} =+(%z (slur gat hil))))
++ slur-r
~/ %slur-r
|=({gat/vase hil/mill} =+(%r (slur gat hil)))
++ slur-l
~/ %slur-l
|=({gat/vase hil/mill} =+(%l (slur gat hil)))
:: ::
++ slur-pro :: profiling slur ++ slur-pro :: profiling slur
~/ %slur-pro ~/ %slur-pro
@ -276,10 +272,9 @@
$e (slur-e gat hil) $e (slur-e gat hil)
$f (slur-f gat hil) $f (slur-f gat hil)
$g (slur-g gat hil) $g (slur-g gat hil)
$i (slur-i gat hil)
$j (slur-j gat hil) $j (slur-j gat hil)
:: $k (slur-k gat hil)
%l (slur-l gat hil)
%r (slur-r gat hil)
== ==
:: ::
++ song :: reduce metacard ++ song :: reduce metacard

View File

@ -14912,7 +14912,7 @@
^= gen ^- hoon ^= gen ^- hoon
[%cnsg [%$ ~] [%$ 2] [%$ 3] ~] [%cnsg [%$ ~] [%$ 2] [%$ 3] ~]
=+ gun=(~(mint ut typ) %noun gen) =+ gun=(~(mint ut typ) %noun gen)
[p.gun .*([q.gat q.sam] q.gun)] [p.gun (slum q.gat q.sam)]
:: ::
++ slab :: test if contains ++ slab :: test if contains
|= {cog/@tas typ/type} |= {cog/@tas typ/type}
@ -17316,44 +17316,49 @@
~> %slog.[0 foo] ~> %slog.[0 foo]
[| +>+<.$] [| +>+<.$]
[& +>+<.$(nes (~(put in nes) [sut ref]))] [& +>+<.$(nes (~(put in nes) [sut ref]))]
:: +play: +play:ut, cached
:: ::
++ play :: play:ut ++ play
|= {sut/type gen/hoon} |= {sut/type gen/hoon}
^- {type worm} ^- {type worm}
=+ old=(~(get by pay) [sut gen]) =+ old=(~(get by pay) [sut gen])
?^ old [u.old +>+<.$] ?^ old [u.old +>+<.$]
=+ new=(~(play ut sut) gen) =+ new=(~(play ut sut) gen)
[new +>+<.$(pay (~(put by pay) [sut gen] new))] [new +>+<.$(pay (~(put by pay) [sut gen] new))]
:: +mint: +mint:ut to noun, cached
:: ::
++ mint :: mint:ut to noun ++ mint
|= {sut/type gen/hoon} |= {sut/type gen/hoon}
^- {(pair type nock) worm} ^- {(pair type nock) worm}
=+ old=(~(get by mit) [sut gen]) =+ old=(~(get by mit) [sut gen])
?^ old [u.old +>+<.$] ?^ old [u.old +>+<.$]
=+ new=(~(mint ut sut) %noun gen) =+ new=(~(mint ut sut) %noun gen)
[new +>+<.$(mit (~(put by mit) [sut gen] new))] [new +>+<.$(mit (~(put by mit) [sut gen] new))]
:: +slam: +slam:ut, cached
:: ::
++ slam :: ++slam, cached ++ slam
|= [gat=vase sam=vase] |= [gat=vase sam=vase]
^- [vase worm]
=/ sut=type [%cell p.gat p.sam] =/ sut=type [%cell p.gat p.sam]
=/ gen=hoon [%cnsg [%$ ~] [%$ 2] [%$ 3] ~] =/ gen=hoon [%cnsg [%$ ~] [%$ 2] [%$ 3] ~]
=^ new=type +>+<.$ (play sut gen) =^ new=type +>+<.$ (play sut gen)
[[new (slum q.gat q.sam)] +>+<.$] [[new (slum q.gat q.sam)] +>+<.$]
:: +slap: +slap:ut, cached
:: ::
++ slap :: ++slap, cached ++ slap
|= {vax/vase gen/hoon} |= {vax/vase gen/hoon}
^- {vase worm} ^- {vase worm}
=^ gun +>+< (mint p.vax gen) =^ gun +>+< (mint p.vax gen)
[[p.gun .*(q.vax q.gun)] +>+<.$] [[p.gun .*(q.vax q.gun)] +>+<.$]
:: +slot: +slot:ut, cached
:: ::
++ slot :: ++slot, cached ++ slot
|= {axe/@ vax/vase} |= {axe/@ vax/vase}
^- {vase worm} ^- {vase worm}
=^ gun +>+< (mint p.vax [%$ axe]) =^ gun +>+< (mint p.vax [%$ axe])
[[p.gun .*(q.vax [0 axe])] +>+<.$] [[p.gun .*(q.vax [0 axe])] +>+<.$]
:: +slym: +slym:ut, cached
:: ::
++ slym :: ++slym, cached ++ slym
|= {gat/vase sam/*} |= {gat/vase sam/*}
^- [vase worm] ^- [vase worm]
(slap gat(+<.q sam) [%limb %$]) (slap gat(+<.q sam) [%limb %$])

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,8 @@
:: ::
?: =(~ timers.state) ~| %behn-crud-no-timer^tag^error !! ?: =(~ timers.state) ~| %behn-crud-no-timer^tag^error !!
:: ::
~& %behn-crud-tag^tag
%- (slog error)
(wake `error) (wake `error)
:: +rest: cancel the timer at :date, then adjust unix wakeup :: +rest: cancel the timer at :date, then adjust unix wakeup
:: +wait: set a new timer at :date, then adjust unix wakeup :: +wait: set a new timer at :date, then adjust unix wakeup

View File

@ -471,7 +471,7 @@
++ note :: out request $-> ++ note :: out request $->
$~ [%b %wait *@da] :: $~ [%b %wait *@da] ::
$% $: %a :: to %ames $% $: %a :: to %ames
$>(%want task:able:ames) :: $>(%plea task:able:ames) ::
== :: == ::
$: %b :: to %behn $: %b :: to %behn
$> $? %drip :: $> $? %drip ::
@ -508,8 +508,9 @@
$% [%init-clad ~] :: $% [%init-clad ~] ::
== == :: == == ::
$: %a :: by %ames $: %a :: by %ames
$> $? %send :: XX strange $> $? %boon :: response
%woot :: %done :: (n)ack
%lost :: lost boon
== :: == ::
gift:able:ames :: gift:able:ames ::
== :: == ::
@ -2685,7 +2686,7 @@
%- (sloy-light ski) %- (sloy-light ski)
=/ pur=spur =/ pur=spur
/(scot %p who) /(scot %p who)
[[151 %noun] %j our %rift da+now pur] [[151 %noun] %k our %rift da+now pur]
:: ::
:: Handle `%sing` requests :: Handle `%sing` requests
:: ::
@ -2808,8 +2809,13 @@
:: Transfer a request to another ship's clay. :: Transfer a request to another ship's clay.
:: ::
++ send-over-ames ++ send-over-ames
|= {a/duct b/path c/ship d/{p/@ud q/riff}} |= [=duct =ship index=@ud =riff]
(emit a %pass b %a %want c [%c %question p.q.d (scot %ud p.d) ~] q.d) ^+ +>
::
=/ =desk p.riff
=/ =wire /warp-index/(scot %p ship)/(scot %tas desk)/(scot %ud index)
=/ =path [%question desk (scot %ud index) ~]
(emit duct %pass wire %a %plea ship %c path riff)
:: ::
:: Create a request that cannot be filled immediately. :: Create a request that cannot be filled immediately.
:: ::
@ -2833,7 +2839,7 @@
=+ inx=nix.u.ref =+ inx=nix.u.ref
=. +>+.$ =. +>+.$
=< ?>(?=(^ ref) .) =< ?>(?=(^ ref) .)
(send-over-ames hen [(scot %ud inx) ~] her inx syd ~ rave) (send-over-ames hen her inx syd `rave)
%= +>+.$ %= +>+.$
nix.u.ref +(nix.u.ref) nix.u.ref +(nix.u.ref)
bom.u.ref (~(put by bom.u.ref) inx [hen rave]) bom.u.ref (~(put by bom.u.ref) inx [hen rave])
@ -2931,12 +2937,21 @@
?: |(?=(%& -.w) (~(has by cez) p.w)) s ?: |(?=(%& -.w) (~(has by cez) p.w)) s
(~(put in s) p.w) (~(put in s) p.w)
?^ mis ?^ mis
=- (emit hen %give %mack `[%leaf "No such group(s): {-}"]~) :: TODO remove this nasty hack
::
?. ?=([[%a *] *] hen)
+>.$
=- (emit hen %give %done `[%perm-fail [%leaf "No such group(s): {-}"]~])
%+ roll ~(tap in `(set @ta)`mis) %+ roll ~(tap in `(set @ta)`mis)
|= {g/@ta t/tape} |= {g/@ta t/tape}
?~ t (trip g) ?~ t (trip g)
:(weld t ", " (trip g)) :(weld t ", " (trip g))
=< (emit hen %give %mack ~) :: TODO remove this nasty hack
::
=< ?. ?=([[%a *] *] hen)
.
(emit hen %give %done ~)
::
?- -.rit ?- -.rit
$r wake(per (put-perm per pax red.rit)) $r wake(per (put-perm per pax red.rit))
$w wake(pew (put-perm pew pax wit.rit)) $w wake(pew (put-perm pew pax wit.rit))
@ -2987,7 +3002,7 @@
=: fod.u.ref (~(del by fod.u.ref) hen) =: fod.u.ref (~(del by fod.u.ref) hen)
bom.u.ref (~(del by bom.u.ref) u.nux) bom.u.ref (~(del by bom.u.ref) u.nux)
== ==
(send-over-ames hen [(scot %ud u.nux) ~] her u.nux syd ~) (send-over-ames hen her u.nux syd ~)
:: ::
:: Handles a request. :: Handles a request.
:: ::
@ -4128,7 +4143,7 @@
=| mos/(list move) =| mos/(list move)
=/ des ~(tap in ~(key by dos.rom.ruf)) =/ des ~(tap in ~(key by dos.rom.ruf))
|- |-
?~ des [[[hen %give %mack ~] mos] ..^^$] ?~ des [[[hen %give %done ~] mos] ..^^$]
=/ den ((de our now ski hen ruf) our i.des) =/ den ((de our now ski hen ruf) our i.des)
=^ mor ruf =^ mor ruf
=< abet:wake =< abet:wake
@ -4339,25 +4354,19 @@
(start-request:den for u.q.rif) (start-request:den for u.q.rif)
[mos ..^$] [mos ..^$]
:: ::
%west %plea
=* wer p.req =* her ship.req
=* pax q.req =* pax path.plea.req
=* res r.req =* res payload.plea.req
?: ?=({%question *} pax) ::
=+ ryf=;;(riff res) ?> ?=({%question *} pax)
:_ ..^$ =+ ryf=;;(riff res)
:~ [hen %give %mack ~] :_ ..^$
=/ =wire :~ [hen %give %done ~]
[(scot %p our) (scot %p wer) t.pax] =/ =wire
[hen %pass wire %c %werp wer our ryf] [%foreign-warp (scot %p her) t.pax]
== [hen %pass wire %c %werp her our ryf]
?> ?=({%answer @ @ ~} pax) ==
=+ syd=(slav %tas i.t.pax)
=+ inx=(slav %ud i.t.t.pax)
=^ mos ruf
=/ den ((de our now ski hen ruf) wer syd)
abet:(take-foreign-answer:den inx ;;((unit rand) res))
[[[hen %give %mack ~] mos] ..^$]
:: ::
%wegh %wegh
:_ ..^$ :_ ~ :_ ..^$ :_ ~
@ -4438,6 +4447,11 @@
abet:(take-mount:den q.hin) abet:(take-mount:den q.hin)
[mos ..^$] [mos ..^$]
:: ::
?: ?=([%foreign-warp *] tea)
?> ?=(%writ +<.q.hin)
:_ ..^$
[hen %give %boon `(unit rand)`(bind `riot`p.q.hin rant-to-rand)]~
::
?: ?=([%foreign-request @ @ @ *] tea) ?: ?=([%foreign-request @ @ @ *] tea)
=/ her (slav %p i.t.tea) =/ her (slav %p i.t.tea)
=/ syd (slav %tas i.t.t.tea) =/ syd (slav %tas i.t.t.tea)
@ -4471,6 +4485,35 @@
`cage`(result-to-cage:ford build-result.result.q.hin) `cage`(result-to-cage:ford build-result.result.q.hin)
== == == ==
:: ::
?: ?=([%warp-index @ @ @ ~] tea)
?+ +<.q.hin ~| %clay-warp-index-strange !!
%done
?~ error.q.hin
[~ ..^$]
:: TODO better error handling
::
~& %clay-take-warp-index-error^our^tea^tag.u.error.q.hin
%- (slog tang.u.error.q.hin)
[~ ..^$]
::
%lost
~| %clay-take-lost^our
:: TODO better error handling
!!
::
%boon
=+ ;; res=(unit rand) payload.q.hin
::
=/ her=ship (slav %p i.t.tea)
=/ =desk (slav %tas i.t.t.tea)
=/ index=@ud (slav %ud i.t.t.t.tea)
::
=^ mos ruf
=/ den ((de our now ski hen ruf) her desk)
abet:(take-foreign-answer:den index res)
[mos ..^$]
==
::
?: ?=([%sinks ~] tea) ?: ?=([%sinks ~] tea)
?> ?=(%public-keys +<.q.hin) ?> ?=(%public-keys +<.q.hin)
?: ?=(%full -.public-keys-result.q.hin) ?: ?=(%full -.public-keys-result.q.hin)
@ -4566,28 +4609,17 @@
:: ::
(handle-task hen queued-task) (handle-task hen queued-task)
:: ::
%writ :: handled in the wire dispatcher
?> ?=({@ @ *} tea) ::
~| i=i.tea %boon !!
~| it=i.t.tea %lost !!
=+ him=(slav %p i.t.tea) %writ !!
:_ ..^$
:~ :* hen %pass /writ-want %a
%want him [%c %answer t.t.tea]
(bind p.+.q.hin rant-to-rand)
==
==
:: ::
%send %done
[[[hen %give +.q.hin] ~] ..^$] ?~ error=error.q.hin
::
%woot
?~ q.q.hin
[~ ..^$] [~ ..^$]
~& [%clay-lost p.q.hin tea] ~& [%clay-lost u.error tea]
?~ u.q.q.hin %- (slog >tag.u.error< tang.u.error)
[~ ..^$]
%- (slog >p.u.u.q.q.hin< q.u.u.q.q.hin)
[~ ..^$] [~ ..^$]
== ==
:: ::
@ -4647,5 +4679,5 @@
%- (sloy-light ski) %- (sloy-light ski)
=/ pur=spur =/ pur=spur
/(scot %p who) /(scot %p who)
[[151 %noun] %j our %rift da+now pur] [[151 %noun] %k our %rift da+now pur]
-- --

View File

@ -93,19 +93,14 @@
++ sign :: in result $<- ++ sign :: in result $<-
$~ [%j %init *@p] :: $~ [%j %init *@p] ::
$% $: %a :: $% $: %a ::
$% [%nice ~] :: XX obsolete $% $>(%mass gift:able:ames) ::
$> $? %mass ::
%send :: XX strange
== ::
gift:able:ames ::
== == :: == == ::
$: %b :: $: %b ::
$% $>(%mass gift:able:behn) :: $% $>(%mass gift:able:behn) ::
$>(%writ gift:able:clay) :: XX %slip $>(%writ gift:able:clay) :: XX %slip
== == :: == == ::
$: %c :: $: %c ::
$> $? %mack :: XX strange $> $? %mass ::
%mass ::
%mere :: %mere ::
%note :: %note ::
%writ :: %writ ::
@ -400,30 +395,17 @@
== ==
== ==
:: ::
++ pump :: send diff ack
%_ .
moz
:_(moz [hen %pass ~ %g %deal [our our] ram %pump ~])
==
::
++ take :: receive ++ take :: receive
|= sih/sign |= sih/sign
^+ +> ^+ +>
?- sih ?- sih
{?($a $b $c $e $f $g $i $j) $mass *} {?($a $b $c $e $f $g $i $j) $mass *}
(wegh -.sih p.sih) (wegh -.sih p.sih)
::
{$a $nice *}
:: ~& [%take-nice-ames sih]
+>
:: ::
[%j %init *] [%j %init *]
:: pass thru to unix :: pass thru to unix
:: ::
+>(moz :_(moz [hen %give +.sih])) +>(moz :_(moz [hen %give +.sih]))
::
{$a $send *}
+>(moz :_(moz [hen %give +.sih]))
:: ::
{$g $onto *} {$g $onto *}
:: ~& [%take-gall-onto +>.sih] :: ~& [%take-gall-onto +>.sih]
@ -440,7 +422,7 @@
$reap ?~ p.p.+>.sih $reap ?~ p.p.+>.sih
+>.$ +>.$
(dump:(crud %reap u.p.p.+>.sih) %logo ~) (dump:(crud %reap u.p.p.+>.sih) %logo ~)
$diff pump:(from ;;(dill-blit q:`vase`+>+>.sih)) $diff (from ;;(dill-blit q:`vase`+>+>.sih))
$http-response !! $http-response !!
== ==
:: ::
@ -454,10 +436,6 @@
?: ?=(%& -.p.sih) ?: ?=(%& -.p.sih)
mere mere
(mean >%dill-mere-fail< >p.p.p.sih< q.p.p.sih) (mean >%dill-mere-fail< >p.p.p.sih< q.p.p.sih)
::
{$c $mack *}
?~ p.sih +>.$
(mean >%dill-clay-nack< u.p.sih)
:: ::
{$d $blit *} {$d $blit *}
(done +.sih) (done +.sih)

View File

@ -13,35 +13,34 @@
%out %out
%cay %cay
== ==
:: +reverse-ames: reverse ames message :: +ames-response: network response message (%boon)
:: ::
++ reverse-ames :: %d: diff
$% :: diff :: %x: quit
:: ::
[%d p=mark q=*] ++ ames-response
:: etc. $% [%d =mark noun=*]
::
[%x ~] [%x ~]
== ==
:: +forward-ames: forward ames message :: +ames-request: network request (%plea)
:: ::
++ forward-ames :: %m: poke
$% :: message :: %l: "peel" mark-translated subscribe
:: :: %s: subscribe
[%m =mark noun=*] :: %u: unsubscribe
:: "peel" subscribe ::
:: ++ ames-request
$% [%m =mark noun=*]
[%l =mark =path] [%l =mark =path]
:: subscribe
::
[%s =path] [%s =path]
:: cancel+unsubscribe
::
[%u ~] [%u ~]
== ==
:: +foreign-response: foreign response :: +remote-request: kinds of $agent-action that can cross the network
:: ::
++ foreign-response :: Used in wires to identify the kind of remote request we made.
:: Bijective with the tags of $ames-request.
::
++ remote-request
$? %peer $? %peer
%peel %peel
%poke %poke
@ -94,9 +93,6 @@
:: outgoing subscribers :: outgoing subscribers
:: ::
outgoing=boat outgoing=boat
:: queue meter
::
meter=(map bone @ud)
== ==
:: +agents: ship state :: +agents: ship state
:: ::
@ -106,7 +102,7 @@
system-duct=duct system-duct=duct
:: foreign contacts :: foreign contacts
:: ::
contacts=(map ship foreign) contacts=(set ship)
:: running agents :: running agents
:: ::
running=(map term agent) running=(map term agent)
@ -124,22 +120,6 @@
:: ::
attributing=ship attributing=ship
== ==
:: +foreign: foreign connections
::
++ foreign
$: :: rift of first contact
::
=rift
:: index
::
index=@ud
:: by duct
::
index-map=(map duct @ud)
:: by index
::
duct-map=(map @ud duct)
==
:: +ducts: opaque input :: +ducts: opaque input
:: ::
++ ducts ++ ducts
@ -268,7 +248,7 @@
^+ mo-core ^+ mo-core
:: ::
=/ =case [%da now] =/ =case [%da now]
=/ =path =/ =wire
=/ ship (scot %p ship) =/ ship (scot %p ship)
=/ case (scot case) =/ case (scot case)
/sys/core/[term]/[ship]/[desk]/[case] /sys/core/[term]/[ship]/[desk]/[case]
@ -277,13 +257,11 @@
=/ =schematic:ford [%core [ship desk] /hoon/[term]/app] =/ =schematic:ford [%core [ship desk] /hoon/[term]/app]
[%f %build live=%.y schematic] [%f %build live=%.y schematic]
:: ::
=/ pass [path note-arvo] (mo-pass wire note-arvo)
(mo-pass pass)
::
:: +mo-pass: prepend a standard %pass to the current list of moves. :: +mo-pass: prepend a standard %pass to the current list of moves.
:: ::
++ mo-pass ++ mo-pass
|= pass=(pair path note-arvo) |= pass=(pair wire note-arvo)
^+ mo-core ^+ mo-core
:: ::
=/ =move [hen [%pass pass]] =/ =move [hen [%pass pass]]
@ -394,33 +372,21 @@
%_ mo-core %_ mo-core
running.agents.state (~(put by running.agents.state) term agent) running.agents.state (~(put by running.agents.state) term agent)
== ==
:: +mo-handle-foreign-request: handle a foreign request. :: +mo-send-foreign-request: handle local app request to .ship
:: ::
:: Handles tasks received on a +call that have come from another ship. ++ mo-send-foreign-request
:: ~/ %mo-send-foreign-request
++ mo-handle-foreign-request
~/ %mo-handle-foreign-request
|= [=ship =internal-task] |= [=ship =internal-task]
^+ mo-core ^+ mo-core
:: ::
=/ =term p.internal-task =/ foreign-agent p.internal-task
=/ =agent-action q.internal-task =/ =agent-action q.internal-task
?: ?=(%pump -.agent-action)
::
:: you'd think this would send an ack for the diff
:: that caused this pump. it would, but we already
:: sent it when we got the diff in +mo-handle-sys. then
:: we'd have to save the network duct and connect it
:: to this returning pump.
::
mo-core
:: ::
?: ?=(%peer-not -.agent-action) ?: ?=(%peer-not -.agent-action)
=/ =tang p.agent-action (mo-give %unto %reap `p.agent-action)
(mo-give %unto %reap (some tang))
:: ::
=^ bone mo-core (mo-assign-bone ship) =. mo-core (mo-track-rift ship)
=/ =forward-ames =/ =ames-request
?- -.agent-action ?- -.agent-action
%poke [%m p.p.agent-action q.q.p.agent-action] %poke [%m p.p.agent-action q.q.p.agent-action]
%pull [%u ~] %pull [%u ~]
@ -435,96 +401,38 @@
/sys/way/[action] /sys/way/[action]
:: ::
=/ =note-arvo =/ =note-arvo
=/ =path /g/ge/[term] =/ =path /ge/[term]
=/ =noun [bone forward-ames] [%a %plea ship %g path ames-request]
[%a %want ship path noun]
:: ::
(mo-pass sys-path note-arvo) (mo-pass sys-path note-arvo)
:: +mo-handle-foreign-response: handle foreign response. :: +mo-track-rift: ensure we're subscribed to jael for .ship breaches
:: ::
:: Handle a received %woot from %ames. ++ mo-track-rift
::
++ mo-handle-foreign-response
|= [=foreign-response art=(unit ares)]
^+ mo-core
::
=/ to-tang
|= =ares
^- tang
?~ ares
~
=/ tape (trip p.u.ares)
[[%leaf tape] q.u.ares]
::
=/ result (bind art to-tang)
?- foreign-response
%peel (mo-give %unto %reap result)
%peer (mo-give %unto %reap result)
%poke (mo-give %unto %coup result)
%pull mo-core
==
:: +mo-assign-bone: assign an outbone to a ship.
::
:: If we know about the ship, we simply use its existing bone. Otherwise
:: we register a new entry for the ship, and use a default bone for it.
::
++ mo-assign-bone
|= =ship |= =ship
^- [bone _mo-core] ^+ mo-core
:: if already contacted, no-op
:: ::
=? mo-core !(~(has by contacts.agents.state) ship) ?: (~(has in contacts.agents.state) ship)
=/ =note-arvo [%j %public-keys (silt ship ~)]
=. moves [[system-duct.agents.state %pass /sys/jael note-arvo] moves]
=/ =rift (fall (mo-rift-scry ship) *rift)
=/ =foreign [rift 1 ~ ~]
=. contacts.agents.state
(~(put by contacts.agents.state) ship foreign)
mo-core mo-core
:: first contact; update state and subscribe to jael
:: ::
=/ =foreign (~(got by contacts.agents.state) ship) =. contacts.agents.state (~(put in contacts.agents.state) ship)
=/ existing (~(get by index-map.foreign) hen) =/ =note-arvo [%j %public-keys (silt ship ~)]
?^ existing =. moves
[u.existing mo-core] [[system-duct.agents.state %pass /sys/jael note-arvo] moves]
:: mo-core
=/ index index.foreign :: +mo-untrack-rift: cancel jael subscription to .ship's breaches
=/ contacts
=/ new-foreign
%_ foreign
index +(index)
index-map (~(put by index-map.foreign) hen index)
duct-map (~(put by duct-map.foreign) index hen)
==
(~(put by contacts.agents.state) ship new-foreign)
::
=/ next mo-core(contacts.agents.state contacts)
[index next]
:: +mo-retrieve-duct: retrieve a duct by index.
:: ::
++ mo-retrieve-duct ++ mo-untrack-rift
|= [=ship index=@ud]
^- (unit duct)
::
=/ contact=(unit foreign) (~(get by contacts.agents.state) ship)
?~ contact
~
`(~(got by duct-map.u.contact) index)
:: +mo-rift-scry: for a +rift
::
++ mo-rift-scry
|= who=ship
^- (unit rift)
=; rit
?~(rit ~ u.rit)
;; (unit (unit rift))
%- (sloy-light ska)
=/ pur=spur
/(scot %p who)
[[151 %noun] %j our %rift da+now pur]
:: +mo-cancel-jael: cancel jael subscription
::
++ mo-cancel-jael
|= =ship |= =ship
^+ mo-core ^+ mo-core
:: if already canceled, no-op
::
?. (~(has in contacts.agents.state) ship)
mo-core
:: delete .ship from state and kill subscription
::
=. contacts.agents.state (~(del in contacts.agents.state) ship)
=/ =note-arvo [%j %nuke (silt ship ~)] =/ =note-arvo [%j %nuke (silt ship ~)]
=. moves =. moves
[[system-duct.agents.state %pass /sys/jael note-arvo] moves] [[system-duct.agents.state %pass /sys/jael note-arvo] moves]
@ -534,6 +442,7 @@
++ mo-breach ++ mo-breach
|= =ship |= =ship
^+ mo-core ^+ mo-core
=. mo-core (mo-untrack-rift ship)
=/ agents=(list [name=term =agent]) ~(tap by running.agents.state) =/ agents=(list [name=term =agent]) ~(tap by running.agents.state)
|- ^+ mo-core |- ^+ mo-core
?~ agents ?~ agents
@ -542,8 +451,6 @@
=/ =routes [disclosing=~ attributing=ship] =/ =routes [disclosing=~ attributing=ship]
=/ app (ap-abed:ap name.i.agents routes) =/ app (ap-abed:ap name.i.agents routes)
ap-abet:(ap-breach:app ship) ap-abet:(ap-breach:app ship)
=. mo-core (mo-cancel-jael ship)
=. contacts.agents.state (~(del by contacts.agents.state) ship)
$(agents t.agents) $(agents t.agents)
:: +mo-handle-sys: handle a +sign incoming over /sys. :: +mo-handle-sys: handle a +sign incoming over /sys.
:: ::
@ -569,46 +476,19 @@
++ mo-handle-sys-jael ++ mo-handle-sys-jael
|= [=path =sign-arvo] |= [=path =sign-arvo]
^+ mo-core ^+ mo-core
?> ?=([%j %public-keys *] sign-arvo)
?> ?=([%jael ~] path) ?> ?=([%jael ~] path)
?: ?=(%full -.public-keys-result.sign-arvo) ?> ?=([%j %public-keys *] sign-arvo)
=/ ships=(list [=ship =point:able:jael]) ?. ?=(%breach -.public-keys-result.sign-arvo)
~(tap by points.public-keys-result.sign-arvo)
|- ^+ mo-core
?~ ships
mo-core
=. mo-core
=/ contact=(unit foreign)
(~(get by contacts.agents.state) ship.i.ships)
?~ contact
=/ =tank
leaf+"gall: unexpected jael update for {<ship.i.ships>}, cancelling"
%- (slog tank ~)
(mo-cancel-jael ship.i.ships)
?: (lte rift.point.i.ships rift.u.contact)
mo-core
(mo-breach ship.i.ships)
$(ships t.ships)
?. ?=(%rift -.diff.public-keys-result.sign-arvo)
mo-core mo-core
=/ =ship who.public-keys-result.sign-arvo (mo-breach who.public-keys-result.sign-arvo)
=/ contact=(unit foreign) (~(get by contacts.agents.state) ship)
?~ contact
=/ =tank
leaf+"gall: unexpected jael update for {<ship>}, cancelling"
%- (slog tank ~)
(mo-cancel-jael ship)
?: (lte to.diff.public-keys-result.sign-arvo rift.u.contact)
mo-core
(mo-breach ship)
:: +mo-handle-sys-core: receive a core from %ford. :: +mo-handle-sys-core: receive a core from %ford.
:: ::
++ mo-handle-sys-core ++ mo-handle-sys-core
|= [=path =sign-arvo] |= [=path =sign-arvo]
^+ mo-core ^+ mo-core
:: ::
?> ?=([%f %made *] sign-arvo)
?> ?=([@ @ @ @ @ ~] path) ?> ?=([@ @ @ @ @ ~] path)
?> ?=([%f %made *] sign-arvo)
=/ beak-path t.t.path =/ beak-path t.t.path
=/ =beak =/ =beak
=/ =ship (slav %p i.beak-path) =/ =ship (slav %p i.beak-path)
@ -624,75 +504,19 @@
|= [=path =sign-arvo] |= [=path =sign-arvo]
^+ mo-core ^+ mo-core
:: ::
?> ?=([%pel @ ~] path)
?> ?=([%f %made *] sign-arvo) ?> ?=([%f %made *] sign-arvo)
?> ?=([@ @ ~] path)
:: ::
?: ?=([%incomplete *] result.sign-arvo) ?- result.sign-arvo
=/ err (some tang.result.sign-arvo) [%incomplete *]
(mo-give %unto %coup err) (mo-give %unto %coup `tang.result.sign-arvo)
:: ::
=/ build-result build-result.result.sign-arvo [%complete %error *]
(mo-give %unto %coup `message.build-result.result.sign-arvo)
:: ::
?: ?=([%error *] build-result) [%complete %success *]
=/ err (some message.build-result) (mo-give %unto %diff (result-to-cage:ford build-result.result.sign-arvo))
(mo-give %unto %coup err) ==
::
=/ =cage (result-to-cage:ford build-result)
(mo-give %unto %diff cage)
:: +mo-handle-sys-red: diff ack.
::
:: On receipt of a valid +sign from %ames, we simply pass a %pump
:: acknowledgement internally; otherwise we pass both an internal
:: unsubscribing %pull, plus a %want to %ames, before complaining about a
:: bad message acknowledgment.
::
++ mo-handle-sys-red
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([@ @ @ @ ~] path)
?. ?=([%a %woot *] sign-arvo)
~& [%red-want path]
mo-core
::
=/ him (slav %p i.t.path)
=/ dap i.t.t.path
=/ num (slav %ud i.t.t.t.path)
=/ =coop q.+>.sign-arvo
=/ sys-path
=/ pax [%req t.path]
[%sys pax]
::
?~ coop
=/ =note-arvo
=/ =sock [him our]
=/ =internal-task [dap %pump ~]
=/ =task:able [%deal sock internal-task]
[%g task]
(mo-pass sys-path note-arvo)
::
=/ gall-move=note-arvo
=/ =sock [him our]
=/ =internal-task [dap %pull ~]
=/ =task:able [%deal sock internal-task]
[%g task]
::
=/ ames-move=note-arvo
=/ path [%g %gh dap ~]
=/ =noun [num %x ~]
=/ =task:able:ames [%want him path noun]
[%a task]
::
=. mo-core (mo-pass sys-path gall-move)
=. mo-core (mo-pass sys-path ames-move)
::
?. ?=([~ ~ %mack *] coop)
~& [%diff-bad-ack coop]
mo-core
::
~& [%diff-bad-ack %mack]
=/ print (slog (flop q.,.+>.coop))
(print mo-core)
:: +mo-handle-sys-rep: reverse request. :: +mo-handle-sys-rep: reverse request.
:: ::
:: On receipt of a valid +sign from %ford, sets state to the appropriate :: On receipt of a valid +sign from %ford, sets state to the appropriate
@ -702,86 +526,54 @@
|= [=path =sign-arvo] |= [=path =sign-arvo]
^+ mo-core ^+ mo-core
:: ::
?> ?=([@ @ @ @ ~] path) ?> ?=([%rep @ @ *] path)
?> ?=([%f %made *] sign-arvo) ?> ?=([%f %made *] sign-arvo)
=/ him (slav %p i.t.path)
=/ dap i.t.t.path
=/ num (slav %ud i.t.t.t.path)
:: ::
?: ?=([%incomplete *] result.sign-arvo) ?- result.sign-arvo
=/ err (some tang.result.sign-arvo) [%incomplete *]
(mo-give %mack err) (mo-give %done `[%gall-fail tang.result.sign-arvo])
:: ::
=/ build-result build-result.result.sign-arvo [%complete %error *]
?: ?=([%error *] build-result) (mo-give %done `[%gall-fail message.build-result.result.sign-arvo])
:: XX should crash ::
=/ err (some message.build-result) [%complete %success *]
(mo-give %mack err) (mo-give %unto %diff (result-to-cage:ford build-result.result.sign-arvo))
:: XX pump should ack ==
=. mo-core (mo-give %mack ~) :: +mo-handle-sys-req: TODO description
=/ duct (mo-retrieve-duct him num) ::
?~ duct :: TODO: what should we do if the remote nacks our %pull?
%- (slog leaf/"gall: sys-rep no index" ~)
mo-core
=. mo-core (mo-abed u.duct)
=/ =cage (result-to-cage:ford build-result)
=/ move [%unto [%diff cage]]
(mo-give move)
:: +mo-handle-sys-req: process an inbound request.
:: ::
++ mo-handle-sys-req ++ mo-handle-sys-req
|= [=path =sign-arvo] |= [=path =sign-arvo]
^+ mo-core ^+ mo-core
:: ::
?> ?=([@ @ @ @ ~] path) ?> ?=([%req @ @ @ ~] path)
=/ him (slav %p i.t.path) =/ him (slav %p i.t.path)
=/ dap i.t.t.path =/ dap i.t.t.path
=/ num (slav %ud i.t.t.t.path) =/ num (slav %ud i.t.t.t.path)
:: ::
?: ?=([%f %made *] sign-arvo)
?: ?=([%incomplete *] result.sign-arvo)
=/ err (some tang.result.sign-arvo)
(mo-give %mack err)
::
=/ build-result build-result.result.sign-arvo
?: ?=([%error *] build-result)
=/ err (some message.build-result)
(mo-give %mack err)
::
=/ sys-path [%sys path]
=/ =note-arvo
=/ =cage (result-to-cage:ford build-result)
[%g %deal [him our] i.t.t.path %poke cage]
(mo-pass sys-path note-arvo)
::
?: ?=([%a %woot *] sign-arvo)
mo-core
::
?> ?=([%g %unto *] sign-arvo) ?> ?=([%g %unto *] sign-arvo)
=/ =internal-gift +>.sign-arvo =/ =internal-gift +>.sign-arvo
:: ::
?- -.internal-gift ?- -.internal-gift
%coup %coup
(mo-give %mack p.internal-gift) =/ err=(unit error:ames)
?~ p.internal-gift ~
`[%coup u.p.internal-gift]
(mo-give %done err)
:: ::
%diff %diff
=/ sys-path [%sys %red t.path] =+ [mark noun]=[p q.q]:p.internal-gift
=/ =note-arvo (mo-give %boon num %d mark noun)
=/ path [%g %gh dap ~]
=/ noun [num %d p.p.internal-gift q.q.p.internal-gift]
[%a %want him path noun]
(mo-pass sys-path note-arvo)
:: ::
%quit %quit
=/ sys-path [%sys path] (mo-give %boon num %x ~)
=/ =note-arvo
=/ path [%g %gh dap ~]
=/ noun [num %x ~]
[%a %want him path noun]
(mo-pass sys-path note-arvo)
:: ::
%reap %reap
(mo-give %mack p.internal-gift) =/ err=(unit error:ames)
?~ p.internal-gift ~
`[%reap u.p.internal-gift]
(mo-give %done err)
:: ::
%http-response %http-response
!! !!
@ -796,7 +588,7 @@
^+ mo-core ^+ mo-core
:: ::
?> ?=([%f %made *] sign-arvo) ?> ?=([%f %made *] sign-arvo)
?> ?=([@ @ @ ~] path) ?> ?=([%val @ @ ~] path)
=/ =ship (slav %p i.t.path) =/ =ship (slav %p i.t.path)
=/ =term i.t.t.path =/ =term i.t.t.path
?: ?=([%incomplete *] result.sign-arvo) ?: ?=([%incomplete *] result.sign-arvo)
@ -812,17 +604,43 @@
=/ =cage (result-to-cage:ford build-result) =/ =cage (result-to-cage:ford build-result)
=/ =agent-action [%poke cage] =/ =agent-action [%poke cage]
(mo-apply term routes agent-action) (mo-apply term routes agent-action)
:: +mo-handle-sys-way: outbound request. :: +mo-handle-sys-way: handle response to outgoing remote request
:: ::
++ mo-handle-sys-way ++ mo-handle-sys-way
|= [=path =sign-arvo] |= [=path =sign-arvo]
^+ mo-core ^+ mo-core
:: ::
?> ?=([%a %woot *] sign-arvo) ?> ?=([%way @ @ @ *] path)
?> ?=([@ @ ~] path) =/ him (slav %p i.t.path)
=/ =foreign-response (foreign-response i.t.path) =/ agent-name `@tas`i.t.t.path
=/ maybe-ares +>+.sign-arvo =/ =remote-request ;;(remote-request i.t.t.t.path)
(mo-handle-foreign-response foreign-response maybe-ares) ::
?+ sign-arvo !!
[%a %done *]
=/ err=(unit tang)
?~ error=error.sign-arvo
~
`[[%leaf (trip tag.u.error)] tang.u.error]
::
?- remote-request
%peel (mo-give %unto %reap err)
%peer (mo-give %unto %reap err)
%poke (mo-give %unto %coup err)
%pull mo-core
==
::
[%a %boon *]
=/ =ames-response ;;(ames-response payload.sign-arvo)
(mo-handle-ames-response him agent-name ames-response)
::
[%a %lost *]
=/ sys-wire [%sys path]
:: TODO: %drip %quit so app crash can't kill the remote %pull
::
=. mo-core (mo-give %unto %quit ~)
=. mo-core (mo-pass sys-wire %a %plea him %g /ge/[agent-name] %u ~)
mo-core
==
:: +mo-handle-use: handle a typed +sign incoming on /use. :: +mo-handle-use: handle a typed +sign incoming on /use.
:: ::
:: (Note that /use implies the +sign should be routed to an agent.) :: (Note that /use implies the +sign should be routed to an agent.)
@ -922,15 +740,15 @@
:: +mo-apply: apply the supplied action to the specified agent. :: +mo-apply: apply the supplied action to the specified agent.
:: ::
++ mo-apply ++ mo-apply
|= [=term =routes =agent-action] |= [agent=term =routes =agent-action]
^+ mo-core ^+ mo-core
:: ::
=/ =path =/ =path
=/ ship (scot %p attributing.routes) =/ ship (scot %p attributing.routes)
/sys/val/[ship]/[term] /sys/val/[ship]/[agent]
:: ::
=/ ship-desk =/ ship-desk
=/ =beak (mo-beak term) =/ =beak (mo-beak agent)
[p q]:beak [p q]:beak
:: ::
?: ?=(%puff -.agent-action) ?: ?=(%puff -.agent-action)
@ -947,7 +765,7 @@
=/ err (some p.agent-action) =/ err (some p.agent-action)
(mo-give %unto %reap err) (mo-give %unto %reap err)
:: ::
=/ app (ap-abed:ap term routes) =/ app (ap-abed:ap agent routes)
=. app (ap-apply:app agent-action) =. app (ap-apply:app agent-action)
ap-abet:app ap-abet:app
:: +mo-handle-local: handle locally. :: +mo-handle-local: handle locally.
@ -960,97 +778,65 @@
^+ mo-core ^+ mo-core
:: ::
=/ =routes [disclosing=~ attributing=ship] =/ =routes [disclosing=~ attributing=ship]
=/ =term p.internal-task =/ agent p.internal-task
=/ =agent-action q.internal-task =/ =agent-action q.internal-task
=/ is-running (~(has by running.agents.state) term) =/ is-running (~(has by running.agents.state) agent)
=/ is-blocked (~(has by blocked.agents.state) term) =/ is-blocked (~(has by blocked.agents.state) agent)
:: ::
?: |(!is-running is-blocked) ?: |(!is-running is-blocked)
=/ =blocked =/ =blocked
=/ waiting (~(get by blocked.agents.state) term) =/ waiting (~(get by blocked.agents.state) agent)
=/ tasks (fall waiting *blocked) =/ tasks (fall waiting *blocked)
=/ task [hen routes agent-action] =/ task [hen routes agent-action]
(~(put to tasks) task) (~(put to tasks) task)
:: ::
%_ mo-core %_ mo-core
blocked.agents.state (~(put by blocked.agents.state) term blocked) blocked.agents.state (~(put by blocked.agents.state) agent blocked)
== ==
(mo-apply term routes agent-action) (mo-apply agent routes agent-action)
:: +mo-handle-forward: handle forward %ames message. :: +mo-handle-ames-request: handle ames request message
:: ::
++ mo-handle-forward ++ mo-handle-ames-request
|= [=ship =term =bone =forward-ames] |= [=ship agent-name=term =ames-request]
^+ mo-core
:: %u/%pull gets automatically acked
::
=? mo-core !?=(%u -.ames-request) (mo-give %done ~)
::
=/ =wire /sys/req/(scot %p ship)/[agent-name]
::
=/ =agent-action
?- -.ames-request
%m [%puff [mark noun]:ames-request]
%l [%peel [mark path]:ames-request]
%s [%peer path.ames-request]
%u [%pull ~]
==
(mo-pass wire %g %deal [ship our] agent-name agent-action)
:: +mo-handle-ames-response: handle ames response message
::
++ mo-handle-ames-response
|= [=ship agent-name=term =subscription=path =ames-response]
^+ mo-core ^+ mo-core
:: ::
=. mo-core ?- -.ames-response
?. ?=(%u -.forward-ames) :: %d: diff; ask ford to validate .noun as .mark
mo-core ::
(mo-give %mack ~)
::
=/ =path
=/ him (scot %p ship)
=/ num (scot %ud bone)
/sys/req/[him]/[term]/[num]
::
=/ =sock [ship our]
=/ =note-arvo
?- -.forward-ames
%m
=/ =task:able
=/ =internal-task [term %puff [mark noun]:forward-ames]
[%deal sock internal-task]
[%g task]
::
%l
=/ =task:able
=/ =internal-task [term %peel [mark path]:forward-ames]
[%deal sock internal-task]
[%g task]
::
%s
=/ =task:able
=/ =internal-task [term %peer path.forward-ames]
[%deal sock internal-task]
[%g task]
::
%u
=/ =task:able
=/ =internal-task [term %pull ~]
[%deal sock internal-task]
[%g task]
==
(mo-pass path note-arvo)
:: +mo-handle-backward: handle reverse %ames message.
::
++ mo-handle-backward
|= [=ship =term =bone =reverse-ames]
^+ mo-core
::
?- -.reverse-ames
%d %d
=/ =path =/ =wire
=/ him (scot %p ship) =- (weld - subscription-path)
=/ num (scot %ud bone) /sys/rep/(scot %p ship)/[agent-name]
/sys/rep/[him]/[term]/[num]
:: ::
=/ =note-arvo =/ =note-arvo
=/ beak (mo-beak term) =/ =disc:ford [p q]:(mo-beak term)
=/ info [p q]:beak [%f %build live=%.n %vale disc [mark noun]:ames-response]
=/ =schematic:ford [%vale info p.reverse-ames q.reverse-ames]
[%f %build live=%.n schematic]
:: ::
(mo-pass path note-arvo) (mo-pass wire note-arvo)
:: ::
:: %x: quit; tell agent the publisher canceled the subscription
::
%x %x
:: XX should crash (mo-give %unto %quit ~)
=. mo-core (mo-give %mack ~)
=/ out (mo-retrieve-duct ship bone)
?~ out
%- (slog leaf/"gall: x no index" ~)
mo-core
=/ initialised
(mo-abed u.out)
(mo-give:initialised %unto %quit ~)
== ==
:: +ap: agent engine :: +ap: agent engine
:: ::
@ -1127,16 +913,10 @@
=/ bones *(set bone) =/ bones *(set bone)
|- ^+ ap-core |- ^+ ap-core
?^ internal-moves ?^ internal-moves
=/ =internal-move i.internal-moves =? bones ?=([%give %diff *] move.i.internal-moves)
?. ?=([%give %diff *] move.internal-move) (~(put in bones) bone.i.internal-moves)
$(internal-moves t.internal-moves)
:: ::
=^ filled ap-core ap-enqueue(agent-bone bone.internal-move) $(internal-moves t.internal-moves)
=/ new-bones
?: filled
bones
(~(put in bones) bone.internal-move)
$(internal-moves t.internal-moves, bones new-bones)
:: ::
=/ bones ~(tap in bones) =/ bones ~(tap in bones)
:: ::
@ -1229,7 +1009,7 @@
core(agent-bone agent-bone) core(agent-bone agent-bone)
$(in t.in) $(in t.in)
:: ::
=/ out=(list [[=bone =wire] =bean =^ship =path]) =/ out=(list [[=bone =wire] ? =^ship =path])
~(tap by outgoing.subscribers.current-agent) ~(tap by outgoing.subscribers.current-agent)
|- ^+ ap-core |- ^+ ap-core
?~ out ?~ out
@ -1347,7 +1127,6 @@
%punk !! %punk !!
%peer-not !! %peer-not !!
%pull ap-load-delete %pull ap-load-delete
%pump ap-dequeue
== ==
:: +ap-diff: pour a diff. :: +ap-diff: pour a diff.
:: ::
@ -1399,36 +1178,15 @@
|= [is-ok=? =ship =path] |= [is-ok=? =ship =path]
^+ ap-core ^+ ap-core
:: ::
=/ way [(scot %p ship) %out path]
::
?: is-ok ?: is-ok
=/ =internal-note [%send ship -.path %pump ~] ap-core
(ap-pass way internal-note) :: not ok; kill in both directions with %quit and %pull
::
=. ap-core (ap-give %quit ~) =. ap-core (ap-give %quit ~)
::
=/ way [(scot %p ship) %out path]
=/ =internal-note [%send ship -.path %pull ~] =/ =internal-note [%send ship -.path %pull ~]
(ap-pass way internal-note) (ap-pass way internal-note)
:: +ap-dequeue: drop from queue.
::
:: Dequeues along the current bone, deleting the queue entirely if it
:: drops to zero.
::
++ ap-dequeue
^+ ap-core
::
?. (~(has by incoming.subscribers.current-agent) agent-bone)
ap-core
=/ level (~(get by meter.subscribers.current-agent) agent-bone)
?: |(?=(~ level) =(0 u.level))
ap-core
::
=. u.level (dec u.level)
?: =(0 u.level)
=/ deleted (~(del by meter.subscribers.current-agent) agent-bone)
ap-core(meter.subscribers.current-agent deleted)
::
=/ dequeued
(~(put by meter.subscribers.current-agent) agent-bone u.level)
ap-core(meter.subscribers.current-agent dequeued)
:: +ap-produce-arm: produce arm. :: +ap-produce-arm: produce arm.
:: ::
++ ap-produce-arm ++ ap-produce-arm
@ -1463,39 +1221,6 @@
ap-core(cache.current-agent worm) ap-core(cache.current-agent worm)
:: ::
[possibly-vase next] [possibly-vase next]
:: +ap-enqueue: add to queue.
::
:: Every agent has a 'meter', that tracks the number of incoming
:: subscribers by bone. We get both the meter and ship associated with
:: the current bone; if the meter has hit twenty for another ship, we
:: don't enqueue the subscriber. Otherwise we increment the meter for
:: the current bone and update the agent's state with it.
::
:: Returns a yes if the meter has been incremented, and no otherwise.
::
++ ap-enqueue
^- [? _ap-core]
::
=/ meter (~(gut by meter.subscribers.current-agent) agent-bone 0)
=/ subscriber=(unit (pair ship path))
(~(get by incoming.subscribers.current-agent) agent-bone)
::
?: ?& =(20 meter)
?| ?=(~ subscriber)
!=(our p.u.subscriber)
==
==
=/ incoming (~(get by incoming.subscribers.current-agent) agent-bone)
=/ duct (~(get by duct-map.ducts.current-agent) agent-bone)
~& [%gall-pulling-20 agent-bone incoming duct]
[%.n ap-core]
::
=/ next
=/ meter
(~(put by meter.subscribers.current-agent) agent-bone +(meter))
ap-core(meter.subscribers.current-agent meter)
::
[%.y next]
:: +ap-find-arm: general arm. :: +ap-find-arm: general arm.
:: ::
++ ap-find-arm ++ ap-find-arm
@ -2189,15 +1914,9 @@
++ ap-silent-delete ++ ap-silent-delete
^+ ap-core ^+ ap-core
:: ::
?~ (~(get by incoming.subscribers.current-agent) agent-bone) =. incoming.subcribers.current-agent
ap-core (~(del by incoming.subscribers.current-agent) agent-bone)
:: ap-core
=/ incoming (~(del by incoming.subscribers.current-agent) agent-bone)
=/ meter (~(del by meter.subscribers.current-agent) agent-bone)
%_ ap-core
incoming.subscribers.current-agent incoming
meter.subscribers.current-agent meter
==
:: +ap-load-delete: load delete. :: +ap-load-delete: load delete.
:: ::
++ ap-load-delete ++ ap-load-delete
@ -2211,8 +1930,6 @@
=/ incoming u.maybe-incoming =/ incoming u.maybe-incoming
=. incoming.subscribers.current-agent =. incoming.subscribers.current-agent
(~(del by incoming.subscribers.current-agent) agent-bone) (~(del by incoming.subscribers.current-agent) agent-bone)
=. meter.subscribers.current-agent
(~(del by meter.subscribers.current-agent) agent-bone)
:: ::
=^ maybe-arm ap-core (ap-find-arm %pull q.incoming) =^ maybe-arm ap-core (ap-find-arm %pull q.incoming)
?~ maybe-arm ?~ maybe-arm
@ -2422,7 +2139,7 @@
%rest `%b %rest `%b
%rekey `%j %rekey `%j
%wait `%b %wait `%b
%want `%a %plea `%a
%warp `%c %warp `%c
%wash `%g %wash `%g
%wipe `%f %wipe `%f
@ -2467,7 +2184,7 @@
=/ =internal-task q.task =/ =internal-task q.task
?. =(q.sock our) ?. =(q.sock our)
?> =(p.sock our) ?> =(p.sock our)
=> (mo-handle-foreign-request:initialised q.sock internal-task) => (mo-send-foreign-request:initialised q.sock internal-task)
mo-abet mo-abet
:: ::
=> (mo-handle-local:initialised p.sock internal-task) => (mo-handle-local:initialised p.sock internal-task)
@ -2489,21 +2206,17 @@
%vega %vega
[~ gall-payload] [~ gall-payload]
:: ::
%west %plea
=/ =ship p.task =/ =ship ship.task
=/ =path q.task =/ =path path.task
=/ =noun r.task =/ =noun payload.task
:: ::
?> ?=([?(%ge %gh) @ ~] path) ~| [ship=ship plea-path=path]
?> ?=([%ge @ ~] path)
=/ agent-name i.t.path =/ agent-name i.t.path
:: ::
?: ?=(%ge i.path) =/ =ames-request ;;(ames-request noun)
=/ mes ;;((pair @ud forward-ames) noun) => (mo-handle-ames-request ship agent-name ames-request)
=> (mo-handle-forward:initialised ship agent-name mes)
mo-abet
::
=/ mes ;;((pair @ud reverse-ames) noun)
=> (mo-handle-backward:initialised ship agent-name mes)
mo-abet mo-abet
:: ::
%wash %wash
@ -2528,11 +2241,7 @@
[%dot %.y state] [%dot %.y state]
== ==
:: ::
=/ moves [[duct %give %mass mass]~ gall-payload]
=/ =move [duct %give %mass mass]
[move ~]
::
[moves gall-payload]
== ==
:: +load: recreate vane :: +load: recreate vane
:: ::
@ -2588,6 +2297,7 @@
^- [(list move) _gall-payload] ^- [(list move) _gall-payload]
:: ::
~| [%gall-take-failed wire] ~| [%gall-take-failed wire]
::
?> ?=([?(%sys %use) *] wire) ?> ?=([?(%sys %use) *] wire)
=/ initialised (mo-abed:mo duct) =/ initialised (mo-abed:mo duct)
=/ =sign-arvo q.hin =/ =sign-arvo q.hin

View File

@ -62,8 +62,10 @@
+$ message :: message to her jael +$ message :: message to her jael
$% [%nuke whos=(set ship)] :: cancel trackers $% [%nuke whos=(set ship)] :: cancel trackers
[%public-keys whos=(set ship)] :: view ethereum events [%public-keys whos=(set ship)] :: view ethereum events
[%public-keys-result =public-keys-result] :: tmp workaround
== :: == ::
+$ message-result
$% [%public-keys-result =public-keys-result] :: public keys boon
==
+$ card :: i/o action +$ card :: i/o action
(wind note gift) :: (wind note gift) ::
:: :: :: ::
@ -71,12 +73,12 @@
[p=duct q=card] :: [p=duct q=card] ::
:: :: :: ::
+$ note :: out request $-> +$ note :: out request $->
$~ [%a %want *ship *path **] :: $~ [%a %plea *ship *plea:ames] ::
$% $: %a :: to %ames $% $: %a :: to %ames
$>(%want task:able:ames) :: send message $>(%plea task:able:ames) :: send request message
== :: == ::
$: %g :: to self $: %g :: to self
$>(%deal task:able:gall) :: set ethereum source $>(%deal task:able:gall) :: set ethereum source
== :: == ::
$: %j :: to self $: %j :: to self
$>(%listen task) :: set ethereum source $>(%listen task) :: set ethereum source
@ -88,8 +90,12 @@
+$ peer-sign [=ship =udiff:point] :: +$ peer-sign [=ship =udiff:point] ::
:: :: :: ::
+$ sign :: in result $<- +$ sign :: in result $<-
$~ [%a %woot *ship ~] :: $~ [%a %done ~] ::
$% [%a $>(%woot gift:able:ames)] :: message result $% $: %a
$% $>(%boon gift:able:ames) :: message response
$>(%done gift:able:ames) :: message (n)ack
$>(%lost gift:able:ames) :: lost boon
== ==
$: %g :: $: %g ::
$> $? %onto :: $> $? %onto ::
%unto :: %unto ::
@ -486,32 +492,24 @@
:: authenticated remote request :: authenticated remote request
:: {$west p/ship q/path r/*} :: {$west p/ship q/path r/*}
:: ::
$west %plea
=* her p.tac =* her ship.tac
=/ mes (message r.tac) =/ mes ;;(message payload.plea.tac)
?- -.mes ?- -.mes
:: ::
:: cancel trackers :: cancel trackers
:: [%nuke whos=(set ship)] :: [%nuke whos=(set ship)]
:: ::
%nuke %nuke
=. moz [[hen %give %mack ~] moz] =. moz [[hen %give %done ~] moz]
$(tac mes) $(tac mes)
:: ::
:: view ethereum events :: view ethereum events
:: [%public-keys whos=(set ship)] :: [%public-keys whos=(set ship)]
:: ::
%public-keys %public-keys
=. moz [[hen %give %mack ~] moz] =. moz [[hen %give %done ~] moz]
$(tac mes) $(tac mes)
::
:: receive keys result
:: [%public-keys-result =public-keys-result]
::
%public-keys-result
=. moz [[hen %give %mack ~] moz]
%- curd =< abet
(public-keys:~(feel su hen our pki etn) public-keys-result.mes)
== ==
== ==
:: ::
@ -519,13 +517,23 @@
|= [tea=wire hen=duct hin=sign] |= [tea=wire hen=duct hin=sign]
^+ +> ^+ +>
?- hin ?- hin
[%a %woot *] [%a %done *]
?~ q.hin +>.$ ?~ error.hin ~&(%ares-fine +>.$)
?~ u.q.hin ~&(%ares-fine +>.$) ~& [%done-bad tag.u.error.hin]
~& [%woot-bad p.u.u.q.hin] %- (slog tang.u.error.hin)
~_ q.u.u.q.hin
::TODO fail:et ::TODO fail:et
+>.$ +>.$
::
[%a %boon *]
=+ ;; [%public-keys-result =public-keys-result] payload.hin
%- curd =< abet
(public-keys:~(feel su hen our pki etn) public-keys-result)
::
[%a %lost *]
:: TODO: better error handling
::
~| %jael-ames-lost
!!
:: ::
[%g %onto *] [%g %onto *]
~& [%jael-onto tea hin] ~& [%jael-onto tea hin]
@ -551,8 +559,6 @@
?> ?=([@ *] tea) ?> ?=([@ *] tea)
=* app i.tea =* app i.tea
=/ =peer-sign ;;(peer-sign q.q.p.p.+>.hin) =/ =peer-sign ;;(peer-sign q.q.p.p.+>.hin)
%. [hen tea app]
=< pump
%- curd =< abet %- curd =< abet
(~(new-event su hen our pki etn) peer-sign) (~(new-event su hen our pki etn) peer-sign)
== ==
@ -564,10 +570,6 @@
etn/state-eth-node etn/state-eth-node
== ==
+>(pki pki, etn etn, moz (weld (flop moz) ^moz)) +>(pki pki, etn etn, moz (weld (flop moz) ^moz))
:: :: ++wind:of
++ pump
|= [hen=duct =wire app=term]
(emit [hen %pass wire %g %deal [our our] app %pump ~])
-- --
:: :: ++su :: :: ++su
:::: ## relative^heavy :: subjective engine :::: ## relative^heavy :: subjective engine
@ -643,15 +645,8 @@
?. &(?=([[%a @ @ *] *] d) !=(%pubs i.t.i.d)) ?. &(?=([[%a @ @ *] *] d) !=(%pubs i.t.i.d))
%- emit %- emit
[d %give %public-keys public-keys-result] [d %give %public-keys public-keys-result]
=/ our (slav %p i.t.i.d)
=/ who (slav %p i.t.t.i.d)
=/ =message [%public-keys-result public-keys-result]
%- emit %- emit
:^ d [d %give %boon %public-keys-result public-keys-result]
%pass
/public-keys-result
^- note
[%a %want who /j/public-keys-result message]
$(yez t.yez) $(yez t.yez)
:: ::
++ get-source ++ get-source
@ -808,9 +803,11 @@
|- ^+ ..feel |- ^+ ..feel
?~ pointl ?~ pointl
..feel ..feel
%+ public-keys-give =. ..feel
(subscribers-on-ship who.i.pointl) %+ public-keys-give
[%full (my i.pointl ~)] (subscribers-on-ship who.i.pointl)
[%full (my i.pointl ~)]
$(pointl t.pointl)
=* who who.public-keys-result =* who who.public-keys-result
=/ a-diff=diff:point diff.public-keys-result =/ a-diff=diff:point diff.public-keys-result
=/ maybe-point (~(get by pos.zim) who) =/ maybe-point (~(get by pos.zim) who)
@ -854,7 +851,7 @@
?: ?=(%& -.source) ?: ?=(%& -.source)
=/ send-message =/ send-message
|= =message |= =message
[hen %pass /public-keys %a %want p.source /j/public-keys message] [hen %pass /public-keys %a %plea p.source %j /public-keys message]
(emit (send-message %public-keys whos)) (emit (send-message %public-keys whos))
=^ =source-id this-su (get-source-id source) =^ =source-id this-su (get-source-id source)
=. ..feed =. ..feed
@ -1017,7 +1014,7 @@
?: fak.own.pki.lex ?: fak.own.pki.lex
=/ cub (pit:nu:crub:crypto 512 u.who) =/ cub (pit:nu:crub:crypto 512 u.who)
:^ ~ ~ %noun :^ ~ ~ %noun
!> `deed:ames`[1 pub:ex:cub ~] !> [1 pub:ex:cub ~]
:: ::
=/ rac (clan:title u.who) =/ rac (clan:title u.who)
?: ?=(%pawn rac) ?: ?=(%pawn rac)
@ -1029,8 +1026,7 @@
=/ cub (nol:nu:crub:crypto sec) =/ cub (nol:nu:crub:crypto sec)
=/ sig (sign:as:cub (shaf %self (sham [u.who 1 pub:ex:cub]))) =/ sig (sign:as:cub (shaf %self (sham [u.who 1 pub:ex:cub])))
:^ ~ ~ %noun :^ ~ ~ %noun
!> ^- deed:ames !> [1 pub:ex:cub `sig]
[1 pub:ex:cub `sig]
:: ::
=/ pub (~(get by pos.zim.pki.lex) u.who) =/ pub (~(get by pos.zim.pki.lex) u.who)
?~ pub ?~ pub
@ -1041,7 +1037,7 @@
?~ pas ?~ pas
~ ~
:^ ~ ~ %noun :^ ~ ~ %noun
!> `deed:ames`[u.lyf pass.u.pas ~] !> [u.lyf pass.u.pas ~]
:: ::
%earl %earl
?. ?=([@ @ ~] tyl) [~ ~] ?. ?=([@ @ ~] tyl) [~ ~]

View File

@ -1,3 +1,4 @@
!:
:: :: /van/zuse :: :: /van/zuse
:: :: %reference/1 :: :: %reference/1
:: %zuse: arvo library. :: %zuse: arvo library.
@ -194,6 +195,7 @@
:: +vane-task: general tasks shared across vanes :: +vane-task: general tasks shared across vanes
:: ::
+$ vane-task +$ vane-task
$~ [%born ~]
$% :: i/o device replaced (reset state) $% :: i/o device replaced (reset state)
:: ::
[%born ~] [%born ~]
@ -214,7 +216,9 @@
[%wegh ~] [%wegh ~]
:: receive message via %ames :: receive message via %ames
:: ::
[%west p=ship q=path r=*] :: TODO: move .vane from $plea to here
::
[%plea =ship =plea:ames]
== ==
:: :::: :: ::::
:::: ++http :: :::: ++http ::
@ -374,32 +378,56 @@
:: :::: :: ::::
++ able ^? ++ able ^?
|% |%
++ gift :: out result <-$ :: $task: job for ames
$% {$mack p/(unit tang)} :: acknowledgement ::
{$mass p/mass} :: memory usage :: Messaging Tasks
{$send p/lane q/@} :: transmit packet ::
{$turf p/(list turf)} :: bind to domains :: %hear: packet from unix
$>(%west vane-task) :: for the outside :: %hole: report that packet handling crashed
{$woot p/ship q/coop} :: reaction message :: %plea: request to send message
== :: ::
++ task :: in request ->$ :: System and Lifecycle Tasks
$~ [%vega ~] :: ::
$% {$barn ~} :: new unix process :: %born: process restart notification
{$bonk ~} :: reset the timer :: %crud: crash report
$>(%crud vane-task) :: error with trace :: %init: vane boot
{$hear p/lane q/@} :: receive packet :: %vega: kernel reload notification
{$halo p/lane q/@ r/ares} :: hole with trace :: %wegh: request for memory usage report
{$hole p/lane q/@} :: packet failed ::
$>(%init vane-task) :: report install +$ task
{$kick p/@da} :: wake up $% [%hear =lane =blob]
{$nuke p/@p} :: toggle auto-block [%hole =lane =blob]
$>(%trim vane-task) :: trim state $>(%plea vane-task)
$>(%vega vane-task) :: report upgrade ::
{$wake ~} :: timer activate $>(%born vane-task)
$>(%wegh vane-task) :: report memory $>(%crud vane-task)
$>(%west vane-task) :: network request $>(%init vane-task)
{$want p/ship q/path r/*} :: forward message $>(%vega vane-task)
== :: $>(%wegh vane-task)
==
:: $gift: effect from ames
::
:: Messaging Gifts
::
:: %boon: response message from remote ship
:: %done: notify vane that peer (n)acked our message
:: %lost: notify vane that we crashed on %boon
:: %send: packet to unix
::
:: System and Lifecycle Gifts
::
:: %mass: memory usage report
:: %turf: domain report, relayed from jael
::
+$ gift
$% [%boon payload=*]
[%done error=(unit error)]
[%lost ~]
[%send =lane =blob]
::
[%mass p=mass]
[%turf turfs=(list turf)]
==
-- ::able -- ::able
:: ::
:::: :: (1a2) :::: :: (1a2)
@ -427,131 +455,28 @@
++ com |~(a/pass ^?(..nu)) :: from pass ++ com |~(a/pass ^?(..nu)) :: from pass
-- ::nu :: -- ::nu ::
-- ::acru :: -- ::acru ::
++ bait {p/skin q/@ud r/dove} :: fmt nrecvd spec :: $address: opaque atomic transport address to or from unix
++ bath :: convo per client ::
$: sop/shed :: not stalled +$ address @uxaddress
raz/(map path race) :: statements inbound :: $blob: raw atom to or from unix, representing a packet
ryl/(map path rill) :: statements outbound ::
== :: +$ blob @uxblob
++ boon :: fort output :: $error: tagged diagnostic trace
$% [%beer p=ship] :: request public keys ::
[%bock ~] :: bind to domains +$ error [tag=@tas =tang]
[%brew ~] :: request domains :: $lane: ship transport address; either opaque $address or galaxy
[%cake p=ship q=soap r=coop s=duct] :: e2e message result ::
[%mead p=lane q=rock] :: accept packet :: The runtime knows how to look up galaxies, so we don't need to
[%milk p=ship q=soap r=*] :: e2e pass message :: know their transport addresses.
[%ouzo p=lane q=rock] :: transmit packet ::
[%pito p=@da] :: timeout +$ lane (each @pC address)
[%raki p=ship q=life r=pass] :: neighbor'd :: $plea: application-level message, as a %pass
[%sake ~] :: our private keys ::
[%wine p=ship q=tape] :: notify user :: vane: destination vane on remote ship
== :: :: path: internal route on the receiving ship
++ cake {p/sock q/skin r/@} :: top level packet :: payload: semantic message contents
++ cape :: end-to-end result ::
$? $good :: delivered +$ plea [vane=@tas =path payload=*]
$dead :: rejected
== ::
++ clot :: symmetric record
$: yed/(unit {p/hand q/code}) :: outbound
heg/(map hand code) :: proposed
qim/(map hand code) :: inbound
== ::
++ code @uvI :: symmetric key
++ corn :: flow by server
$: nys/(map flap bait) :: packets incoming
olz/(map flap cape) :: packets completed
wab/(map ship bath) :: relationship
== ::
+$ deed [=life =pass oath=(unit oath:pki:jael)] :: life/pub/sig
++ dore :: foreign contact
$: wod/road :: connection to
caq/clot :: symmetric key state
== ::
++ dove {p/@ud q/(map @ud @)} :: count hash 13-blocks
++ flap @uvH :: network packet id
++ flow :: packet connection
$: rtt/@dr :: decaying avg rtt
wid/@ud :: logical wdow msgs
== ::
++ fort :: formal state
$: $1 :: version
gad/duct :: client interface
tim/(unit @da) :: pending timer
tuf/(list turf) :: domains
hop/@da :: network boot date
bad/(set @p) :: bad ships
ton/town :: security
zac/corn :: flows by server
== ::
++ hand @uvH :: 128-bit hash
++ lane :: packet route
$% {$if p/@da q/@ud r/@if} :: IP4/public UDP/addr
{$is p/@ud q/(unit lane) r/@is} :: IPv6 w+alternates
{$ix p/@da q/@ud r/@if} :: IPv4 provisional
== ::
++ meal :: payload
$% {$back p/coop q/flap r/@dr} :: ack
{$bond p/path q/@ud r/*} :: message
{$carp p/@ q/@ud r/@ud s/flap t/@} :: skin+inx+cnt+hash
{$fore p/ship q/(unit lane) r/@} :: forwarded packet
== ::
++ name {p/@t q/(unit @t) r/(unit @t) s/@t} :: first mid+nick last
++ putt :: outgoing message
$: ski/snow :: sequence acked+sent
wyv/(list rock) :: packet list XX gear
== ::
++ race :: inbound stream
$: did/@ud :: filled sequence
dod/? :: not processing
bum/(map @ud ares) :: nacks
mis/(map @ud {p/cape q/lane r/flap s/(unit)}) :: misordered
== ::
++ rill :: outbound stream
$: sed/@ud :: sent
san/(map @ud duct) :: outstanding
== ::
++ road :: secured oneway route
$: exp/@da :: expiration date
lun/(unit lane) :: route to friend
lew/(unit deed) :: deed of friend
== ::
++ rock @uvO :: packet
++ shed :: packet flow
$: $: rtt/@dr :: smoothed rtt
rto/@dr :: retransmit timeout
rtn/(unit @da) :: next timeout
rue/(unit @da) :: last heard from
== ::
$: nus/@ud :: number sent
nif/@ud :: number live
nep/@ud :: next expected
caw/@ud :: logical window
cag/@ud :: congest thresh
== ::
$: diq/(map flap @ud) :: packets sent
pyz/(map soup @ud) :: message+unacked
puq/(qeu {p/@ud q/soul}) :: packet queue
== ::
== ::
++ skin ?($none $open $fast $full) :: encoding stem
++ snow {p/@ud q/@ud r/(set @ud)} :: window exceptions
++ soap {p/{p/life q/life} q/path r/@ud} :: statement id
++ soup {p/path q/@ud} :: new statement id
++ soul :: packet in travel
$: gom/soup :: message identity
nux/@ud :: xmission count
liv/? :: deemed live
lys/@da :: last sent
pac/rock :: packet data
== ::
++ town :: all security state
$: any/@ :: entropy
val/wund :: private keys
law/deed :: server deed
seh/(map hand {p/ship q/@da}) :: key cache
hoc/(map ship dore) :: neighborhood
== ::
++ wund (list {p/life q/ring r/acru}) :: secrets in action
-- ::ames -- ::ames
:: :::: :: ::::
:::: ++behn :: (1b) timekeeping :::: ++behn :: (1b) timekeeping
@ -594,18 +519,18 @@
++ able ^? ++ able ^?
|% |%
++ gift :: out result <-$ ++ gift :: out result <-$
$% {$croz rus/(map desk {r/regs w/regs})} :: rules for group $% [%boon payload=*] :: ames response
{$croz rus/(map desk {r/regs w/regs})} :: rules for group
{$cruz cez/(map @ta crew)} :: permission groups {$cruz cez/(map @ta crew)} :: permission groups
{$dirk p/@tas} :: mark mount dirty {$dirk p/@tas} :: mark mount dirty
{$ergo p/@tas q/mode} :: version update {$ergo p/@tas q/mode} :: version update
{$hill p/(list @tas)} :: mount points {$hill p/(list @tas)} :: mount points
{$mack p/(unit tang)} :: ack [%done error=(unit error:ames)] :: ames message (n)ack
{$mass p/mass} :: memory usage {$mass p/mass} :: memory usage
{$mere p/(each (set path) (pair term tang))} :: merge result {$mere p/(each (set path) (pair term tang))} :: merge result
{$note p/@tD q/tank} :: debug message {$note p/@tD q/tank} :: debug message
{$ogre p/@tas} :: delete mount point {$ogre p/@tas} :: delete mount point
{$rule red/dict wit/dict} :: node r+w permissions {$rule red/dict wit/dict} :: node r+w permissions
{$send p/lane:ames q/@} :: transmit packet
{$writ p/riot} :: response {$writ p/riot} :: response
{$wris p/{$da p/@da} q/(set (pair care path))} :: many changes {$wris p/{$da p/@da} q/(set (pair care path))} :: many changes
== :: == ::
@ -634,7 +559,7 @@
{$warp wer/ship rif/riff} :: internal file req {$warp wer/ship rif/riff} :: internal file req
{$werp who/ship wer/ship rif/riff} :: external file req {$werp who/ship wer/ship rif/riff} :: external file req
$>(%wegh vane-task) :: report memory $>(%wegh vane-task) :: report memory
$>(%west vane-task) :: network request $>(%plea vane-task) :: ames request
== :: == ::
-- ::able -- ::able
:: ::
@ -777,7 +702,6 @@
{$logo ~} :: logout {$logo ~} :: logout
{$lyra p/@t q/@t} :: upgrade kernel {$lyra p/@t q/@t} :: upgrade kernel
{$mass p/mass} :: memory usage {$mass p/mass} :: memory usage
{$send p/lane:ames q/@} :: transmit packet
{$veer p/@ta q/path r/@t} :: install vane {$veer p/@ta q/path r/@t} :: install vane
{$verb ~} :: verbose mode {$verb ~} :: verbose mode
== :: == ::
@ -1873,20 +1797,20 @@
++ able ^? ++ able ^?
|% |%
++ gift :: outgoing result ++ gift :: outgoing result
$% {$mass p/mass} :: memory usage $% [%boon payload=*] :: ames response
[%done error=(unit error:ames)] :: ames message (n)ack
{$mass p/mass} :: memory usage
{$onto p/(each suss tang)} :: about agent {$onto p/(each suss tang)} :: about agent
{$rend p/path q/*} :: network request
{$unto p/internal-gift} :: {$unto p/internal-gift} ::
{$mack p/(unit tang)} :: message ack
== :: == ::
++ task :: incoming request ++ task :: incoming request
$~ [%vega ~] :: $~ [%vega ~] ::
$% {$conf p/dock q/dock} :: configure app $% {$conf p/dock q/dock} :: configure app
$>(%init vane-task) :: set owner
{$deal p/sock q/internal-task} :: full transmission {$deal p/sock q/internal-task} :: full transmission
$>(%init vane-task) :: set owner
$>(%trim vane-task) :: trim state $>(%trim vane-task) :: trim state
$>(%vega vane-task) :: report upgrade $>(%vega vane-task) :: report upgrade
$>(%west vane-task) :: network request $>(%plea vane-task) :: network request
[%wash ~] :: clear caches [%wash ~] :: clear caches
$>(%wegh vane-task) :: report memory $>(%wegh vane-task) :: report memory
== :: == ::
@ -1894,7 +1818,7 @@
++ bitt (map bone (pair ship path)) :: incoming subs ++ bitt (map bone (pair ship path)) :: incoming subs
++ boat :: outgoing subs ++ boat :: outgoing subs
%+ map (pair bone wire) :: %+ map (pair bone wire) ::
(trel bean ship path) :: (trel ? ship path) ::
++ bowl :: standard app state ++ bowl :: standard app state
$: $: our/ship :: host $: $: our/ship :: host
src/ship :: guest src/ship :: guest
@ -1914,9 +1838,8 @@
{$peer p/path} :: subscribe {$peer p/path} :: subscribe
{$poke p/cage} :: apply {$poke p/cage} :: apply
{$puff p/mark q/noun} :: unchecked poke {$puff p/mark q/noun} :: unchecked poke
{$pull ~} :: unsubscribe {$pull p/path} :: unsubscribe
{$punk p/mark q/cage} :: translated poke {$punk p/mark q/cage} :: translated poke
{$pump ~} :: pump yes+no
{$peer-not p/tang} :: poison pill peer {$peer-not p/tang} :: poison pill peer
== :: == ::
++ internal-gift :: ++ internal-gift ::
@ -2072,7 +1995,8 @@
++ gift :: out result <-$ ++ gift :: out result <-$
$% [%init p=ship] :: report install unix $% [%init p=ship] :: report install unix
[%mass p=mass] :: memory usage report [%mass p=mass] :: memory usage report
[%mack p=(unit tang)] :: message n/ack [%done error=(unit error:ames)] :: ames message (n)ack
[%boon payload=*] :: ames response
[%turf turf=(list turf)] :: domains [%turf turf=(list turf)] :: domains
[%private-keys =life vein=(map life ring)] :: private keys [%private-keys =life vein=(map life ring)] :: private keys
[%public-keys =public-keys-result] :: ethereum changes [%public-keys =public-keys-result] :: ethereum changes
@ -2097,7 +2021,7 @@
[%turf ~] :: view domains [%turf ~] :: view domains
$>(%vega vane-task) :: report upgrade $>(%vega vane-task) :: report upgrade
$>(%wegh vane-task) :: memory usage request $>(%wegh vane-task) :: memory usage request
$>(%west vane-task) :: remote request $>(%plea vane-task) :: ames request
== :: == ::
:: ::
+$ dawn-event +$ dawn-event
@ -2272,57 +2196,7 @@
++ oath @ :: signature ++ oath @ :: signature
-- :: pki -- :: pki
-- :: jael -- :: jael
:: :::: --
:::: ++xmas :: (1i) new network
:: ::::
++ xmas ^?
:: ::
:::: ++able:xmas :: (1i1) arvo moves
:: ::::
|%
++ able ^?
|%
++ gift ::
$% {$east p/*} :: response message
{$home p/lane q/@} :: process forward
{$send p/lane q/@} :: send packet
{$rest p/coop} :: acknowledgment
== ::
++ task :: in request ->$
$% {$hear p/lane q/@} ::
{$mess p/ship q/path r/*} :: send message
{$wake ~} ::
== ::
++ card :: out cards
$% {$west p/ship q/path r/*} :: network request
== ::
++ sign :: in response $-<
$: $g ::
$% {$rend p/path q/*} :: network request
{$mack p/(unit tang)} :: message ack
== == ::
++ note :: out request $->
$% {$c $west p/ship q/path r/*} :: to %clay
{$e $west p/ship q/path r/*} :: to %eyre
{$g $west p/ship q/path r/*} :: to %gall
$: $j :: to %jael
$% {$line p/ship q/@da r/code} ::
{$link p/ship q/@da r/code} ::
{$veil p/ship} ::
{$west p/ship q/path r/*} :: to %gall
== == == ::
-- :: able
::
:::: :: (1i2)
::
++ code @uvI :: symmetric key
++ lane :: packet route
$% {$if p/@da q/@ud r/@if} :: IP4/public UDP/addr
{$is p/@ud q/(unit lane) r/@is} :: IPv6 w+alternates
{$ix p/@da q/@ud r/@if} :: IPv4 provisional
== ::
-- ::xmas
-- ::
:: :: :: :: :: ::
:::: :: :: (2) engines :::: :: :: (2) engines
:: :: :: :: :: ::
@ -6873,7 +6747,7 @@
++ saxo :: autocanon ++ saxo :: autocanon
|= [our=ship now=@da who=ship] |= [our=ship now=@da who=ship]
.^ (list ship) .^ (list ship)
%j %k
/(scot %p our)/saxo/(scot %da now)/(scot %p who) /(scot %p our)/saxo/(scot %da now)/(scot %p who)
== ==
:: :: ++sein:title :: :: ++sein:title
@ -7448,6 +7322,15 @@
|=({pax/path hid/bowl} (pale hid (prix pax))) |=({pax/path hid/bowl} (pale hid (prix pax)))
-- ::pubsub -- ::pubsub
-- --
:: +harden: coerce %soft $hobo or pass-through
::
++ harden
|* task=mold
|= wrapped=(hobo task)
^- task
?. ?=(%soft -.wrapped)
wrapped
;;(task +.wrapped)
:: ::
++ zuse %309 :: hoon+zuse kelvin ++ zuse %309 :: hoon+zuse kelvin
++ gift-arvo :: out result <-$ ++ gift-arvo :: out result <-$
@ -7467,14 +7350,14 @@
task:able:clay task:able:clay
task:able:behn task:able:behn
task:able:dill task:able:dill
task:able:iris task:able:eyre
task:able:ford task:able:ford
task:able:gall task:able:gall
task:able:eyre task:able:iris
task:able:jael task:able:jael
== ==
++ note-arvo :: out request $-> ++ note-arvo :: out request $->
$~ [%a %wake ~] $~ [%b %wake ~]
$% {$a task:able:ames} $% {$a task:able:ames}
{$b task:able:behn} {$b task:able:behn}
{$c task:able:clay} {$c task:able:clay}
@ -7501,13 +7384,11 @@
[%i gift:able:iris] [%i gift:able:iris]
{$j gift:able:jael} {$j gift:able:jael}
== ==
:: $unix-task: input from unix
:: ::
+$ unix-task :: input from unix +$ unix-task
$~ [%wake ~] $~ [%wake ~]
$% :: %ames: new process $% :: %dill: keyboard input
::
$>(%barn task:able:ames)
:: %dill: keyboard input
:: ::
$>(%belt task:able:dill) $>(%belt task:able:dill)
:: %dill: configure terminal (resized) :: %dill: configure terminal (resized)
@ -7552,9 +7433,6 @@
:: %behn: wakeup :: %behn: wakeup
:: ::
$>(%wake task:able:behn) $>(%wake task:able:behn)
:: %ames: send message
::
$>(%want task:able:ames)
== ==
:: :: :: ::
:::: ++azimuth :: (2az) azimuth :::: ++azimuth :: (2az) azimuth
@ -7640,7 +7518,7 @@
:: # constants :: # constants
:: ::
:: contract addresses :: contract addresses
++ contracts mainnet-contracts ++ contracts ropsten-contracts
++ mainnet-contracts ++ mainnet-contracts
|% |%
:: azimuth: data contract :: azimuth: data contract

View File

@ -5,56 +5,64 @@
:: ::
=/ vane (alef !>(..zuse)) =/ vane (alef !>(..zuse))
:: ::
=/ alice vane =/ nec vane
=/ bob vane =/ bud vane
:: ::
=. our.alice ~nec =. our.nec ~nec
=. now.alice ~1111.1.1 =. now.nec ~1111.1.1
=. eny.alice 0xdead.beef =. eny.nec 0xdead.beef
=. scry-gate.nec |=(* ``[%noun !>(*(list turf))])
:: ::
=. our.bob ~doznec-doznec =. our.bud ~bud
=. now.bob ~1111.1.1 =. now.bud ~1111.1.1
=. eny.bob 0xbeef.dead =. eny.bud 0xbeef.dead
=. scry-gate.bud |=(* ``[%noun !>(*(list turf))])
:: ::
=. crypto-core.ames-state.alice (pit:nu:crub:crypto 512 (shaz 'alice')) =. crypto-core.ames-state.nec (pit:nu:crub:crypto 512 (shaz 'nec'))
=. crypto-core.ames-state.bob (pit:nu:crub:crypto 512 (shaz 'bob')) =. crypto-core.ames-state.bud (pit:nu:crub:crypto 512 (shaz 'bud'))
:: ::
=/ alice-pub pub:ex:crypto-core.ames-state.alice =/ nec-pub pub:ex:crypto-core.ames-state.nec
=/ alice-sec sec:ex:crypto-core.ames-state.alice =/ nec-sec sec:ex:crypto-core.ames-state.nec
=/ bob-pub pub:ex:crypto-core.ames-state.bob =/ bud-pub pub:ex:crypto-core.ames-state.bud
=/ bob-sec sec:ex:crypto-core.ames-state.bob =/ bud-sec sec:ex:crypto-core.ames-state.bud
:: ::
=/ alice-sym (derive-symmetric-key:alef bob-pub alice-sec) =/ nec-sym (derive-symmetric-key:vane bud-pub nec-sec)
=/ bob-sym (derive-symmetric-key:alef alice-pub bob-sec) =/ bud-sym (derive-symmetric-key:vane nec-pub bud-sec)
:: ::
?> =(alice-sym bob-sym) ?> =(nec-sym bud-sym)
:: ::
=. life.ames-state.alice 2 =. life.ames-state.nec 2
=. peers.ames-state.alice =. peers.ames-state.nec
%+ ~(put by peers.ames-state.alice) ~doznec-doznec %+ ~(put by peers.ames-state.nec) ~bud
=| =peer-state:alef =| =peer-state:alef
=. -.peer-state =. -.peer-state
:* symmetric-key=bob-sym :* symmetric-key=bud-sym
life=3 life=3
public-key=bob-pub public-key=bud-pub
sponsor=~marzod sponsor=~nec
== ==
=. route.peer-state `[direct=%.y `lane:alef`[%& ~nec]] =. route.peer-state `[direct=%.y `lane:alef`[%& ~nec]]
[%known peer-state] [%known peer-state]
:: ::
=. life.ames-state.bob 3 =. life.ames-state.bud 3
=. peers.ames-state.bob =. peers.ames-state.bud
%+ ~(put by peers.ames-state.bob) ~nec %+ ~(put by peers.ames-state.bud) ~nec
=| =peer-state:alef =| =peer-state:alef
=. -.peer-state =. -.peer-state
:* symmetric-key=alice-sym :* symmetric-key=nec-sym
life=2 life=2
public-key=alice-pub public-key=nec-pub
sponsor=~nec sponsor=~nec
== ==
=. route.peer-state `[direct=%.y `lane:alef`[%| `@`%lane-bar]] =. route.peer-state `[direct=%.y `lane:alef`[%| `@`%lane-bar]]
[%known peer-state] [%known peer-state]
:: metamorphose
:: ::
=> .(nec +:(call:(nec) ~[//unix] ** %born ~))
=> .(bud +:(call:(bud) ~[//unix] ** %born ~))
:: helper core
::
=>
|% |%
++ move-to-packet ++ move-to-packet
|= =move:alef |= =move:alef
@ -75,19 +83,37 @@
%- move-to-packet %- move-to-packet
%+ snag index %+ snag index
(skim moves is-move-send) (skim moves is-move-send)
::
++ call
|= [vane=_nec =duct =task:alef]
^- [moves=(list move:alef) _nec]
::
=/ vane-core (vane(now `@da`(add ~s1 now.vane)))
::
(call:vane-core duct ** task)
::
++ take
|= [vane=_nec =wire =duct =sign:alef]
^- [moves=(list move:alef) _nec]
::
=/ vane-core (vane(now `@da`(add ~s1 now.vane)))
::
(take:vane-core wire duct ** sign)
-- --
:: test core
::
|% |%
++ test-packet-encoding ^- tang ++ test-packet-encoding ^- tang
:: ::
=/ =packet:alef =/ =packet:alef
:* [sndr=~nec rcvr=~doznec-doznec] :* [sndr=~nec rcvr=~bud]
encrypted=%.n encrypted=%.n
origin=~ origin=~
content=[12 13] content=[12 13]
== ==
:: ::
=/ encoded (encode-packet:alef packet) =/ encoded (encode-packet:vane packet)
=/ decoded (decode-packet:alef encoded) =/ decoded (decode-packet:vane encoded)
:: ::
%+ expect-eq %+ expect-eq
!> packet !> packet
@ -97,104 +123,108 @@
:: ::
=/ lane-foo=lane:alef [%| `@ux``@`%lane-foo] =/ lane-foo=lane:alef [%| `@ux``@`%lane-foo]
:: ::
=/ =message:alef [/g/talk [%first %post]] =/ =plea:ames [%g /talk [%first %post]]
:: ::
=/ =shut-packet:alef =/ =shut-packet:alef
:* sndr-life=4 :* sndr-life=4
rcvr-life=3 rcvr-life=3
bone=1 bone=1
message-num=1 message-num=1
[%& num-fragments=1 fragment-num=0 (jam message)] [%& num-fragments=1 fragment-num=0 (jam plea)]
== ==
:: ::
=/ =packet:alef =/ =packet:alef
:* [sndr=~bus rcvr=~doznec-doznec] :* [sndr=~bus rcvr=~bud]
encrypted=%.y encrypted=%.y
origin=~ origin=~
content=(encrypt:alef alice-sym shut-packet) content=(encrypt:vane nec-sym shut-packet)
== ==
:: ::
=/ =blob:alef (encode-packet:alef packet) =/ =blob:alef (encode-packet:vane packet)
=^ moves1 bob (call bob ~[//unix] %hear lane-foo blob) =^ moves1 bud (call bud ~[//unix] %hear lane-foo blob)
=^ moves2 bob =^ moves2 bud
=/ =point:alef =/ =point:alef
:* rift=1 :* rift=1
life=4 life=4
crypto-suite=1 keys=[[life=4 [crypto-suite=1 `@`nec-pub]] ~ ~]
encryption-key=`@`alice-pub
authentication-key=`@`0
sponsor=`~bus sponsor=`~bus
== ==
%- take %- take
:^ bob /alien ~[//unix] :^ bud /public-keys ~[//unix]
^- sign:alef ^- sign:alef
[%j %public-keys %full [n=[~bus point] ~ ~]] [%k %public-keys %full [n=[~bus point] ~ ~]]
:: ::
;: weld ;: weld
%+ expect-eq %+ expect-eq
!> [~[//unix] %pass /alien %j %public-keys ~bus]~ !> [~[//unix] %pass /public-keys %k %public-keys [~bus ~ ~]]~
!> moves1 !> moves1
:: ::
%+ expect-eq %+ expect-eq
!> [~[//unix] %pass /bone/~bus/1 %g %memo ~bus /g/talk [%first %post]]~ !> %- sy
!> moves2 :~ :^ ~[//unix] %pass /bone/~bus/1
[%g %plea ~bus %g /talk [%first %post]]
::
:^ ~[//unix] %pass /qos
[%d %flog %text "; ~bus is your neighbor"]
==
!> (sy ,.moves2)
== ==
:: ::
++ test-message-flow ^- tang ++ test-message-flow ^- tang
:: ~nec -> %plea -> ~bud
:: ::
=^ moves1 alice =^ moves1 nec (call nec ~[/g/talk] %plea ~bud %g /talk [%get %post])
(call alice ~[/alice] %memo ~doznec-doznec /g/talk [%get %post]) =^ moves2 bud (call bud ~[//unix] %hear (snag-packet 0 moves1))
:: ~bud -> %done -> ~nec
:: ::
=^ moves2 bob (call bob ~[/bob] %hear (snag-packet 0 moves1)) =^ moves3 bud (take bud /bone/~nec/1 ~[//unix] %g %done ~)
=^ moves3 bob (take bob /bone/~nec/1 ~[/bob] %g %done ~) =^ moves4 nec (call nec ~[//unix] %hear (snag-packet 0 moves3))
=^ moves4 alice (call alice ~[/alice] %hear (snag-packet 0 moves3)) :: ~bud -> %boon -> ~nec
=^ moves5 bob
(take bob /bone/~nec/1 ~[/bob] %g %memo /g/talk [%post 'first1!!'])
:: ::
=^ moves6 alice (call alice ~[/alice] %hear (snag-packet 0 moves5)) =^ moves5 bud (take bud /bone/~nec/1 ~[//unix] %g %boon [%post 'first1!!'])
=^ moves7 bob (call bob ~[/bob] %hear (snag-packet 0 moves6)) =^ moves6 nec (call nec ~[//unix] %hear (snag-packet 0 moves5))
:: ~nec -> %done -> ~bud (just make sure ~bud doesn't crash on ack)
::
=^ moves7 bud (call bud ~[//unix] %hear (snag-packet 0 moves6))
:: ::
;: weld ;: weld
%+ expect-eq %+ expect-eq
!> :~ :+ ~[/alice] %give [%done error=~] !> :~ [~[//unix] %pass /qos %d %flog %text "; ~nec is your neighbor"]
:+ ~[/alice] %pass [~[//unix] %pass /bone/~nec/1 %g %plea ~nec %g /talk [%get %post]]
[/pump/~doznec-doznec/0 %b %rest ~1111.1.1..00.00.06]
== ==
!> moves4 !> moves2
:: ::
%+ expect-eq %+ expect-eq
!> [~[/alice] %give %memo /g/talk %post 'first1!!'] !> %- sy
:~ [~[//unix] %pass /qos %d %flog %text "; ~bud is your neighbor"]
[~[//unix] %pass /pump/~bud/0 %b %rest ~1111.1.1..00.00.06]
[~[/g/talk] %give %done error=~]
==
!> (sy ,.moves4)
::
%+ expect-eq
!> [~[/g/talk] %give %boon [%post 'first1!!']]
!> (snag 1 `(list move:alef)`moves6) !> (snag 1 `(list move:alef)`moves6)
== ==
:: ::
++ test-nack ^- tang ++ test-nack ^- tang
=^ moves1 alice :: ~nec -> %plea -> ~bud
(call alice ~[/alice] %memo ~doznec-doznec /g/talk [%get %post])
:: ::
=^ moves2 bob (call bob ~[/bob] %hear (snag-packet 0 moves1)) =^ moves1 nec (call nec ~[/g/talk] %plea ~bud %g /talk [%get %post])
=/ =error:alef [%flub [%leaf "sinusoidal repleneration"]~] =^ moves2 bud (call bud ~[//unix] %hear (snag-packet 0 moves1))
=^ moves3 bob (take bob /bone/~nec/1 ~[/bob] %g %done `error) :: ~bud -> nack -> ~nec
=^ moves4 alice (call alice ~[/alice] %hear (snag-packet 0 moves3)) ::
=^ moves5 alice (call alice ~[/alice] %hear (snag-packet 1 moves3)) =/ =error:alef [%flub [%leaf "sinusoidal repleneration"]~]
=^ moves6 bob (call bob ~[/bob] %hear (snag-packet 0 moves5)) =^ moves3 bud (take bud /bone/~nec/1 ~[/bud] %g %done `error)
=^ moves4 nec (call nec ~[//unix] %hear (snag-packet 0 moves3))
:: ~bud -> nack-trace -> ~nec
::
=^ moves5 nec (call nec ~[//unix] %hear (snag-packet 1 moves3))
:: ~nec -> ack nack-trace -> ~bud
::
=^ moves6 bud (call bud ~[//unix] %hear (snag-packet 0 moves5))
:: ::
%+ expect-eq %+ expect-eq
!> [~[/alice] %give %done `error] !> [~[/g/talk] %give %done `error]
!> (snag 1 `(list move:alef)`moves5) !> (snag 1 `(list move:alef)`moves5)
::
++ call
|= [vane=_alice =duct =task:alef]
^- [moves=(list move:alef) _alice]
::
=/ vane-core (vane(now `@da`(add ~s1 now.vane)))
::
(call:vane-core duct ** task)
::
++ take
|= [vane=_alice =wire =duct =sign:alef]
^- [moves=(list move:alef) _alice]
::
=/ vane-core (vane(now `@da`(add ~s1 now.vane)))
::
(take:vane-core wire duct ** sign)
-- --

View File

@ -1,175 +0,0 @@
/+ *test
::
/= ames-raw /: /===/sys/vane/ames
/!noun/
=/ type-spear -:!>(ames-raw)
::
=/ test-pit=vase !>(.)
=/ ames-gate (ames-raw test-pit)
::
|%
:: tests that %ames asks for private keys on %init
::
++ test-init
=^ results1 ames-gate
=/ =duct [/ /term/1 / ~]
=/ =wire /our/~nul
%: ames-call
ames-gate
now=~1234.5.6
call-args=[duct type=*type %soft %init ~nul]
expected-moves=[[duct %pass wire %j %private-keys ~] [duct %pass / %j %turf ~] ~]
==
::
results1
::
:: tests that %ames sends a message to itself
::
++ test-send
=/ now ~1234.5.6
=/ =duct [/ /term/1 / ~]
=/ =wire /our/~nul
=/ pact1
0wHfb.1hdCh.0oxed.Ta7-f.4IIDV.4ku6J.PoJe7.AiyMS.w~mfu.V04ja.iXj8d.E3nq7.
gcW-a.0II6T.vb5zH.FHEkp.J7wgT.XTnuu.KaUiu.xZ6dg.qgWSH.3ovaO.dETNQ.5YAOR.
Lw8Mj.iQCrM.-TcjY.gFysP.XCfdx.52ack.MN~yA.0CNFU.0eL1M.Un-ey.CZyf9.Omk2p.
-Wbar.-w2bs.02sNg.340cg.okHUP
=/ pact2
0w78EWp.7898D.odZ3b.7iLvr.vyjzn.XBNaN.vxTZj.b4BFp.EHHvW.IjvpB.j0~87.
t06D0.SbrGK.QlIeE.1Xj1v.CX~YY.c9cAE.eUPSb.gj8-M.e15TJ.EPPXN.efms-.8y9og.
IdyLr.lkZJ5.KMB-F.S7mwd.t5rmo.CEYCp.3zC4n.HYh2T.RgVI8.0eT1z.Jxj9c.m1Sm5.
SaYrP.0LKO3.-w2cA.02sNg.340cg.oi9Nj
=/ vein-data
[life=1 (my [1 sec:ex:(pit:nu:crub:crypto 512 ~nul)] ~)]
::
=^ results1 ames-gate
%: ames-call
ames-gate
now
call-args=[duct type=*type %soft [%barn ~]]
expected-moves=[[duct %give %turf ~] ~]
==
::
=. now (add ~m1 now)
:: ~& [%fox1 now fox.ames-gate]
=^ results2 ames-gate
%: ames-take
ames-gate
now
take-args=[wire duct -:!>([%j %private-keys vein-data]) [%j %private-keys vein-data]]
expected-moves=~
==
::
=. now (add ~m1 now)
:: ~& [%fox2 now fox.ames-gate]
=^ results3 ames-gate
%: ames-call
ames-gate
now
call-args=[duct type=*type %soft [%want ~nul /foo 1]]
:~ [duct %pass /pubs/~nul %j %public-keys (silt ~nul ~)]
[duct %give %send *lane:ames pact1]
:: XX why ~s4 ??
::
[duct %pass /ames %b %wait (add ~s4 now)]
==
==
::
=. now (add ~m1 now)
:: ~& [%fox3 now fox.ames-gate]
=^ results4 ames-gate
%: ames-call
ames-gate
now
call-args=[duct type=*type %soft [%want ~nul /foo 2]]
expected-moves=[[duct %give %send *lane:ames pact2] ~]
==
::
=. now (add ~m1 now)
:: ~& [%fox4 now fox.ames-gate]
=^ results5 ames-gate
%: ames-take
ames-gate
now
take-args=[wire duct -:!>([%b %wake ~]) [%b %wake ~]]
:~ [duct %give %send *lane:ames pact1]
[duct %give %send *lane:ames pact2]
[duct %pass /ames %b %wait (add ~s8 now)]
==
==
::
:: ~& [%fox5 now fox.ames-gate]
:(weld results1 results2 results3 results4 results5)
::
++ ames-scry
^- sley
|= [* (unit (set monk)) =term =beam]
^- (unit (unit cage))
?: =(%turf q.beam)
(some (some %noun !>(~)))
::
?: ?& =(%life q.beam)
=(/~nul s.beam)
==
(some (some %atom !>(1)))
::
?: ?& =(%saxo q.beam)
=(/~nul s.beam)
==
(some (some %noun !>([~nul ~])))
::
?: ?& =(%sein q.beam)
=(/~nul s.beam)
==
(some (some %atom !>(~nul)))
::
?: ?& =(%deed q.beam)
=(/1/~nul s.beam)
==
=/ =deed:ames
[life=1 pub:ex:(pit:nu:crub:crypto 512 ~nul) ~]
(some (some %noun !>(deed)))
::
~& [%ames-scry-fail +<]
~
::
++ ames-call
|= $: ames-gate=_ames-gate
now=@da
call-args=[=duct wrapped-task=(hypo (hobo task:able:ames-gate))]
expected-moves=(list move:ames-gate)
==
^- [tang _ames-gate]
::
=/ ames (ames-gate our=~nul now=now eny=`@`0xdead.beef ames-scry)
::
=^ moves ames-gate
(call:ames call-args)
::
=/ output=tang
%+ expect-eq
!> expected-moves
!> moves
::
[output ames-gate]
::
++ ames-take
|= $: ames-gate=_ames-gate
now=@da
take-args=[=wire =duct wrapped-sign=(hypo sign:ames-gate)]
expected-moves=(list move:ames-gate)
==
^- [tang _ames-gate]
::
=/ ames (ames-gate our=~nul now=now eny=`@`0xdead.beef ames-scry)
::
=^ moves ames-gate
(take:ames take-args)
::
=/ output=tang
%+ expect-eq
!> expected-moves
!> moves
::
[output ames-gate]
--

View File

@ -15,7 +15,7 @@ worker_objs = $(shell echo $(worker) | sed 's/\.c/.o/g')
all_objs = $(common_objs) $(daemon_objs) $(worker_objs) all_objs = $(common_objs) $(daemon_objs) $(worker_objs)
all_srcs = $(common) $(daemon) $(worker) all_srcs = $(common) $(daemon) $(worker)
all_exes = ./build/mug_tests ./build/jam_tests \ all_exes = ./build/ames_tests ./build/mug_tests ./build/jam_tests \
./build/noun_tests ./build/hashtable_tests \ ./build/noun_tests ./build/hashtable_tests \
./build/urbit ./build/urbit-worker ./build/urbit ./build/urbit-worker
@ -31,7 +31,8 @@ CFLAGS := $(CFLAGS)
all: $(all_exes) all: $(all_exes)
test: build/hashtable_tests build/jam_tests build/mug_tests build/noun_tests test: build/ames_tests build/hashtable_tests build/jam_tests build/mug_tests build/noun_tests
./build/ames_tests
./build/hashtable_tests ./build/hashtable_tests
./build/jam_tests ./build/jam_tests
./build/mug_tests ./build/mug_tests
@ -45,6 +46,23 @@ mrproper: clean
################################################################################ ################################################################################
include/ca-bundle.h:
@echo XXD -i $(SSL_CERT_FILE)
@cat $(SSL_CERT_FILE) > include/ca-bundle.crt
@xxd -i include/ca-bundle.crt > include/ca-bundle.h
@rm include/ca-bundle.crt
include/ivory.h:
@echo XXD -i $(IVORY)
@cat $(IVORY) > u3_Ivory.pill
@xxd -i u3_Ivory.pill > include/ivory.h
@rm u3_Ivory.pill
build/ames_tests: $(common_objs) tests/ames_tests.o
@echo CC -o $@
@mkdir -p ./build
@$(CC) $^ $(LDFLAGS) -o $@
build/hashtable_tests: $(common_objs) tests/hashtable_tests.o build/hashtable_tests: $(common_objs) tests/hashtable_tests.o
@echo CC -o $@ @echo CC -o $@
@mkdir -p ./build @mkdir -p ./build

BIN
pkg/urbit/hashtable_tests Executable file

Binary file not shown.

View File

@ -248,6 +248,13 @@
c3_c* dns_c; // galaxy fqdn (optional) c3_c* dns_c; // galaxy fqdn (optional)
} u3_pact; } u3_pact;
/* u3_lane: ames lane (IP address and port)
*/
typedef struct _u3_lane {
c3_w pip_w; // target IPv4 address
c3_s por_s; // target port
} u3_lane;
/* u3_poke: poke callback function. /* u3_poke: poke callback function.
*/ */
typedef void (*u3_poke)(void*, u3_noun); typedef void (*u3_poke)(void*, u3_noun);
@ -330,7 +337,6 @@
uv_udp_t wax_u; uv_udp_t wax_u;
uv_handle_t had_u; uv_handle_t had_u;
}; };
uv_timer_t tim_u; // XX temporary timer
c3_o liv; // listener on c3_o liv; // listener on
c3_o alm; // alarm on c3_o alm; // alarm on
c3_s por_s; // public IPv4 port c3_s por_s; // public IPv4 port
@ -979,6 +985,15 @@
void void
u3_ames_io_exit(u3_pier* pir_u); u3_ames_io_exit(u3_pier* pir_u);
/* u3_ames_decode_lane(): destructure lane from noun
*/
u3_lane
u3_ames_decode_lane(u3_noun);
/* u3_ames_encode_lane(): encode lane as noun
*/
u3_noun
u3_ames_encode_lane(u3_lane);
/** Autosave. /** Autosave.
**/ **/

View File

@ -0,0 +1,44 @@
#include "all.h"
#include "vere/vere.h"
/* _setup(): prepare for tests.
*/
static void
_setup(void)
{
u3m_init();
u3m_pave(c3y, c3n);
}
/* _test_ames(): spot check ames helpers
*/
static void
_test_ames(void)
{
u3_lane lan_u;
lan_u.pip_w = 0x7f000001;
lan_u.por_s = 12345;
u3_noun lan = u3_ames_encode_lane(lan_u);
u3_lane nal_u = u3_ames_decode_lane(u3k(lan));
u3_lane nal_u2 = u3_ames_decode_lane(lan);
if ( !(lan_u.pip_w == nal_u.pip_w && lan_u.por_s == nal_u.por_s) ) {
fprintf(stderr, "ames: lane fail (a)\r\n");
fprintf(stderr, "pip: %d, por: %d\r\n", nal_u.pip_w, nal_u.por_s);
exit(1);
}
}
/* main(): run all test cases.
*/
int
main(int argc, char* argv[])
{
_setup();
_test_ames();
fprintf(stderr, "ames okeedokee");
return 0;
}

BIN
pkg/urbit/urbit Executable file

Binary file not shown.

BIN
pkg/urbit/urbit-worker Executable file

Binary file not shown.

View File

@ -88,7 +88,6 @@ _ames_send(u3_pact* pac_u)
add_u.sin_port = htons(pac_u->por_s); add_u.sin_port = htons(pac_u->por_s);
uv_buf_t buf_u = uv_buf_init((c3_c*)pac_u->hun_y, pac_u->len_w); uv_buf_t buf_u = uv_buf_init((c3_c*)pac_u->hun_y, pac_u->len_w);
c3_i sas_i; c3_i sas_i;
if ( 0 != (sas_i = uv_udp_send(&pac_u->snd_u, if ( 0 != (sas_i = uv_udp_send(&pac_u->snd_u,
@ -194,6 +193,33 @@ _ames_czar_cb(uv_getaddrinfo_t* adr_u,
uv_freeaddrinfo(aif_u); uv_freeaddrinfo(aif_u);
} }
/* u3_ames_decode_lane(): deserialize noun to lane
*/
u3_lane
u3_ames_decode_lane(u3_atom lan) {
u3_noun cud, tag, pip, por;
cud = u3ke_cue(lan);
u3x_trel(cud, &tag, &pip, &por);
c3_assert( c3__ipv4 == tag );
u3_lane lan_u;
lan_u.pip_w = u3r_word(0, pip);
c3_assert( _(u3a_is_cat(por)) );
c3_assert( por < 65536 );
lan_u.por_s = por;
u3z(cud);
return lan_u;
}
/* u3_ames_encode_lane(): serialize lane to jammed noun
*/
u3_atom
u3_ames_encode_lane(u3_lane lan) {
return u3ke_jam(u3nt(c3__ipv4, u3i_words(1, &lan.pip_w), lan.por_s));
}
/* _ames_czar(): galaxy address resolution. /* _ames_czar(): galaxy address resolution.
*/ */
@ -268,34 +294,6 @@ _ames_czar(u3_pact* pac_u, c3_c* bos_c)
} }
} }
/* _ames_lane_ipv4(): IPv4 address/ from lane.
*/
u3_noun
_ames_lane_ip(u3_noun lan, c3_s* por_s, c3_w* pip_w)
{
switch ( u3h(lan) ) {
case c3__if: {
*por_s= (c3_s) u3h(u3t(u3t(lan)));
*pip_w = u3r_word(0, u3t(u3t(u3t(lan))));
return c3y;
} break;
case c3__is: {
u3_noun pq_lan = u3h(u3t(u3t(lan)));
if ( u3_nul == pq_lan ) return c3n;
else return _ames_lane_ip(u3t(pq_lan), por_s, pip_w);
} break;
case c3__ix: {
*por_s = (c3_s) u3h(u3t(u3t(lan)));
*pip_w = u3r_word(0, u3t(u3t(u3t(lan))));
return c3y;
} break;
}
return c3n;
}
/* u3_ames_ef_bake(): notify %ames that we're live. /* u3_ames_ef_bake(): notify %ames that we're live.
*/ */
void void
@ -303,7 +301,7 @@ u3_ames_ef_bake(u3_pier* pir_u)
{ {
u3_noun pax = u3nq(u3_blip, c3__newt, u3k(u3A->sen), u3_nul); u3_noun pax = u3nq(u3_blip, c3__newt, u3k(u3A->sen), u3_nul);
u3_pier_plan(pax, u3nc(c3__barn, u3_nul)); u3_pier_plan(pax, u3nc(c3__born, u3_nul));
} }
/* u3_ames_ef_send(): send packet to network (v4). /* u3_ames_ef_send(): send packet to network (v4).
@ -320,35 +318,45 @@ u3_ames_ef_send(u3_pier* pir_u, u3_noun lan, u3_noun pac)
} }
u3_pact* pac_u = c3_calloc(sizeof(*pac_u)); u3_pact* pac_u = c3_calloc(sizeof(*pac_u));
pac_u->len_w = u3r_met(3, pac);
pac_u->hun_y = c3_malloc(pac_u->len_w);
if ( c3y == _ames_lane_ip(lan, &pac_u->por_s, &pac_u->pip_w) ) { u3r_bytes(0, pac_u->len_w, pac_u->hun_y, pac);
pac_u->len_w = u3r_met(3, pac);
pac_u->hun_y = c3_malloc(pac_u->len_w);
u3r_bytes(0, pac_u->len_w, pac_u->hun_y, pac); u3_noun tag, val;
u3x_cell(lan, &tag, &val);
c3_assert( (c3y == tag) || (c3n == tag) );
if ( 0 == pac_u->pip_w ) { // galaxy lane; do DNS lookup and send packet
pac_u->pip_w = 0x7f000001; //
pac_u->por_s = pir_u->por_s; if ( c3y == tag ) {
} c3_assert( c3y == u3a_is_cat(val) );
c3_assert( val < 256 );
if ( (0 == (pac_u->pip_w >> 16)) && (1 == (pac_u->pip_w >> 8)) ) { pac_u->imp_y = val;
pac_u->imp_y = (pac_u->pip_w & 0xff); _ames_czar(pac_u, sam_u->dns_c);
}
_ames_czar(pac_u, sam_u->dns_c); // non-galaxy lane
} //
else if ( (c3y == u3_Host.ops_u.net) || (0x7f000001 == pac_u->pip_w) ) { else {
_ames_send(pac_u); u3_lane lan_u = u3_ames_decode_lane(u3k(val));
} // convert incoming localhost to outgoing localhost
else { //
// networking disabled lan_u.pip_w = ( 0 == lan_u.pip_w )? 0x7f000001 : lan_u.pip_w;
// if in local-only mode, don't send remote packets
//
if ( (c3n == u3_Host.ops_u.net) && (0x7f000001 != lan_u.pip_w) ) {
_ames_pact_free(pac_u); _ames_pact_free(pac_u);
} }
} // otherwise, mutate destination and send packet
else { //
_ames_pact_free(pac_u); else {
} pac_u->pip_w = lan_u.pip_w;
pac_u->por_s = lan_u.por_s;
_ames_send(pac_u);
}
}
u3z(lan); u3z(pac); u3z(lan); u3z(pac);
} }
@ -374,30 +382,21 @@ _ames_recv_cb(uv_udp_t* wax_u,
#if 0 #if 0
u3z(msg); u3z(msg);
#else #else
u3_lane lan_u;
struct sockaddr_in* add_u = (struct sockaddr_in *)adr_u; struct sockaddr_in* add_u = (struct sockaddr_in *)adr_u;
c3_s por_s = ntohs(add_u->sin_port);
c3_w pip_w = ntohl(add_u->sin_addr.s_addr);
u3_pier_plan lan_u.por_s = ntohs(add_u->sin_port);
(u3nt(u3_blip, c3__ames, u3_nul), lan_u.pip_w = ntohl(add_u->sin_addr.s_addr);
u3nt(c3__hear, u3_noun lan = u3_ames_encode_lane(lan_u);
u3nq(c3__if, u3k(u3A->now), por_s, u3i_words(1, &pip_w)), u3_noun mov = u3nt(c3__hear, u3nc(c3n, lan), msg);
msg));
u3_pier_plan(u3nt(u3_blip, c3__ames, u3_nul), mov);
#endif #endif
} }
_ames_free(buf_u->base); _ames_free(buf_u->base);
} }
} }
/* _ames_timer_cb(): wake up ames
*/
static void
_ames_timer_cb(uv_timer_t* tim_u)
{
u3_pier_plan(u3nt(u3_blip, c3__ames, u3_nul),
u3nc(c3__wake, u3_nul));
}
/* _ames_io_start(): initialize ames I/O. /* _ames_io_start(): initialize ames I/O.
*/ */
static void static void
@ -467,8 +466,6 @@ _ames_io_start(u3_pier* pir_u)
sam_u->liv = c3y; sam_u->liv = c3y;
u3z(rac); u3z(rac);
u3z(who); u3z(who);
uv_timer_start(&sam_u->tim_u, _ames_timer_cb, 300 * 1000, 300 * 1000);
} }
/* _cttp_mcut_char(): measure/cut character. /* _cttp_mcut_char(): measure/cut character.
@ -561,8 +558,6 @@ u3_ames_io_init(u3_pier* pir_u)
{ {
u3_ames* sam_u = pir_u->sam_u; u3_ames* sam_u = pir_u->sam_u;
sam_u->liv = c3n; sam_u->liv = c3n;
uv_timer_init(u3L, &sam_u->tim_u);
} }
/* u3_ames_io_talk(): start receiving ames traffic. /* u3_ames_io_talk(): start receiving ames traffic.
@ -570,6 +565,7 @@ u3_ames_io_init(u3_pier* pir_u)
void void
u3_ames_io_talk(u3_pier* pir_u) u3_ames_io_talk(u3_pier* pir_u)
{ {
_ames_io_start(pir_u);
} }
/* u3_ames_io_exit(): terminate ames I/O. /* u3_ames_io_exit(): terminate ames I/O.
@ -583,6 +579,4 @@ u3_ames_io_exit(u3_pier* pir_u)
// XX remove had_u/wax_u union, cast and close wax_u // XX remove had_u/wax_u union, cast and close wax_u
uv_close(&sam_u->had_u, 0); uv_close(&sam_u->had_u, 0);
} }
uv_close((uv_handle_t*)&sam_u->tim_u, 0);
} }

View File

@ -376,6 +376,21 @@ _worker_send_slog(u3_noun hod)
_worker_send(u3nt(c3__slog, u3i_chubs(1, &u3V.sen_d), hod)); _worker_send(u3nt(c3__slog, u3i_chubs(1, &u3V.sen_d), hod));
} }
/* _worker_send_tang(): send list of hoon tanks as hint outputs.
*/
static void
_worker_send_tang(c3_y pri_y, u3_noun tan)
{
u3_noun i_tan, t_tan;
while ( u3_nul != tan ) {
i_tan = u3k(u3h(tan));
t_tan = u3k(u3t(tan));
u3z(tan);
_worker_send_slog(u3nc(pri_y, i_tan));
tan = t_tan;
}
}
/* _worker_lame(): event failed, replace with error event. /* _worker_lame(): event failed, replace with error event.
*/ */
static void static void
@ -395,6 +410,7 @@ _worker_lame(c3_d evt_d, u3_noun now, u3_noun ovo, u3_noun why, u3_noun tan)
// with a crypto failure, just drop the packet. // with a crypto failure, just drop the packet.
// //
if ( (c3__hear == tag) && (c3__exit == why) ) { if ( (c3__hear == tag) && (c3__exit == why) ) {
_worker_send_tang(1, u3k(tan));
rep = u3nt(u3k(wir), c3__hole, u3k(cad)); rep = u3nt(u3k(wir), c3__hole, u3k(cad));
} }
// failed event notifications (%crud) are replaced with // failed event notifications (%crud) are replaced with
@ -406,6 +422,7 @@ _worker_lame(c3_d evt_d, u3_noun now, u3_noun ovo, u3_noun why, u3_noun tan)
else if ( c3__crud == tag ) { else if ( c3__crud == tag ) {
u3_noun lef = u3nc(c3__leaf, u3i_tape("crude crashed!")); u3_noun lef = u3nc(c3__leaf, u3i_tape("crude crashed!"));
u3_noun nat = u3kb_weld(u3k(u3t(cad)), u3nc(lef, u3k(tan))); u3_noun nat = u3kb_weld(u3k(u3t(cad)), u3nc(lef, u3k(tan)));
_worker_send_tang(1, u3k(nat));
rep = u3nc(u3nt(u3_blip, c3__arvo, u3_nul), rep = u3nc(u3nt(u3_blip, c3__arvo, u3_nul),
u3nt(c3__warn, u3k(u3h(cad)), nat)); u3nt(c3__warn, u3k(u3h(cad)), nat));
} }
@ -425,6 +442,7 @@ _worker_lame(c3_d evt_d, u3_noun now, u3_noun ovo, u3_noun why, u3_noun tan)
u3_noun lef = u3nc(c3__leaf, u3kb_weld(u3i_tape("bail: "), u3_noun lef = u3nc(c3__leaf, u3kb_weld(u3i_tape("bail: "),
u3qc_rip(3, why))); u3qc_rip(3, why)));
u3_noun nat = u3kb_weld(u3k(tan), u3nc(lef, u3_nul)); u3_noun nat = u3kb_weld(u3k(tan), u3nc(lef, u3_nul));
_worker_send_tang(1, u3k(nat));
rep = u3nc(u3k(wir), u3nt(c3__crud, u3k(tag), nat)); rep = u3nc(u3k(wir), u3nt(c3__crud, u3k(tag), nat));
} }