This commit is contained in:
Philip Monk 2019-02-01 13:46:09 -08:00
parent fe02c76537
commit 075700583f
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
5 changed files with 193 additions and 67 deletions

View File

@ -34,7 +34,7 @@
%look
:_ ~
=/ pul
(need (de-purl:html 'http://eth-mainnet.urbit.org:8545'))
(need (de-purl:html 'http://localhost:8545'))
[ost.hid %look /hi |+pul]
==
::

View File

@ -416,6 +416,13 @@
::
++ mere
|= mes=(each (set path) (pair term tang))
?: ?=([%| %ali-sunk *] mes)
=. +>.$
%^ spam
leaf+"merge cancelled because sunk, restarting"
(render "on sync" sud her syd)
~
start-sync:stop
=. let +(let)
=. +>.$
%- spam

View File

@ -1,5 +1,5 @@
:: clay (4c), revision control
::
!:
:: This is split in three top-level sections: structure definitions, main
:: logic, and arvo interface.
::
@ -298,7 +298,10 @@
::
:: Foreign desk data.
::
+= rung rus/(map desk rede) :: neighbor desks
++ rung
$: rit=rift :: lyfe of 1st contact
rus=(map desk rede) :: neighbor desks
==
::
:: Hash of a commit, for lookup in the object store (hut.ran)
::
@ -370,6 +373,23 @@
$: @tas :: by any
$% {$crud p/@tas q/(list tank)} ::
== == == ::
--
::
:: Old state types for ++load
::
=> |%
++ raft-1
$: rom/room
hoy/(map ship rung-1)
ran/rang :: hashes
mon/(map term beam)
hez/(unit duct)
cez/(map @ta crew)
cue/(qeu [duct task:able])
tip/@da
==
+= rung-1 rus/(map desk rede)
++ raft-2 raft
-- =>
:: %utilities
::
@ -393,6 +413,7 @@
:: -- local urbit `our`
:: -- current time `now`
:: -- current duct `hen`
:: -- scry handler `ski`
:: -- all vane state `++raft` (rarely used, except for the object store)
:: -- target urbit `her`
:: -- target desk `syd`
@ -430,11 +451,11 @@
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|%
++ de :: per desk
|= [our=ship now=@da hen=duct raft]
|= [our=ship now=@da ski=sley hen=duct raft]
|= [her=ship syd=desk]
:: XX ruf=raft crashes in the compiler
::
=* ruf |3.+6.^$
=* ruf |4.+6.^$
::
=+ ^- [hun=(unit duct) rede]
?. =(our her)
@ -459,9 +480,11 @@
?. =(our her)
:: save foreign +rede
::
=/ rus rus:(fall (~(get by hoy.ruf) her) *rung)
=/ rug (~(put by rus) syd red)
ruf(hoy (~(put by hoy.ruf) her rug))
=/ run (fall (~(get by hoy.ruf) her) *rung)
=? rit.run =(0 rit.run)
(fall (rift-scry her) *rift)
=/ rug (~(put by rus.run) syd red)
ruf(hoy (~(put by hoy.ruf) her run(rus rug)))
:: save domestic +room
::
%= ruf
@ -469,6 +492,20 @@
dos.rom (~(put by dos.rom.ruf) syd [qyx dom dok mer per pew]:red)
==
::
:: +rift-scry: for a +rift
::
++ rift-scry
~/ %rift-scry
|= who=ship
^- (unit rift)
=; rit
?~(rit ~ u.rit)
;; (unit (unit rift))
%- (sloy-light ski)
=/ pur=spur
/(scot %p who)
[[151 %noun] %j our %rift da+now pur]
::
:: Handle `%sing` requests
::
++ aver
@ -521,7 +558,8 @@
~& [%clay-first-failure message.head.row]
~
?: ?=([%success [%success *] [%error *]] row)
~& [%clay-second-failure message.tail.row]
~& %clay-second-failure
%- (slog message.tail.row)
~
?. ?=([%success [%success *] [%success *]] row)
~
@ -1759,6 +1797,7 @@
:* hen %pass
[%foreign-x (scot %p our) (scot %p her) syd car (scot cas) pax]
%f %build live=%.n %pin
:: XX perhaps should be now as in ++validate-plops
(case-to-date cas)
(vale-page [her syd] peg)
==
@ -1870,7 +1909,14 @@
%- emit
:* hen %pass
[%foreign-plops (scot %p our) (scot %p her) syd lum ~]
%f %build live=%.n %pin (case-to-date cas)
%f %build live=%.n %pin
:: This corresponds to all the changes from [her syd]
:: to [our %home]. This should be (case-to-date cas)
:: in the context of the foreign desk, but since we're
:: getting everything from our own desk now we want to
:: use our most recent commit.
::
now
%list
^- (list schematic:ford)
%+ turn ~(tap in pop)
@ -2816,12 +2862,14 @@
++ me :: merge ali into bob
|= {ali/(pair ship desk) alh/(unit dome) new/?} :: from
=+ bob=`(pair ship desk)`[our syd] :: to
:: ?: &(?=(~ mer) !new)
:: ~& [%not-actually-merging ali=ali bob=bob hen=hen]
:: ..me
=+ ^- dat/(each mery term)
?~ mer
?: new
=+ *mery
[%& -(sor ali:+, hen hen:+, wat %null)]
[%| %not-actually-merging]
?> new :: checked in ++take
=+ *mery
[%& -(sor ali:+, hen hen:+, wat %null)]
?. new
?: =(ali sor.u.mer)
[%& u.mer]
@ -2940,7 +2988,9 @@
|= rot/riot
^+ +>
?~ rot
(error:he %bad-fetch-ali ~)
?: (~(has by hoy) her)
(error:he %bad-fetch-ali ~)
(error:he %ali-sunk ~)
=+ ^= dum
:: construct an empty mime cache
::
@ -3174,7 +3224,7 @@
=+ (cat 3 %diff- nam)
[%merge (scot %p p.bob) q.bob (scot %p p.ali) q.ali - ~]
%f %build live=%.n %pin
(case-to-date:((de our now hen ruf) p.oth q.oth) r.oth)
(case-to-date:((de our now ski hen ruf) p.oth q.oth) r.oth)
%list
^- (list schematic:ford)
%+ murn ~(tap by q.bas.dat)
@ -3701,8 +3751,8 @@
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
=| :: instrument state
$: $1 :: vane version
ruf/raft :: revision tree
$: ver=%2 :: vane version
ruf=raft :: revision tree
== ::
|= [our=ship now=@da eny=@uvJ ski=sley] :: current invocation
^? :: opaque core
@ -3733,7 +3783,7 @@
=/ des ~(tap in ~(key by dos.rom.ruf))
|-
?~ des [[[hen %give %mack ~] mos] ..^^$]
=/ den ((de our now hen ruf) our i.des)
=/ den ((de our now ski hen ruf) our i.des)
=^ mor ruf
=< abet:wake
?: ?=(^ cew.req) den
@ -3768,7 +3818,7 @@
::
$drop
=^ mos ruf
=/ den ((de our now hen ruf) our des.req)
=/ den ((de our now ski hen ruf) our des.req)
abet:drop-me:den
[mos ..^$]
::
@ -3787,11 +3837,12 @@
?: =(%$ des.req)
[~ ..^$]
=^ mos ruf
=/ den ((de our now hen ruf) our des.req)
=/ den ((de our now ski hen ruf) our des.req)
abet:(edit:den now dit.req)
[mos ..^$]
::
$init
~& [%init hen]
[~ ..^$(hun.rom.ruf hen)]
::
$into
@ -3827,7 +3878,7 @@
?: =(%$ des.req)
[~ ..^$]
=^ mos ruf
=/ den ((de our now hen ruf) our des.req)
=/ den ((de our now ski hen ruf) our des.req)
abet:abet:(start:(me:ze:den [her.req dem.req] ~ &) cas.req how.req)
[mos ..^$]
::
@ -3844,7 +3895,7 @@
?~ dos
[~ ..^$]
=^ mos ruf
=/ den ((de our now hen ruf) p.bem q.bem)
=/ den ((de our now ski hen ruf) p.bem q.bem)
abet:(mont:den des.req bem)
[mos ..^$]
::
@ -3882,23 +3933,32 @@
::
$perm
=^ mos ruf
=/ den ((de our now hen ruf) our des.req)
=/ den ((de our now ski hen ruf) our des.req)
abet:(perm:den pax.req rit.req)
[mos ..^$]
::
$sunk
!:
~& rift=[p.req q.req]
~& desks=(turn ~(tap by dos.rom.ruf) head)
~& hoy=(turn ~(tap by hoy.ruf) head)
:: if we sunk, don't clear clay
::
?: =(our p.req)
[~ ..^$]
:: cancel subscriptions
::
=/ foreign-desk=(map desk rede)
(fall (~(get by hoy.ruf) p.req) ~)
=/ foreign-desk=(unit rung)
(~(get by hoy.ruf) p.req)
?~ foreign-desk
~& [%never-heard-of-her p.req q.req]
[~ ..^$]
~& old-rift=rit.u.foreign-desk
?: (gte rit.u.foreign-desk q.req)
~& 'replaying sunk, so not clearing state'
[~ ..^$]
=/ cancel-ducts=(list duct)
%- zing ^- (list (list duct))
%+ turn ~(tap by foreign-desk)
%+ turn ~(tap by rus.u.foreign-desk)
|= [=desk =rede]
%+ weld
^- (list duct) %- zing ^- (list (list duct))
@ -3915,12 +3975,12 @@
=/ clear-ford-cache-moves=(list move)
:~ [hen %pass /clear/keep %f %keep 0 1]
[hen %pass /clear/wipe %f %wipe 100]
[hen %pass /clear/kepe %f %keep 2.048 64]
[hen %pass /clear/kep %f %keep 2.048 64]
==
:: delete local state of foreign desk
::
=. hoy.ruf (~(del by hoy.ruf) p.req)
[(weld cancel-moves clear-ford-cache-moves) ..^$]
[(weld clear-ford-cache-moves cancel-moves) ..^$]
::
?($warp $werp)
:: capture whether this read is on behalf of another ship
@ -3935,7 +3995,7 @@
?> ?=($warp -.req)
=* rif rif.req
=^ mos ruf
=/ den ((de our now hen ruf) wer.req p.rif)
=/ den ((de our now ski hen ruf) wer.req p.rif)
=< abet
?~ q.rif
cancel-request:den
@ -3957,7 +4017,7 @@
=+ syd=(slav %tas i.t.pax)
=+ inx=(slav %ud i.t.t.pax)
=^ mos ruf
=/ den ((de our now hen ruf) wer syd)
=/ den ((de our now ski hen ruf) wer syd)
abet:(take-foreign-update:den inx ((hard (unit rand)) res.req))
[[[hen %give %mack ~] mos] ..^$]
::
@ -3977,11 +4037,34 @@
::
++ load
=> |%
++ axle $%([%1 ruf=raft])
++ axle $% [%1 ruf-1=raft-1]
[%2 ruf-2=raft]
==
--
|= old=axle
^+ ..^$
..^$(ruf ruf.old)
=? old ?=(%1 -.old)
~& desks=(turn ~(tap by dos.rom.ruf-1.old) head)
~& hoy=(turn ~(tap by hoy.ruf-1.old) head)
(load-1-2 old)
~& hrm=[-.old ver]
?> ?=(%2 -.old)
~& desks=(turn ~(tap by dos.rom.ruf-2.old) head)
~& hoy=(turn ~(tap by hoy.ruf-2.old) head)
%_(..^$ ruf ruf-2.old)
::
++ load-1-2
|= [%1 ruf-1=raft-1]
^- [%2 ruf-2=raft]
:- %2
%= ruf-1
hoy
%- ~(rut by hoy.ruf-1)
|= [her=ship run-1=rung-1]
^- rung
:- (fall (rift-scry her) *rift)
rus.run-1
==
::
++ scry :: inspect
|= {fur/(unit (set monk)) ren/@tas why/shop syd/desk lot/coin tyl/path}
@ -4004,14 +4087,14 @@
?: ?=(%| -.m) ~
?: =(p.m his) ~
`p.m
=/ den ((de our now [/scryduct ~] ruf) his syd)
=/ den ((de our now ski [/scryduct ~] ruf) his syd)
=+ (aver:den for u.run u.luk tyl)
?~ - -
?~ u.- -
?: ?=(%& -.u.u.-) ``p.u.u.-
~
::
++ stay [%1 ruf]
++ stay [%2 ruf]
++ take :: accept response
|= {tea/wire hen/duct hin/(hypo sign)}
^+ [*(list move) ..^$]
@ -4026,7 +4109,10 @@
%+ bind (~(get by dos.rom.ruf) sud)
|=(a=dojo dom.a)
=^ mos ruf
=/ den ((de our now hen ruf) our syd)
=/ den ((de our now ski hen ruf) our syd)
?~ mer.den
~& [%not-actually-merging ali=[her sud] bob=[our syd] hen=hen]
[~ ruf]
abet:abet:(route:(me:ze:den [her sud] kan |) sat dat)
[mos ..^$]
?: ?=({$blab care @ @ *} tea)
@ -4056,7 +4142,7 @@
=+ syd=(slav %tas i.t.t.tea)
=+ wen=(slav %da i.t.t.t.tea)
=^ mos ruf
=/ den ((de our now hen ruf) our syd)
=/ den ((de our now ski hen ruf) our syd)
abet:(take-inserting:den wen result.q.hin)
[mos ..^$]
::
@ -4065,7 +4151,7 @@
=+ syd=(slav %tas i.t.t.tea)
=+ wen=(slav %da i.t.t.t.tea)
=^ mos ruf
=/ den ((de our now hen ruf) our syd)
=/ den ((de our now ski hen ruf) our syd)
abet:(take-diffing:den wen result.q.hin)
[mos ..^$]
::
@ -4074,7 +4160,7 @@
=+ syd=(slav %tas i.t.t.tea)
=+ wen=(slav %da i.t.t.t.tea)
=^ mos ruf
=/ den ((de our now hen ruf) our syd)
=/ den ((de our now ski hen ruf) our syd)
abet:(take-castify:den wen result.q.hin)
[mos ..^$]
::
@ -4083,7 +4169,7 @@
=+ syd=(slav %tas i.t.t.tea)
=+ wen=(slav %da i.t.t.t.tea)
=^ mos ruf
=/ den ((de our now hen ruf) our syd)
=/ den ((de our now ski hen ruf) our syd)
abet:(take-mutating:den wen result.q.hin)
[mos ..^$]
::
@ -4091,7 +4177,7 @@
?> ?=({@ @ ~} t.tea)
=+ syd=(slav %tas i.t.t.tea)
=^ mos ruf
=/ den ((de our now hen ruf) our syd)
=/ den ((de our now ski hen ruf) our syd)
abet:(take-patch:den result.q.hin)
[mos ..^$]
::
@ -4099,7 +4185,7 @@
?> ?=({@ @ ~} t.tea)
=+ syd=(slav %tas i.t.t.tea)
=^ mos ruf
=/ den ((de our now hen ruf) our syd)
=/ den ((de our now ski hen ruf) our syd)
abet:(take-ergo:den result.q.hin)
[mos ..^$]
::
@ -4109,7 +4195,7 @@
=* syd i.t.t.t.tea
=+ lem=(slav %da i.t.t.t.t.tea)
=^ mos ruf
=/ den ((de our now hen ruf) her syd)
=/ den ((de our now ski hen ruf) her syd)
abet:(take-foreign-plops:den ?~(lem ~ `lem) result.q.hin)
[mos ..^$]
::
@ -4124,7 +4210,7 @@
->+
=* pax t.t.t.t.t.t.tea
=^ mos ruf
=/ den ((de our now hen ruf) her syd)
=/ den ((de our now ski hen ruf) her syd)
abet:(take-foreign-x:den car cas pax result.q.hin)
[mos ..^$]
==
@ -4221,4 +4307,17 @@
?~ -
`[paf %ins %mime -:!>(*mime) u.mim]
`[paf %mut %mime -:!>(*mime) u.mim]
:: +rift-scry: for a +rift
::
++ rift-scry
~/ %rift-scry
|= who=ship
^- (unit rift)
=; lyf
?~(lyf ~ u.lyf)
;; (unit (unit rift))
%- (sloy-light ski)
=/ pur=spur
/(scot %p who)
[[151 %noun] %j our %rift da+now pur]
--

