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
?+ -.q.i.ufs.afs this
%restore (handle-restore who.afs)
%send (handle-send i.ufs.afs)
%send (handle-send who.afs i.ufs.afs)
==
$(ufs.afs t.ufs.afs)
::
++ handle-restore
|= who=@p
%- emit-aqua-events
[%event who [//newt/0v1n.2m9vh %barn ~]]~
[%event who [//newt/0v1n.2m9vh %born ~]]~
::
++ handle-send
|= [way=wire %send lan=lane:ames pac=@]
|= [sndr=ship way=wire %send lan=lane:ames pac=@]
^+ this
=/ hear [//newt/0v1n.2m9vh %hear lan pac]
=? ships =(~ ships)
.^((list ship) %gx /(scot %p our)/aqua/(scot %da now)/ships/noun)
=/ rcvr=ship (lane-to-ship lan)
=/ hear-lane (ship-to-lane sndr)
=> ?. ?| =(rcvr ~linnup-torsyx-linnup-torsyx)
=(sndr ~linnup-torsyx-linnup-torsyx)
==
.
~> %slog.0^leaf/"aqua: {(scow %p sndr)} -> {(scow %p rcvr)}"
.
%- emit-aqua-events
%+ turn ships
|= who=ship
[%event who hear]
[%event rcvr //newt/0v1n.2m9vh %hear hear-lane pac]~
:: +lane-to-ship: decode a ship from an aqua lane
::
++ 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
=/ vane
?+ v ~|([%unknown-vane v] !!)
%a %ames
%a %alef
%b %behn
%c %clay
%d %dill
@ -428,7 +428,7 @@
^- (list unix-event)
:~ [/ %wack 0] :: eny
[/ %whom who.ae] :: eny
[//newt/0v1n.2m9vh %barn ~]
[//newt/0v1n.2m9vh %born ~]
[//behn/0v1n.2m9vh %born ~]
:^ //term/1 %boot &
?~ keys.ae

View File

@ -306,7 +306,7 @@
=* walk-loop $
?: (gth number.state number.id.latest-block)
;< 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)
;< =block bind:m (get-block-by-number url.state number.state)
;< [=new=pending-udiffs new-blocks=(lest ^block)] bind:m

View File

@ -128,6 +128,109 @@
~& > %bud-done
(send-hi ~bud ~dev)
(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
~[~bud ~marbud ~linnup-torsyx ~linnup-torsyx-linnup-torsyx ~dev]
@ -193,18 +296,27 @@
%+ (wrap-philter ,_eth-node ,~)
router:eth-node
;< ~ bind:m (raw-real-ship:eth-node ~bud)
~& > 'BUD DONE'
;< ~ bind:m (raw-real-ship:eth-node ~dev)
~& > 'DEV DONE'
;< ~ bind:m (raw-real-ship:eth-node ~marbud)
~& > 'MARBUD DONE'
;< ~ bind:m (raw-real-ship:eth-node ~mardev)
~& > 'MARDEV DONE'
(send-hi ~marbud ~mardev)
~& > 'HI MARBUD MARDEV'
;< eth-node=_eth-node bind:m
(breach-and-hear:eth-node our.hid ~mardev ~marbud)
~& > 'BREACH MARDEV'
;< [eth-node=_eth-node ~] bind:m
%+ (wrap-philter ,_eth-node ,~)
router:eth-node
;< ~ bind:m (send-hi-not-responding ~marbud ~mardev)
~& > 'HI NOT RESPONDING'
;< ~ bind:m (raw-real-ship:eth-node ~mardev)
~& > 'MARDEV RE DONE'
(wait-for-dojo ~marbud "hi ~mardev successful")
~& > 'DONE'
(pure:m ~)
::
:+ %breach-sync
@ -298,9 +410,11 @@
;< [eth-node=_eth-node ~] bind:m
%+ (wrap-philter ,_eth-node ,~)
router:eth-node
;< ~ bind:m (raw-real-ship:eth-node ~bud)
;< ~ bind:m (raw-real-ship:eth-node ~bud)
~& > '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'
;< file=@t bind:m (touch-file ~bud %base)
~& > '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
::
[%$ /zuse]
:: sys/vane/ames: network
:: sys/vane/alef: network
::
[%a /vane/ames]
[%a /vane/alef]
:: sys/vane/behn: timer
::
[%b /vane/behn]
@ -49,7 +49,7 @@
:: sys/vane/iris: http client
::
[%i /vane/iris]
:: sys/vane/jael: security
:: sys/vane/kale: security
::
[%j /vane/jael]
==

View File

@ -349,8 +349,15 @@
|= [our=@p now=@da ship=@p =life]
^- @udpoint
::
=/ d=deed:ames
.^(deed:ames j+/(scot %p our)/deed/(scot %da now)/(scot %p ship)/(scot %ud life))
=/ d=[=^life =pass]
=/ 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
:: together; pull out the keys
::
@ -370,7 +377,7 @@
[participants keys]
::
=/ =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)
$(invited t.invited)
@ -429,11 +436,11 @@
:: get our ships' current 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
::
=/ 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
::
=/ secret-auth-seed=@

View File

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

View File

@ -14912,7 +14912,7 @@
^= gen ^- hoon
[%cnsg [%$ ~] [%$ 2] [%$ 3] ~]
=+ 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
|= {cog/@tas typ/type}
@ -17316,44 +17316,49 @@
~> %slog.[0 foo]
[| +>+<.$]
[& +>+<.$(nes (~(put in nes) [sut ref]))]
:: +play: +play:ut, cached
::
++ play :: play:ut
++ play
|= {sut/type gen/hoon}
^- {type worm}
=+ old=(~(get by pay) [sut gen])
?^ old [u.old +>+<.$]
=+ new=(~(play ut sut) gen)
[new +>+<.$(pay (~(put by pay) [sut gen] new))]
:: +mint: +mint:ut to noun, cached
::
++ mint :: mint:ut to noun
++ mint
|= {sut/type gen/hoon}
^- {(pair type nock) worm}
=+ old=(~(get by mit) [sut gen])
?^ old [u.old +>+<.$]
=+ new=(~(mint ut sut) %noun gen)
[new +>+<.$(mit (~(put by mit) [sut gen] new))]
:: +slam: +slam:ut, cached
::
++ slam :: ++slam, cached
++ slam
|= [gat=vase sam=vase]
^- [vase worm]
=/ sut=type [%cell p.gat p.sam]
=/ gen=hoon [%cnsg [%$ ~] [%$ 2] [%$ 3] ~]
=^ new=type +>+<.$ (play sut gen)
[[new (slum q.gat q.sam)] +>+<.$]
:: +slap: +slap:ut, cached
::
++ slap :: ++slap, cached
++ slap
|= {vax/vase gen/hoon}
^- {vase worm}
=^ gun +>+< (mint p.vax gen)
[[p.gun .*(q.vax q.gun)] +>+<.$]
:: +slot: +slot:ut, cached
::
++ slot :: ++slot, cached
++ slot
|= {axe/@ vax/vase}
^- {vase worm}
=^ gun +>+< (mint p.vax [%$ axe])
[[p.gun .*(q.vax [0 axe])] +>+<.$]
:: +slym: +slym:ut, cached
::
++ slym :: ++slym, cached
++ slym
|= {gat/vase sam/*}
^- [vase worm]
(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 !!
::
~& %behn-crud-tag^tag
%- (slog error)
(wake `error)
:: +rest: cancel the 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 $->
$~ [%b %wait *@da] ::
$% $: %a :: to %ames
$>(%want task:able:ames) ::
$>(%plea task:able:ames) ::
== ::
$: %b :: to %behn
$> $? %drip ::
@ -508,8 +508,9 @@
$% [%init-clad ~] ::
== == ::
$: %a :: by %ames
$> $? %send :: XX strange
%woot ::
$> $? %boon :: response
%done :: (n)ack
%lost :: lost boon
== ::
gift:able:ames ::
== ::
@ -2685,7 +2686,7 @@
%- (sloy-light ski)
=/ pur=spur
/(scot %p who)
[[151 %noun] %j our %rift da+now pur]
[[151 %noun] %k our %rift da+now pur]
::
:: Handle `%sing` requests
::
@ -2808,8 +2809,13 @@
:: Transfer a request to another ship's clay.
::
++ send-over-ames
|= {a/duct b/path c/ship d/{p/@ud q/riff}}
(emit a %pass b %a %want c [%c %question p.q.d (scot %ud p.d) ~] q.d)
|= [=duct =ship index=@ud =riff]
^+ +>
::
=/ =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.
::
@ -2833,7 +2839,7 @@
=+ inx=nix.u.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)
bom.u.ref (~(put by bom.u.ref) inx [hen rave])
@ -2931,12 +2937,21 @@
?: |(?=(%& -.w) (~(has by cez) p.w)) s
(~(put in s) p.w)
?^ 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)
|= {g/@ta t/tape}
?~ t (trip g)
:(weld t ", " (trip g))
=< (emit hen %give %mack ~)
:: TODO remove this nasty hack
::
=< ?. ?=([[%a *] *] hen)
.
(emit hen %give %done ~)
::
?- -.rit
$r wake(per (put-perm per pax red.rit))
$w wake(pew (put-perm pew pax wit.rit))
@ -2987,7 +3002,7 @@
=: fod.u.ref (~(del by fod.u.ref) hen)
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.
::
@ -4128,7 +4143,7 @@
=| mos/(list move)
=/ 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)
=^ mor ruf
=< abet:wake
@ -4339,25 +4354,19 @@
(start-request:den for u.q.rif)
[mos ..^$]
::
%west
=* wer p.req
=* pax q.req
=* res r.req
?: ?=({%question *} pax)
=+ ryf=;;(riff res)
:_ ..^$
:~ [hen %give %mack ~]
=/ =wire
[(scot %p our) (scot %p wer) t.pax]
[hen %pass wire %c %werp wer 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] ..^$]
%plea
=* her ship.req
=* pax path.plea.req
=* res payload.plea.req
::
?> ?=({%question *} pax)
=+ ryf=;;(riff res)
:_ ..^$
:~ [hen %give %done ~]
=/ =wire
[%foreign-warp (scot %p her) t.pax]
[hen %pass wire %c %werp her our ryf]
==
::
%wegh
:_ ..^$ :_ ~
@ -4438,6 +4447,11 @@
abet:(take-mount:den q.hin)
[mos ..^$]
::
?: ?=([%foreign-warp *] tea)
?> ?=(%writ +<.q.hin)
:_ ..^$
[hen %give %boon `(unit rand)`(bind `riot`p.q.hin rant-to-rand)]~
::
?: ?=([%foreign-request @ @ @ *] tea)
=/ her (slav %p i.t.tea)
=/ syd (slav %tas i.t.t.tea)
@ -4471,6 +4485,35 @@
`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)
?> ?=(%public-keys +<.q.hin)
?: ?=(%full -.public-keys-result.q.hin)
@ -4566,28 +4609,17 @@
::
(handle-task hen queued-task)
::
%writ
?> ?=({@ @ *} tea)
~| i=i.tea
~| it=i.t.tea
=+ him=(slav %p i.t.tea)
:_ ..^$
:~ :* hen %pass /writ-want %a
%want him [%c %answer t.t.tea]
(bind p.+.q.hin rant-to-rand)
==
==
:: handled in the wire dispatcher
::
%boon !!
%lost !!
%writ !!
::
%send
[[[hen %give +.q.hin] ~] ..^$]
::
%woot
?~ q.q.hin
%done
?~ error=error.q.hin
[~ ..^$]
~& [%clay-lost p.q.hin tea]
?~ u.q.q.hin
[~ ..^$]
%- (slog >p.u.u.q.q.hin< q.u.u.q.q.hin)
~& [%clay-lost u.error tea]
%- (slog >tag.u.error< tang.u.error)
[~ ..^$]
==
::
@ -4647,5 +4679,5 @@
%- (sloy-light ski)
=/ pur=spur
/(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 $<-
$~ [%j %init *@p] ::
$% $: %a ::
$% [%nice ~] :: XX obsolete
$> $? %mass ::
%send :: XX strange
== ::
gift:able:ames ::
$% $>(%mass gift:able:ames) ::
== == ::
$: %b ::
$% $>(%mass gift:able:behn) ::
$>(%writ gift:able:clay) :: XX %slip
== == ::
$: %c ::
$> $? %mack :: XX strange
%mass ::
$> $? %mass ::
%mere ::
%note ::
%writ ::
@ -400,30 +395,17 @@
==
==
::
++ pump :: send diff ack
%_ .
moz
:_(moz [hen %pass ~ %g %deal [our our] ram %pump ~])
==
::
++ take :: receive
|= sih/sign
^+ +>
?- sih
{?($a $b $c $e $f $g $i $j) $mass *}
(wegh -.sih p.sih)
::
{$a $nice *}
:: ~& [%take-nice-ames sih]
+>
::
[%j %init *]
:: pass thru to unix
::
+>(moz :_(moz [hen %give +.sih]))
::
{$a $send *}
+>(moz :_(moz [hen %give +.sih]))
::
{$g $onto *}
:: ~& [%take-gall-onto +>.sih]
@ -440,7 +422,7 @@
$reap ?~ p.p.+>.sih
+>.$
(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 !!
==
::
@ -454,10 +436,6 @@
?: ?=(%& -.p.sih)
mere
(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 *}
(done +.sih)

View File

@ -13,35 +13,34 @@
%out
%cay
==
:: +reverse-ames: reverse ames message
:: +ames-response: network response message (%boon)
::
++ reverse-ames
$% :: diff
::
[%d p=mark q=*]
:: etc.
::
:: %d: diff
:: %x: quit
::
++ ames-response
$% [%d =mark noun=*]
[%x ~]
==
:: +forward-ames: forward ames message
:: +ames-request: network request (%plea)
::
++ forward-ames
$% :: message
::
[%m =mark noun=*]
:: "peel" subscribe
::
:: %m: poke
:: %l: "peel" mark-translated subscribe
:: %s: subscribe
:: %u: unsubscribe
::
++ ames-request
$% [%m =mark noun=*]
[%l =mark =path]
:: subscribe
::
[%s =path]
:: cancel+unsubscribe
::
[%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
%peel
%poke
@ -94,9 +93,6 @@
:: outgoing subscribers
::
outgoing=boat
:: queue meter
::
meter=(map bone @ud)
==
:: +agents: ship state
::
@ -106,7 +102,7 @@
system-duct=duct
:: foreign contacts
::
contacts=(map ship foreign)
contacts=(set ship)
:: running agents
::
running=(map term agent)
@ -124,22 +120,6 @@
::
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
@ -268,7 +248,7 @@
^+ mo-core
::
=/ =case [%da now]
=/ =path
=/ =wire
=/ ship (scot %p ship)
=/ case (scot case)
/sys/core/[term]/[ship]/[desk]/[case]
@ -277,13 +257,11 @@
=/ =schematic:ford [%core [ship desk] /hoon/[term]/app]
[%f %build live=%.y schematic]
::
=/ pass [path note-arvo]
(mo-pass pass)
::
(mo-pass wire note-arvo)
:: +mo-pass: prepend a standard %pass to the current list of moves.
::
++ mo-pass
|= pass=(pair path note-arvo)
|= pass=(pair wire note-arvo)
^+ mo-core
::
=/ =move [hen [%pass pass]]
@ -394,33 +372,21 @@
%_ mo-core
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-handle-foreign-request
~/ %mo-handle-foreign-request
++ mo-send-foreign-request
~/ %mo-send-foreign-request
|= [=ship =internal-task]
^+ mo-core
::
=/ =term p.internal-task
=/ foreign-agent p.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)
=/ =tang p.agent-action
(mo-give %unto %reap (some tang))
(mo-give %unto %reap `p.agent-action)
::
=^ bone mo-core (mo-assign-bone ship)
=/ =forward-ames
=. mo-core (mo-track-rift ship)
=/ =ames-request
?- -.agent-action
%poke [%m p.p.agent-action q.q.p.agent-action]
%pull [%u ~]
@ -435,96 +401,38 @@
/sys/way/[action]
::
=/ =note-arvo
=/ =path /g/ge/[term]
=/ =noun [bone forward-ames]
[%a %want ship path noun]
=/ =path /ge/[term]
[%a %plea ship %g path ames-request]
::
(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-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
++ mo-track-rift
|= =ship
^- [bone _mo-core]
^+ mo-core
:: if already contacted, no-op
::
=? mo-core !(~(has by 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)
?: (~(has in contacts.agents.state) ship)
mo-core
:: first contact; update state and subscribe to jael
::
=/ =foreign (~(got by contacts.agents.state) ship)
=/ existing (~(get by index-map.foreign) hen)
?^ existing
[u.existing mo-core]
::
=/ index index.foreign
=/ 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.
=. contacts.agents.state (~(put in contacts.agents.state) ship)
=/ =note-arvo [%j %public-keys (silt ship ~)]
=. moves
[[system-duct.agents.state %pass /sys/jael note-arvo] moves]
mo-core
:: +mo-untrack-rift: cancel jael subscription to .ship's breaches
::
++ mo-retrieve-duct
|= [=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
++ mo-untrack-rift
|= =ship
^+ 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 ~)]
=. moves
[[system-duct.agents.state %pass /sys/jael note-arvo] moves]
@ -534,6 +442,7 @@
++ mo-breach
|= =ship
^+ mo-core
=. mo-core (mo-untrack-rift ship)
=/ agents=(list [name=term =agent]) ~(tap by running.agents.state)
|- ^+ mo-core
?~ agents
@ -542,8 +451,6 @@
=/ =routes [disclosing=~ attributing=ship]
=/ app (ap-abed:ap name.i.agents routes)
ap-abet:(ap-breach:app ship)
=. mo-core (mo-cancel-jael ship)
=. contacts.agents.state (~(del by contacts.agents.state) ship)
$(agents t.agents)
:: +mo-handle-sys: handle a +sign incoming over /sys.
::
@ -569,46 +476,19 @@
++ mo-handle-sys-jael
|= [=path =sign-arvo]
^+ mo-core
?> ?=([%j %public-keys *] sign-arvo)
?> ?=([%jael ~] path)
?: ?=(%full -.public-keys-result.sign-arvo)
=/ ships=(list [=ship =point:able:jael])
~(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)
?> ?=([%j %public-keys *] sign-arvo)
?. ?=(%breach -.public-keys-result.sign-arvo)
mo-core
=/ =ship 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-breach who.public-keys-result.sign-arvo)
:: +mo-handle-sys-core: receive a core from %ford.
::
++ mo-handle-sys-core
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([%f %made *] sign-arvo)
?> ?=([@ @ @ @ @ ~] path)
?> ?=([%f %made *] sign-arvo)
=/ beak-path t.t.path
=/ =beak
=/ =ship (slav %p i.beak-path)
@ -624,75 +504,19 @@
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([%pel @ ~] path)
?> ?=([%f %made *] sign-arvo)
?> ?=([@ @ ~] path)
::
?: ?=([%incomplete *] result.sign-arvo)
=/ err (some tang.result.sign-arvo)
(mo-give %unto %coup err)
?- result.sign-arvo
[%incomplete *]
(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)
=/ err (some message.build-result)
(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)
[%complete %success *]
(mo-give %unto %diff (result-to-cage:ford build-result.result.sign-arvo))
==
:: +mo-handle-sys-rep: reverse request.
::
:: On receipt of a valid +sign from %ford, sets state to the appropriate
@ -702,86 +526,54 @@
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([@ @ @ @ ~] path)
?> ?=([%rep @ @ *] path)
?> ?=([%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)
=/ err (some tang.result.sign-arvo)
(mo-give %mack err)
?- result.sign-arvo
[%incomplete *]
(mo-give %done `[%gall-fail tang.result.sign-arvo])
::
=/ build-result build-result.result.sign-arvo
?: ?=([%error *] build-result)
:: XX should crash
=/ err (some message.build-result)
(mo-give %mack err)
:: XX pump should ack
=. mo-core (mo-give %mack ~)
=/ duct (mo-retrieve-duct him num)
?~ duct
%- (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.
[%complete %error *]
(mo-give %done `[%gall-fail message.build-result.result.sign-arvo])
::
[%complete %success *]
(mo-give %unto %diff (result-to-cage:ford build-result.result.sign-arvo))
==
:: +mo-handle-sys-req: TODO description
::
:: TODO: what should we do if the remote nacks our %pull?
::
++ mo-handle-sys-req
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([@ @ @ @ ~] path)
?> ?=([%req @ @ @ ~] path)
=/ him (slav %p i.t.path)
=/ dap i.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)
=/ =internal-gift +>.sign-arvo
::
?- -.internal-gift
%coup
(mo-give %mack p.internal-gift)
=/ err=(unit error:ames)
?~ p.internal-gift ~
`[%coup u.p.internal-gift]
(mo-give %done err)
::
%diff
=/ sys-path [%sys %red t.path]
=/ =note-arvo
=/ 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)
=+ [mark noun]=[p q.q]:p.internal-gift
(mo-give %boon num %d mark noun)
::
%quit
=/ sys-path [%sys path]
=/ =note-arvo
=/ path [%g %gh dap ~]
=/ noun [num %x ~]
[%a %want him path noun]
(mo-pass sys-path note-arvo)
(mo-give %boon num %x ~)
::
%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
!!
@ -796,7 +588,7 @@
^+ mo-core
::
?> ?=([%f %made *] sign-arvo)
?> ?=([@ @ @ ~] path)
?> ?=([%val @ @ ~] path)
=/ =ship (slav %p i.t.path)
=/ =term i.t.t.path
?: ?=([%incomplete *] result.sign-arvo)
@ -812,17 +604,43 @@
=/ =cage (result-to-cage:ford build-result)
=/ =agent-action [%poke cage]
(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
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([%a %woot *] sign-arvo)
?> ?=([@ @ ~] path)
=/ =foreign-response (foreign-response i.t.path)
=/ maybe-ares +>+.sign-arvo
(mo-handle-foreign-response foreign-response maybe-ares)
?> ?=([%way @ @ @ *] path)
=/ him (slav %p i.t.path)
=/ agent-name `@tas`i.t.t.path
=/ =remote-request ;;(remote-request i.t.t.t.path)
::
?+ 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.
::
:: (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
|= [=term =routes =agent-action]
|= [agent=term =routes =agent-action]
^+ mo-core
::
=/ =path
=/ ship (scot %p attributing.routes)
/sys/val/[ship]/[term]
/sys/val/[ship]/[agent]
::
=/ ship-desk
=/ =beak (mo-beak term)
=/ =beak (mo-beak agent)
[p q]:beak
::
?: ?=(%puff -.agent-action)
@ -947,7 +765,7 @@
=/ err (some p.agent-action)
(mo-give %unto %reap err)
::
=/ app (ap-abed:ap term routes)
=/ app (ap-abed:ap agent routes)
=. app (ap-apply:app agent-action)
ap-abet:app
:: +mo-handle-local: handle locally.
@ -960,97 +778,65 @@
^+ mo-core
::
=/ =routes [disclosing=~ attributing=ship]
=/ =term p.internal-task
=/ agent p.internal-task
=/ =agent-action q.internal-task
=/ is-running (~(has by running.agents.state) term)
=/ is-blocked (~(has by blocked.agents.state) term)
=/ is-running (~(has by running.agents.state) agent)
=/ is-blocked (~(has by blocked.agents.state) agent)
::
?: |(!is-running is-blocked)
=/ =blocked
=/ waiting (~(get by blocked.agents.state) term)
=/ waiting (~(get by blocked.agents.state) agent)
=/ tasks (fall waiting *blocked)
=/ task [hen routes agent-action]
(~(put to tasks) task)
::
%_ 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-handle-forward: handle forward %ames message.
(mo-apply agent routes agent-action)
:: +mo-handle-ames-request: handle ames request message
::
++ mo-handle-forward
|= [=ship =term =bone =forward-ames]
++ mo-handle-ames-request
|= [=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
?. ?=(%u -.forward-ames)
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
?- -.ames-response
:: %d: diff; ask ford to validate .noun as .mark
::
%d
=/ =path
=/ him (scot %p ship)
=/ num (scot %ud bone)
/sys/rep/[him]/[term]/[num]
=/ =wire
=- (weld - subscription-path)
/sys/rep/(scot %p ship)/[agent-name]
::
=/ =note-arvo
=/ beak (mo-beak term)
=/ info [p q]:beak
=/ =schematic:ford [%vale info p.reverse-ames q.reverse-ames]
[%f %build live=%.n schematic]
=/ =disc:ford [p q]:(mo-beak term)
[%f %build live=%.n %vale disc [mark noun]:ames-response]
::
(mo-pass path note-arvo)
(mo-pass wire note-arvo)
::
:: %x: quit; tell agent the publisher canceled the subscription
::
%x
:: XX should crash
=. 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 ~)
(mo-give %unto %quit ~)
==
:: +ap: agent engine
::
@ -1127,16 +913,10 @@
=/ bones *(set bone)
|- ^+ ap-core
?^ internal-moves
=/ =internal-move i.internal-moves
?. ?=([%give %diff *] move.internal-move)
$(internal-moves t.internal-moves)
=? bones ?=([%give %diff *] move.i.internal-moves)
(~(put in bones) bone.i.internal-moves)
::
=^ filled ap-core ap-enqueue(agent-bone bone.internal-move)
=/ new-bones
?: filled
bones
(~(put in bones) bone.internal-move)
$(internal-moves t.internal-moves, bones new-bones)
$(internal-moves t.internal-moves)
::
=/ bones ~(tap in bones)
::
@ -1229,7 +1009,7 @@
core(agent-bone agent-bone)
$(in t.in)
::
=/ out=(list [[=bone =wire] =bean =^ship =path])
=/ out=(list [[=bone =wire] ? =^ship =path])
~(tap by outgoing.subscribers.current-agent)
|- ^+ ap-core
?~ out
@ -1347,7 +1127,6 @@
%punk !!
%peer-not !!
%pull ap-load-delete
%pump ap-dequeue
==
:: +ap-diff: pour a diff.
::
@ -1399,36 +1178,15 @@
|= [is-ok=? =ship =path]
^+ ap-core
::
=/ way [(scot %p ship) %out path]
::
?: is-ok
=/ =internal-note [%send ship -.path %pump ~]
(ap-pass way internal-note)
ap-core
:: not ok; kill in both directions with %quit and %pull
::
=. ap-core (ap-give %quit ~)
::
=/ way [(scot %p ship) %out path]
=/ =internal-note [%send ship -.path %pull ~]
(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
@ -1463,39 +1221,6 @@
ap-core(cache.current-agent worm)
::
[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
@ -2189,15 +1914,9 @@
++ ap-silent-delete
^+ ap-core
::
?~ (~(get 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
==
=. incoming.subcribers.current-agent
(~(del by incoming.subscribers.current-agent) agent-bone)
ap-core
:: +ap-load-delete: load delete.
::
++ ap-load-delete
@ -2211,8 +1930,6 @@
=/ incoming u.maybe-incoming
=. incoming.subscribers.current-agent
(~(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
@ -2422,7 +2139,7 @@
%rest `%b
%rekey `%j
%wait `%b
%want `%a
%plea `%a
%warp `%c
%wash `%g
%wipe `%f
@ -2467,7 +2184,7 @@
=/ =internal-task q.task
?. =(q.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-handle-local:initialised p.sock internal-task)
@ -2489,21 +2206,17 @@
%vega
[~ gall-payload]
::
%west
=/ =ship p.task
=/ =path q.task
=/ =noun r.task
%plea
=/ =ship ship.task
=/ =path path.task
=/ =noun payload.task
::
?> ?=([?(%ge %gh) @ ~] path)
~| [ship=ship plea-path=path]
?> ?=([%ge @ ~] path)
=/ agent-name i.t.path
::
?: ?=(%ge i.path)
=/ mes ;;((pair @ud forward-ames) noun)
=> (mo-handle-forward:initialised ship agent-name mes)
mo-abet
::
=/ mes ;;((pair @ud reverse-ames) noun)
=> (mo-handle-backward:initialised ship agent-name mes)
=/ =ames-request ;;(ames-request noun)
=> (mo-handle-ames-request ship agent-name ames-request)
mo-abet
::
%wash
@ -2528,11 +2241,7 @@
[%dot %.y state]
==
::
=/ moves
=/ =move [duct %give %mass mass]
[move ~]
::
[moves gall-payload]
[[duct %give %mass mass]~ gall-payload]
==
:: +load: recreate vane
::
@ -2588,6 +2297,7 @@
^- [(list move) _gall-payload]
::
~| [%gall-take-failed wire]
::
?> ?=([?(%sys %use) *] wire)
=/ initialised (mo-abed:mo duct)
=/ =sign-arvo q.hin

View File

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

View File

@ -1,3 +1,4 @@
!:
:: :: /van/zuse
:: :: %reference/1
:: %zuse: arvo library.
@ -194,6 +195,7 @@
:: +vane-task: general tasks shared across vanes
::
+$ vane-task
$~ [%born ~]
$% :: i/o device replaced (reset state)
::
[%born ~]
@ -214,7 +216,9 @@
[%wegh ~]
:: receive message via %ames
::
[%west p=ship q=path r=*]
:: TODO: move .vane from $plea to here
::
[%plea =ship =plea:ames]
==
:: ::::
:::: ++http ::
@ -374,32 +378,56 @@
:: ::::
++ able ^?
|%
++ gift :: out result <-$
$% {$mack p/(unit tang)} :: acknowledgement
{$mass p/mass} :: memory usage
{$send p/lane q/@} :: transmit packet
{$turf p/(list turf)} :: bind to domains
$>(%west vane-task) :: for the outside
{$woot p/ship q/coop} :: reaction message
== ::
++ task :: in request ->$
$~ [%vega ~] ::
$% {$barn ~} :: new unix process
{$bonk ~} :: reset the timer
$>(%crud vane-task) :: error with trace
{$hear p/lane q/@} :: receive packet
{$halo p/lane q/@ r/ares} :: hole with trace
{$hole p/lane q/@} :: packet failed
$>(%init vane-task) :: report install
{$kick p/@da} :: wake up
{$nuke p/@p} :: toggle auto-block
$>(%trim vane-task) :: trim state
$>(%vega vane-task) :: report upgrade
{$wake ~} :: timer activate
$>(%wegh vane-task) :: report memory
$>(%west vane-task) :: network request
{$want p/ship q/path r/*} :: forward message
== ::
:: $task: job for ames
::
:: Messaging Tasks
::
:: %hear: packet from unix
:: %hole: report that packet handling crashed
:: %plea: request to send message
::
:: System and Lifecycle Tasks
::
:: %born: process restart notification
:: %crud: crash report
:: %init: vane boot
:: %vega: kernel reload notification
:: %wegh: request for memory usage report
::
+$ task
$% [%hear =lane =blob]
[%hole =lane =blob]
$>(%plea vane-task)
::
$>(%born vane-task)
$>(%crud vane-task)
$>(%init vane-task)
$>(%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
::
:::: :: (1a2)
@ -427,131 +455,28 @@
++ com |~(a/pass ^?(..nu)) :: from pass
-- ::nu ::
-- ::acru ::
++ bait {p/skin q/@ud r/dove} :: fmt nrecvd spec
++ bath :: convo per client
$: sop/shed :: not stalled
raz/(map path race) :: statements inbound
ryl/(map path rill) :: statements outbound
== ::
++ boon :: fort output
$% [%beer p=ship] :: request public keys
[%bock ~] :: bind to domains
[%brew ~] :: request domains
[%cake p=ship q=soap r=coop s=duct] :: e2e message result
[%mead p=lane q=rock] :: accept packet
[%milk p=ship q=soap r=*] :: e2e pass message
[%ouzo p=lane q=rock] :: transmit packet
[%pito p=@da] :: timeout
[%raki p=ship q=life r=pass] :: neighbor'd
[%sake ~] :: our private keys
[%wine p=ship q=tape] :: notify user
== ::
++ cake {p/sock q/skin r/@} :: top level packet
++ cape :: end-to-end result
$? $good :: delivered
$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
:: $address: opaque atomic transport address to or from unix
::
+$ address @uxaddress
:: $blob: raw atom to or from unix, representing a packet
::
+$ blob @uxblob
:: $error: tagged diagnostic trace
::
+$ error [tag=@tas =tang]
:: $lane: ship transport address; either opaque $address or galaxy
::
:: The runtime knows how to look up galaxies, so we don't need to
:: know their transport addresses.
::
+$ lane (each @pC address)
:: $plea: application-level message, as a %pass
::
:: vane: destination vane on remote ship
:: path: internal route on the receiving ship
:: payload: semantic message contents
::
+$ plea [vane=@tas =path payload=*]
-- ::ames
:: ::::
:::: ++behn :: (1b) timekeeping
@ -594,18 +519,18 @@
++ able ^?
|%
++ 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
{$dirk p/@tas} :: mark mount dirty
{$ergo p/@tas q/mode} :: version update
{$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
{$mere p/(each (set path) (pair term tang))} :: merge result
{$note p/@tD q/tank} :: debug message
{$ogre p/@tas} :: delete mount point
{$rule red/dict wit/dict} :: node r+w permissions
{$send p/lane:ames q/@} :: transmit packet
{$writ p/riot} :: response
{$wris p/{$da p/@da} q/(set (pair care path))} :: many changes
== ::
@ -634,7 +559,7 @@
{$warp wer/ship rif/riff} :: internal file req
{$werp who/ship wer/ship rif/riff} :: external file req
$>(%wegh vane-task) :: report memory
$>(%west vane-task) :: network request
$>(%plea vane-task) :: ames request
== ::
-- ::able
::
@ -777,7 +702,6 @@
{$logo ~} :: logout
{$lyra p/@t q/@t} :: upgrade kernel
{$mass p/mass} :: memory usage
{$send p/lane:ames q/@} :: transmit packet
{$veer p/@ta q/path r/@t} :: install vane
{$verb ~} :: verbose mode
== ::
@ -1873,20 +1797,20 @@
++ able ^?
|%
++ 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
{$rend p/path q/*} :: network request
{$unto p/internal-gift} ::
{$mack p/(unit tang)} :: message ack
== ::
++ task :: incoming request
$~ [%vega ~] ::
$% {$conf p/dock q/dock} :: configure app
$>(%init vane-task) :: set owner
{$deal p/sock q/internal-task} :: full transmission
$>(%init vane-task) :: set owner
$>(%trim vane-task) :: trim state
$>(%vega vane-task) :: report upgrade
$>(%west vane-task) :: network request
$>(%plea vane-task) :: network request
[%wash ~] :: clear caches
$>(%wegh vane-task) :: report memory
== ::
@ -1894,7 +1818,7 @@
++ bitt (map bone (pair ship path)) :: incoming subs
++ boat :: outgoing subs
%+ map (pair bone wire) ::
(trel bean ship path) ::
(trel ? ship path) ::
++ bowl :: standard app state
$: $: our/ship :: host
src/ship :: guest
@ -1914,9 +1838,8 @@
{$peer p/path} :: subscribe
{$poke p/cage} :: apply
{$puff p/mark q/noun} :: unchecked poke
{$pull ~} :: unsubscribe
{$pull p/path} :: unsubscribe
{$punk p/mark q/cage} :: translated poke
{$pump ~} :: pump yes+no
{$peer-not p/tang} :: poison pill peer
== ::
++ internal-gift ::
@ -2072,7 +1995,8 @@
++ gift :: out result <-$
$% [%init p=ship] :: report install unix
[%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
[%private-keys =life vein=(map life ring)] :: private keys
[%public-keys =public-keys-result] :: ethereum changes
@ -2097,7 +2021,7 @@
[%turf ~] :: view domains
$>(%vega vane-task) :: report upgrade
$>(%wegh vane-task) :: memory usage request
$>(%west vane-task) :: remote request
$>(%plea vane-task) :: ames request
== ::
::
+$ dawn-event
@ -2272,57 +2196,7 @@
++ oath @ :: signature
-- :: pki
-- :: 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
:: :: ::
@ -6873,7 +6747,7 @@
++ saxo :: autocanon
|= [our=ship now=@da who=ship]
.^ (list ship)
%j
%k
/(scot %p our)/saxo/(scot %da now)/(scot %p who)
==
:: :: ++sein:title
@ -7448,6 +7322,15 @@
|=({pax/path hid/bowl} (pale hid (prix pax)))
-- ::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
++ gift-arvo :: out result <-$
@ -7467,14 +7350,14 @@
task:able:clay
task:able:behn
task:able:dill
task:able:iris
task:able:eyre
task:able:ford
task:able:gall
task:able:eyre
task:able:iris
task:able:jael
==
++ note-arvo :: out request $->
$~ [%a %wake ~]
$~ [%b %wake ~]
$% {$a task:able:ames}
{$b task:able:behn}
{$c task:able:clay}
@ -7501,13 +7384,11 @@
[%i gift:able:iris]
{$j gift:able:jael}
==
:: $unix-task: input from unix
::
+$ unix-task :: input from unix
+$ unix-task
$~ [%wake ~]
$% :: %ames: new process
::
$>(%barn task:able:ames)
:: %dill: keyboard input
$% :: %dill: keyboard input
::
$>(%belt task:able:dill)
:: %dill: configure terminal (resized)
@ -7552,9 +7433,6 @@
:: %behn: wakeup
::
$>(%wake task:able:behn)
:: %ames: send message
::
$>(%want task:able:ames)
==
:: ::
:::: ++azimuth :: (2az) azimuth
@ -7640,7 +7518,7 @@
:: # constants
::
:: contract addresses
++ contracts mainnet-contracts
++ contracts ropsten-contracts
++ mainnet-contracts
|%
:: azimuth: data contract

View File

@ -5,56 +5,64 @@
::
=/ vane (alef !>(..zuse))
::
=/ alice vane
=/ bob vane
=/ nec vane
=/ bud vane
::
=. our.alice ~nec
=. now.alice ~1111.1.1
=. eny.alice 0xdead.beef
=. our.nec ~nec
=. now.nec ~1111.1.1
=. eny.nec 0xdead.beef
=. scry-gate.nec |=(* ``[%noun !>(*(list turf))])
::
=. our.bob ~doznec-doznec
=. now.bob ~1111.1.1
=. eny.bob 0xbeef.dead
=. our.bud ~bud
=. now.bud ~1111.1.1
=. 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.bob (pit:nu:crub:crypto 512 (shaz 'bob'))
=. crypto-core.ames-state.nec (pit:nu:crub:crypto 512 (shaz 'nec'))
=. crypto-core.ames-state.bud (pit:nu:crub:crypto 512 (shaz 'bud'))
::
=/ alice-pub pub:ex:crypto-core.ames-state.alice
=/ alice-sec sec:ex:crypto-core.ames-state.alice
=/ bob-pub pub:ex:crypto-core.ames-state.bob
=/ bob-sec sec:ex:crypto-core.ames-state.bob
=/ nec-pub pub:ex:crypto-core.ames-state.nec
=/ nec-sec sec:ex:crypto-core.ames-state.nec
=/ bud-pub pub:ex:crypto-core.ames-state.bud
=/ bud-sec sec:ex:crypto-core.ames-state.bud
::
=/ alice-sym (derive-symmetric-key:alef bob-pub alice-sec)
=/ bob-sym (derive-symmetric-key:alef alice-pub bob-sec)
=/ nec-sym (derive-symmetric-key:vane bud-pub nec-sec)
=/ bud-sym (derive-symmetric-key:vane nec-pub bud-sec)
::
?> =(alice-sym bob-sym)
?> =(nec-sym bud-sym)
::
=. life.ames-state.alice 2
=. peers.ames-state.alice
%+ ~(put by peers.ames-state.alice) ~doznec-doznec
=. life.ames-state.nec 2
=. peers.ames-state.nec
%+ ~(put by peers.ames-state.nec) ~bud
=| =peer-state:alef
=. -.peer-state
:* symmetric-key=bob-sym
:* symmetric-key=bud-sym
life=3
public-key=bob-pub
sponsor=~marzod
public-key=bud-pub
sponsor=~nec
==
=. route.peer-state `[direct=%.y `lane:alef`[%& ~nec]]
[%known peer-state]
::
=. life.ames-state.bob 3
=. peers.ames-state.bob
%+ ~(put by peers.ames-state.bob) ~nec
=. life.ames-state.bud 3
=. peers.ames-state.bud
%+ ~(put by peers.ames-state.bud) ~nec
=| =peer-state:alef
=. -.peer-state
:* symmetric-key=alice-sym
:* symmetric-key=nec-sym
life=2
public-key=alice-pub
public-key=nec-pub
sponsor=~nec
==
=. route.peer-state `[direct=%.y `lane:alef`[%| `@`%lane-bar]]
[%known peer-state]
:: metamorphose
::
=> .(nec +:(call:(nec) ~[//unix] ** %born ~))
=> .(bud +:(call:(bud) ~[//unix] ** %born ~))
:: helper core
::
=>
|%
++ move-to-packet
|= =move:alef
@ -75,19 +83,37 @@
%- move-to-packet
%+ snag index
(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
::
=/ =packet:alef
:* [sndr=~nec rcvr=~doznec-doznec]
:* [sndr=~nec rcvr=~bud]
encrypted=%.n
origin=~
content=[12 13]
==
::
=/ encoded (encode-packet:alef packet)
=/ decoded (decode-packet:alef encoded)
=/ encoded (encode-packet:vane packet)
=/ decoded (decode-packet:vane encoded)
::
%+ expect-eq
!> packet
@ -97,104 +123,108 @@
::
=/ lane-foo=lane:alef [%| `@ux``@`%lane-foo]
::
=/ =message:alef [/g/talk [%first %post]]
=/ =plea:ames [%g /talk [%first %post]]
::
=/ =shut-packet:alef
:* sndr-life=4
rcvr-life=3
bone=1
message-num=1
[%& num-fragments=1 fragment-num=0 (jam message)]
[%& num-fragments=1 fragment-num=0 (jam plea)]
==
::
=/ =packet:alef
:* [sndr=~bus rcvr=~doznec-doznec]
:* [sndr=~bus rcvr=~bud]
encrypted=%.y
origin=~
content=(encrypt:alef alice-sym shut-packet)
content=(encrypt:vane nec-sym shut-packet)
==
::
=/ =blob:alef (encode-packet:alef packet)
=^ moves1 bob (call bob ~[//unix] %hear lane-foo blob)
=^ moves2 bob
=/ =blob:alef (encode-packet:vane packet)
=^ moves1 bud (call bud ~[//unix] %hear lane-foo blob)
=^ moves2 bud
=/ =point:alef
:* rift=1
life=4
crypto-suite=1
encryption-key=`@`alice-pub
authentication-key=`@`0
keys=[[life=4 [crypto-suite=1 `@`nec-pub]] ~ ~]
sponsor=`~bus
==
%- take
:^ bob /alien ~[//unix]
:^ bud /public-keys ~[//unix]
^- sign:alef
[%j %public-keys %full [n=[~bus point] ~ ~]]
[%k %public-keys %full [n=[~bus point] ~ ~]]
::
;: weld
%+ expect-eq
!> [~[//unix] %pass /alien %j %public-keys ~bus]~
!> [~[//unix] %pass /public-keys %k %public-keys [~bus ~ ~]]~
!> moves1
::
%+ expect-eq
!> [~[//unix] %pass /bone/~bus/1 %g %memo ~bus /g/talk [%first %post]]~
!> moves2
!> %- sy
:~ :^ ~[//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
:: ~nec -> %plea -> ~bud
::
=^ moves1 alice
(call alice ~[/alice] %memo ~doznec-doznec /g/talk [%get %post])
=^ moves1 nec (call nec ~[/g/talk] %plea ~bud %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 bob (take bob /bone/~nec/1 ~[/bob] %g %done ~)
=^ moves4 alice (call alice ~[/alice] %hear (snag-packet 0 moves3))
=^ moves5 bob
(take bob /bone/~nec/1 ~[/bob] %g %memo /g/talk [%post 'first1!!'])
=^ moves3 bud (take bud /bone/~nec/1 ~[//unix] %g %done ~)
=^ moves4 nec (call nec ~[//unix] %hear (snag-packet 0 moves3))
:: ~bud -> %boon -> ~nec
::
=^ moves6 alice (call alice ~[/alice] %hear (snag-packet 0 moves5))
=^ moves7 bob (call bob ~[/bob] %hear (snag-packet 0 moves6))
=^ moves5 bud (take bud /bone/~nec/1 ~[//unix] %g %boon [%post 'first1!!'])
=^ 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
%+ expect-eq
!> :~ :+ ~[/alice] %give [%done error=~]
:+ ~[/alice] %pass
[/pump/~doznec-doznec/0 %b %rest ~1111.1.1..00.00.06]
!> :~ [~[//unix] %pass /qos %d %flog %text "; ~nec is your neighbor"]
[~[//unix] %pass /bone/~nec/1 %g %plea ~nec %g /talk [%get %post]]
==
!> moves4
!> moves2
::
%+ 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)
==
::
++ test-nack ^- tang
=^ moves1 alice
(call alice ~[/alice] %memo ~doznec-doznec /g/talk [%get %post])
:: ~nec -> %plea -> ~bud
::
=^ moves2 bob (call bob ~[/bob] %hear (snag-packet 0 moves1))
=/ =error:alef [%flub [%leaf "sinusoidal repleneration"]~]
=^ moves3 bob (take bob /bone/~nec/1 ~[/bob] %g %done `error)
=^ moves4 alice (call alice ~[/alice] %hear (snag-packet 0 moves3))
=^ moves5 alice (call alice ~[/alice] %hear (snag-packet 1 moves3))
=^ moves6 bob (call bob ~[/bob] %hear (snag-packet 0 moves5))
=^ moves1 nec (call nec ~[/g/talk] %plea ~bud %g /talk [%get %post])
=^ moves2 bud (call bud ~[//unix] %hear (snag-packet 0 moves1))
:: ~bud -> nack -> ~nec
::
=/ =error:alef [%flub [%leaf "sinusoidal repleneration"]~]
=^ 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
!> [~[/alice] %give %done `error]
!> [~[/g/talk] %give %done `error]
!> (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_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/urbit ./build/urbit-worker
@ -31,7 +31,8 @@ CFLAGS := $(CFLAGS)
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/jam_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
@echo CC -o $@
@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)
} 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.
*/
typedef void (*u3_poke)(void*, u3_noun);
@ -330,7 +337,6 @@
uv_udp_t wax_u;
uv_handle_t had_u;
};
uv_timer_t tim_u; // XX temporary timer
c3_o liv; // listener on
c3_o alm; // alarm on
c3_s por_s; // public IPv4 port
@ -979,6 +985,15 @@
void
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.
**/

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);
uv_buf_t buf_u = uv_buf_init((c3_c*)pac_u->hun_y, pac_u->len_w);
c3_i sas_i;
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);
}
/* 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.
*/
@ -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.
*/
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_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).
@ -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));
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) ) {
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);
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 ) {
pac_u->pip_w = 0x7f000001;
pac_u->por_s = pir_u->por_s;
}
// galaxy lane; do DNS lookup and send packet
//
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 = (pac_u->pip_w & 0xff);
_ames_czar(pac_u, sam_u->dns_c);
}
else if ( (c3y == u3_Host.ops_u.net) || (0x7f000001 == pac_u->pip_w) ) {
_ames_send(pac_u);
}
else {
// networking disabled
pac_u->imp_y = val;
_ames_czar(pac_u, sam_u->dns_c);
}
// non-galaxy lane
//
else {
u3_lane lan_u = u3_ames_decode_lane(u3k(val));
// convert incoming localhost to outgoing localhost
//
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);
}
}
else {
_ames_pact_free(pac_u);
}
// otherwise, mutate destination and send packet
//
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);
}
@ -374,30 +382,21 @@ _ames_recv_cb(uv_udp_t* wax_u,
#if 0
u3z(msg);
#else
u3_lane lan_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
(u3nt(u3_blip, c3__ames, u3_nul),
u3nt(c3__hear,
u3nq(c3__if, u3k(u3A->now), por_s, u3i_words(1, &pip_w)),
msg));
lan_u.por_s = ntohs(add_u->sin_port);
lan_u.pip_w = ntohl(add_u->sin_addr.s_addr);
u3_noun lan = u3_ames_encode_lane(lan_u);
u3_noun mov = u3nt(c3__hear, u3nc(c3n, lan), msg);
u3_pier_plan(u3nt(u3_blip, c3__ames, u3_nul), mov);
#endif
}
_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.
*/
static void
@ -467,8 +466,6 @@ _ames_io_start(u3_pier* pir_u)
sam_u->liv = c3y;
u3z(rac);
u3z(who);
uv_timer_start(&sam_u->tim_u, _ames_timer_cb, 300 * 1000, 300 * 1000);
}
/* _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;
sam_u->liv = c3n;
uv_timer_init(u3L, &sam_u->tim_u);
}
/* u3_ames_io_talk(): start receiving ames traffic.
@ -570,6 +565,7 @@ u3_ames_io_init(u3_pier* pir_u)
void
u3_ames_io_talk(u3_pier* pir_u)
{
_ames_io_start(pir_u);
}
/* 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
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_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.
*/
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.
//
if ( (c3__hear == tag) && (c3__exit == why) ) {
_worker_send_tang(1, u3k(tan));
rep = u3nt(u3k(wir), c3__hole, u3k(cad));
}
// 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 ) {
u3_noun lef = u3nc(c3__leaf, u3i_tape("crude crashed!"));
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),
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: "),
u3qc_rip(3, why)));
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));
}