mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-14 08:34:25 +03:00
WIP: wire up scanning logic
This commit is contained in:
parent
6991d2ff73
commit
73d920bea0
@ -77,48 +77,82 @@
|
|||||||
^- (quip card _state)
|
^- (quip card _state)
|
||||||
?- -.act
|
?- -.act
|
||||||
%add-wallet
|
%add-wallet
|
||||||
`state
|
=/ w=_walt (from-xpub:walt +.act)
|
||||||
|
:- ~[(pass-scan xpub.act)]
|
||||||
|
state(walts (~(put by walts) xpub.act w))
|
||||||
::
|
::
|
||||||
%scan
|
%run-scan
|
||||||
`state
|
(run-scan +.act)
|
||||||
::
|
::
|
||||||
%watch-address
|
%watch-address
|
||||||
:: [%watch-address =xpub =chyg =idx utxos=(set utxo) used=?]
|
|
||||||
(watch-address +.act)
|
(watch-address +.act)
|
||||||
::
|
::
|
||||||
%update-address
|
%update-address
|
||||||
`state
|
`state
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ scan-action
|
++ pass-scan
|
||||||
|= =xpub ^- card
|
|= =xpub ^- card
|
||||||
:* %pass /[(scot %da now.bowl)]
|
:* %pass /[(scot %da now.bowl)]
|
||||||
%agent [our.bowl %btc-wallet-store] %poke
|
%agent [our.bowl %btc-wallet-store] %poke
|
||||||
%btc-wallet-store-action !>([%scan xpub])
|
%btc-wallet-store-action !>([%run-scan xpub])
|
||||||
==
|
==
|
||||||
|
:: update scans to start a new wallet scan from 0 indices
|
||||||
::
|
::
|
||||||
++ do-scan 2
|
++ init-scan
|
||||||
:: watch the address passed
|
|= [=xpub max-gap=@]
|
||||||
:: update wallet if it's used
|
^- ^scans
|
||||||
:: if this idx was the last in todo.scans,
|
=/ final=idx (dec max-gap)
|
||||||
|
=/ b=batch [(sy (gulf 0 final)) 0 final]
|
||||||
|
=. scans
|
||||||
|
(~(put by scans) [xpub %0] b)
|
||||||
|
(~(put by scans) [xpub %1] b)
|
||||||
|
::
|
||||||
|
++ end-scan
|
||||||
|
|= [=xpub]
|
||||||
|
^- _state
|
||||||
|
=/ w=_walt (~(got by walts) xpub)
|
||||||
|
=. scans (~(del by scans) [xpub %0])
|
||||||
|
=. scans (~(del by scans) [xpub %1])
|
||||||
|
state(walts (~(put by walts) xpub w(scanned.st %.y)))
|
||||||
|
::
|
||||||
|
++ run-scan
|
||||||
|
|= =xpub
|
||||||
|
^- (quip card _state)
|
||||||
|
=/ w=_walt (~(got by walts) xpub)
|
||||||
|
=? scans ?!((~(has by scans) [xpub %0]))
|
||||||
|
(init-scan xpub max-gap.st.w)
|
||||||
|
=/ ching=batch (~(got by scans) [xpub %0])
|
||||||
|
=/ chang=batch (~(got by scans) [xpub %1])
|
||||||
|
?: ?& (empty ching)
|
||||||
|
(empty chang)
|
||||||
|
~(scan-done w %0)
|
||||||
|
~(scan-done w %1)
|
||||||
|
==
|
||||||
|
`(end-scan xpub)
|
||||||
|
:: TODO: otherwise, make cards for the non-empty one
|
||||||
|
`state
|
||||||
|
:: watch the address passed, update wallet if it's used
|
||||||
|
:: if this idx was the last in todo.scans, check whether scan is done
|
||||||
::
|
::
|
||||||
++ watch-address
|
++ watch-address
|
||||||
|= [=xpub:btc =chyg =idx utxos=(set utxo) used=?]
|
|= [=xpub:btc =chyg =idx utxos=(set utxo) used=?]
|
||||||
^- (quip card _state)
|
^- (quip card _state)
|
||||||
?. (~(has by scans) [xpub chyg]) `state
|
?. (~(has by scans) [xpub chyg]) `state
|
||||||
=/ w=_walt (~(got by walts) xpub)
|
=/ w=_walt (~(got by walts) xpub)
|
||||||
=/ s=scan-batch (~(got by scans) [xpub chyg])
|
=/ b=batch (~(got by scans) [xpub chyg])
|
||||||
=? w used
|
=? w used
|
||||||
%+ ~(watch-address w chyg)
|
%+ ~(watch-address w chyg)
|
||||||
(~(mk-address w chyg) idx)
|
(~(mk-address w chyg) idx)
|
||||||
[chyg idx utxos]
|
[chyg idx utxos]
|
||||||
:: if todo is empty, either scan a new batch or finish
|
:: if todo is empty, check the scan status *after* this update
|
||||||
::
|
::
|
||||||
:- ?:(=(0 ~(wyt in todo.s)) ~[(scan-action xpub)] ~)
|
:- ?: (empty todo.b) ~[(pass-scan xpub)] ~
|
||||||
%= state
|
%= state
|
||||||
walts (~(put by walts) xpub w)
|
walts (~(put by walts) xpub w)
|
||||||
scans %+ ~(put by scans)
|
scans %+ ~(put by scans)
|
||||||
[xpub chyg]
|
[xpub chyg]
|
||||||
s(todo (~(del in todo.s) idx))
|
b(todo (~(del in todo.b) idx))
|
||||||
==
|
==
|
||||||
|
++ empty |*(s=(set *) =(0 ~(wyt in s)))
|
||||||
--
|
--
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
:: todo: Set of indices; empty it out until none are left--means scanning of that batch is done
|
:: todo: Set of indices; empty it out until none are left--means scanning of that batch is done
|
||||||
:: start: index this batch started scanning from
|
:: start: index this batch started scanning from
|
||||||
::
|
::
|
||||||
+$ scan-batch [todo=(set idx) start=idx]
|
+$ batch [todo=(set idx) start=idx final=idx]
|
||||||
+$ scans (map [xpub chyg] scan-batch)
|
+$ scans (map [xpub chyg] batch)
|
||||||
::
|
::
|
||||||
:: %add-wallet: add wallet to state and initiate a scan
|
:: %add-wallet: add wallet to state and initiate a scan
|
||||||
:: %scan: start a scan of the next address batch in a wallet
|
:: %scan: start a scan of the next address batch in a wallet
|
||||||
@ -40,7 +40,7 @@
|
|||||||
::
|
::
|
||||||
+$ action
|
+$ action
|
||||||
$% [%add-wallet =xpub scan-to=(unit scon) max-gap=(unit @)]
|
$% [%add-wallet =xpub scan-to=(unit scon) max-gap=(unit @)]
|
||||||
[%scan =xpub]
|
[%run-scan =xpub]
|
||||||
[%watch-address =xpub =chyg =idx utxos=(set utxo) used=?]
|
[%watch-address =xpub =chyg =idx utxos=(set utxo) used=?]
|
||||||
[%update-address a=address utxos=(set utxo)]
|
[%update-address a=address utxos=(set utxo)]
|
||||||
==
|
==
|
||||||
|
Loading…
Reference in New Issue
Block a user