View File

@ -1,4 +1,4 @@
:: :: /van/jael
!: :: /van/jael
:: :: %reference/0
!? 150
::
@ -1409,20 +1409,22 @@
::
:- (file-discontinuity who)
%= ..file
:: these must be appended here; +abet flops them
::
moz =/ lyf=life
moz =/ rit=rift
~| sunk-unknown+who
life:(~(got by kyz.puk))
%+ weld moz
^- (list move)
:~ [hen %slip %a %sunk who lyf]
[hen %slip %c %sunk who lyf]
[hen %slip %d %sunk who lyf]
[hen %slip %e %sunk who lyf]
[hen %slip %f %sunk who lyf]
[hen %slip %g %sunk who lyf]
==
=< continuity-number
%+ fall
net:(fall (~(get by pos.eth) who) *point)
*[life pass continuity-number=@ud [? @p] (unit @p)]
%+ weld
^- (list move)
:~ [hen %slip %a %sunk who rit]
[hen %slip %c %sunk who rit]
[hen %slip %d %sunk who rit]
[hen %slip %e %sunk who rit]
[hen %slip %f %sunk who rit]
[hen %slip %g %sunk who rit]
==
moz
==
:: pon: updated point
:: new: new keypair or "kept continuity?" (yes is no-op)
@ -2289,6 +2291,23 @@
=/ pub (~(get by kyz.puk.sub.lex) u.who)
?~ pub ~
``[%atom !>(life.u.pub)]
::
%rift
?. ?=([@ ~] tyl) [~ ~]
?. ?& ?=(%& -.why)
(~(has by pry.urb.lex) p.why)
==
[~ ~]
=/ who (slaw %p i.tyl)
?~ who [~ ~]
:: fake ships always have rift=1
::
?: fak.own.sub.lex
``[%atom !>(1)]
=/ pos (~(get by pos.eth.sub.lex) u.who)
?~ pos ~
?~ net.u.pos ~
``[%atom !>(continuity-number.u.net.u.pos)]
::
%deed
?. ?=([@ @ ~] tyl) [~ ~]

