mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 08:32:39 +03:00
naive: add time for next L2 batch to state
This commit is contained in:
parent
b9c5d9e2e6
commit
85c0c11257
@ -33,6 +33,7 @@
|
|||||||
:: finding: raw-tx-hash reverse lookup for sending map
|
:: finding: raw-tx-hash reverse lookup for sending map
|
||||||
:: next-nonce: next l1 nonce to use
|
:: next-nonce: next l1 nonce to use
|
||||||
:: nas: predicted naive state
|
:: nas: predicted naive state
|
||||||
|
:: next-batch: when then next l2 batch will be sent
|
||||||
::
|
::
|
||||||
pending=(list pend-tx)
|
pending=(list pend-tx)
|
||||||
::
|
::
|
||||||
@ -43,6 +44,7 @@
|
|||||||
finding=(map keccak $?(%confirmed %failed l1-tx-pointer))
|
finding=(map keccak $?(%confirmed %failed l1-tx-pointer))
|
||||||
next-nonce=@ud
|
next-nonce=@ud
|
||||||
nas=^state:naive
|
nas=^state:naive
|
||||||
|
next-batch=time
|
||||||
::
|
::
|
||||||
:: pk: private key to send the roll
|
:: pk: private key to send the roll
|
||||||
:: frequency: time to wait between sending batches (TODO fancier)
|
:: frequency: time to wait between sending batches (TODO fancier)
|
||||||
@ -98,8 +100,9 @@
|
|||||||
=. frequency ~h1
|
=. frequency ~h1
|
||||||
=. contract naive:local-contracts:azimuth
|
=. contract naive:local-contracts:azimuth
|
||||||
=. chain-id chain-id:local-contracts:azimuth
|
=. chain-id chain-id:local-contracts:azimuth
|
||||||
|
=^ card next-batch set-timer
|
||||||
:_ this
|
:_ this
|
||||||
:~ set-timer
|
:~ card
|
||||||
[%pass /azimuth-txs %agent [our.bowl %azimuth] %watch /txs]
|
[%pass /azimuth-txs %agent [our.bowl %azimuth] %watch /txs]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -127,21 +130,21 @@
|
|||||||
:: /x/pending/[0xadd.ress] -> %noun (list pend-tx)
|
:: /x/pending/[0xadd.ress] -> %noun (list pend-tx)
|
||||||
:: /x/tx/[0xke.ccak]/status -> %noun tx-status
|
:: /x/tx/[0xke.ccak]/status -> %noun tx-status
|
||||||
:: /x/nonce/[~ship]/[0xadd.ress] -> %atom @
|
:: /x/nonce/[~ship]/[0xadd.ress] -> %atom @
|
||||||
|
:: /x/next-batch -> %atom time
|
||||||
::
|
::
|
||||||
++ on-peek
|
++ on-peek
|
||||||
|= =path
|
|= =path
|
||||||
^- (unit (unit cage))
|
^- (unit (unit cage))
|
||||||
|^
|
|^
|
||||||
?+ path ~
|
?+ path ~
|
||||||
[%x %pending ~] pending
|
[%x %pending ~] ``noun+!>(pending)
|
||||||
[%x %pending @ ~] (pending-by i.t.t.path)
|
[%x %pending @ ~] (pending-by i.t.t.path)
|
||||||
[%x %tx @ %status ~] (status i.t.t.path)
|
[%x %tx @ %status ~] (status i.t.t.path)
|
||||||
[%x %nonce @ @ ~] (nonce i.t.t.path i.t.t.t.path)
|
[%x %nonce @ @ ~] (nonce i.t.t.path i.t.t.t.path)
|
||||||
[%x %spawned @ ~] (spawned i.t.t.path)
|
[%x %spawned @ ~] (spawned i.t.t.path)
|
||||||
|
[%x %next-batch ~] ``noun+!>(next-batch)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ pending ``noun+!>(^pending)
|
|
||||||
::
|
|
||||||
++ pending-by
|
++ pending-by
|
||||||
|= wat=@t
|
|= wat=@t
|
||||||
?~ who=(slaw %p wat)
|
?~ who=(slaw %p wat)
|
||||||
@ -151,7 +154,7 @@
|
|||||||
[~ ~]
|
[~ ~]
|
||||||
=; pending=(list pend-tx)
|
=; pending=(list pend-tx)
|
||||||
``noun+!>(pending)
|
``noun+!>(pending)
|
||||||
%+ skim ^pending
|
%+ skim pending
|
||||||
|= pend-tx
|
|= pend-tx
|
||||||
::TODO deduce address from sig.raw-tx ?
|
::TODO deduce address from sig.raw-tx ?
|
||||||
!!
|
!!
|
||||||
@ -159,7 +162,7 @@
|
|||||||
::
|
::
|
||||||
=; pending=(list pend-tx)
|
=; pending=(list pend-tx)
|
||||||
``noun+!>(pending)
|
``noun+!>(pending)
|
||||||
%+ skim ^pending
|
%+ skim pending
|
||||||
|= pend-tx
|
|= pend-tx
|
||||||
=(u.who ship.from.tx.raw-tx)
|
=(u.who ship.from.tx.raw-tx)
|
||||||
::
|
::
|
||||||
@ -176,7 +179,7 @@
|
|||||||
::TODO potentially slow!
|
::TODO potentially slow!
|
||||||
=; known=?
|
=; known=?
|
||||||
[?:(known %pending %unknown) ~]
|
[?:(known %pending %unknown) ~]
|
||||||
%+ lien ^pending
|
%+ lien pending
|
||||||
|= [* raw-tx:naive]
|
|= [* raw-tx:naive]
|
||||||
=(u.keccak (hash-tx raw))
|
=(u.keccak (hash-tx raw))
|
||||||
::
|
::
|
||||||
@ -550,9 +553,9 @@
|
|||||||
:: +set-timer: %wait until next whole :frequency
|
:: +set-timer: %wait until next whole :frequency
|
||||||
::
|
::
|
||||||
++ set-timer
|
++ set-timer
|
||||||
^- card
|
^- [=card =time]
|
||||||
%+ wait:b:sys /timer
|
=+ time=(mul +((div now.bowl frequency)) frequency)
|
||||||
(mul +((div now.bowl frequency)) frequency)
|
[(wait:b:sys /timer time) time]
|
||||||
:: +on-timer: every :frequency, freeze :pending txs roll and start sending it
|
:: +on-timer: every :frequency, freeze :pending txs roll and start sending it
|
||||||
::
|
::
|
||||||
++ on-timer
|
++ on-timer
|
||||||
@ -575,7 +578,8 @@
|
|||||||
[(hash-raw-tx raw-tx) (get-l1-pointer tx.raw-tx nas)]
|
[(hash-raw-tx raw-tx) (get-l1-pointer tx.raw-tx nas)]
|
||||||
==
|
==
|
||||||
[(send-roll get-address nonce) state]
|
[(send-roll get-address nonce) state]
|
||||||
[[set-timer cards] state]
|
=^ card next-batch set-timer
|
||||||
|
[[card cards] state]
|
||||||
:: +get-nonce: retrieves the latest nonce
|
:: +get-nonce: retrieves the latest nonce
|
||||||
::
|
::
|
||||||
++ get-nonce
|
++ get-nonce
|
||||||
|
Loading…
Reference in New Issue
Block a user