View File

@ -69,7 +69,8 @@
==
::
++ coop (unit ares) :: possible error
++ life @ud :: ship version
++ life @ud :: ship key revision
++ rift @ud :: ship continuity
++ mime {p/mite q/octs} :: mimetyped data
++ octs {p/@ud q/@t} :: octet-stream
++ sock {p/ship q/ship} :: outgoing [our his]
@ -241,7 +242,7 @@
[%init p=ship] :: report install
{$kick p/@da} :: wake up
{$nuke p/@p} :: toggle auto-block
{$sunk p=ship q=life} :: report death
{$sunk p=ship q=rift} :: report death
{$wake ~} :: timer activate
{$wegh ~} :: report memory
{$west p/ship q/path r/*} :: network request
@ -474,7 +475,7 @@
{$dirk des/desk} :: mark mount dirty
{$ogre pot/$@(desk beam)} :: delete mount point
{$perm des/desk pax/path rit/rite} :: change permissions
{$sunk p=ship q=life} :: report death
{$sunk p=ship q=rift} :: report death
{$warp wer/ship rif/riff} :: internal file req
{$werp who/ship wer/ship rif/riff} :: external file req
{$wegh ~} :: report memory
@ -638,7 +639,7 @@
{$harm ~} :: all terms hung up
{$init p/ship} :: after gall ready
{$noop ~} :: no operation
{$sunk p=ship q=life} :: report death
{$sunk p=ship q=rift} :: report death
{$talk p/tank} ::
{$text p/tape} ::
{$veer p/@ta q/path r/@t} :: install vane
@ -735,7 +736,7 @@
[%live p=@ud q=(unit @ud)] :: http/s ports
[%rule p=http-rule] :: update config
[%serv p=$@(desk beam)] :: set serving root
[%sunk p=ship q=life] :: report death
[%sunk p=ship q=rift] :: report death
[%them p=(unit hiss)] :: outbound request
[%they p=@ud q=httr] :: inbound response
[%chis p=? q=clip r=httq] :: IPC inbound request
@ -976,7 +977,7 @@
[%kill ~]
:: %sunk: receive a report that a foreign ship has lost continuity
::
[%sunk =ship =life]
[%sunk =ship =rift]
:: %wegh: produce memory usage information
::
[%wegh ~]
@ -1667,7 +1668,7 @@
$% {$conf p/dock q/culm} :: configure app
{$init p/ship} :: set owner
{$deal p/sock q/cush} :: full transmission
{$sunk p=ship q/life} :: report death
{$sunk p=ship q/rift} :: report death
{$west p/ship q/path r/*} :: network request
{$wegh ~} :: report memory
== ::
@ -1813,7 +1814,7 @@
== == ::
$: @tas ::
$% [%init p=ship] :: report install
[%sunk p=ship q=life] :: report death
[%sunk p=ship q=rift] :: report death
== == == ::
++ public :: public key state
$: life=life :: current key number