mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-03 04:40:50 +03:00
btc-prov/wallet: btc-provider only publishes information to the specific client that is asking for it now, except for new blocks and connection info
This commit is contained in:
parent
e6a3c948fa
commit
b4ca02d911
@ -155,7 +155,7 @@
|
||||
^- (quip card _state)
|
||||
:_ state
|
||||
?. ?|(connected.host-info ?=(%ping -.act))
|
||||
~[(send-update:hc [%| %not-connected 500])]
|
||||
~[(send-update:hc [%| %not-connected 500] ~)]
|
||||
:_ ~
|
||||
%+ req-card act
|
||||
^- action:rpc-types
|
||||
@ -177,7 +177,7 @@
|
||||
++ rpc-wire
|
||||
|= act=action
|
||||
^- wire
|
||||
/[-.act]/[(scot %ux (cut 3 [0 20] eny.bowl))]
|
||||
/[-.act]/(scot %p src.bowl)/(scot %ux (cut 3 [0 20] eny.bowl))
|
||||
--
|
||||
::
|
||||
++ on-watch
|
||||
@ -198,7 +198,11 @@
|
||||
==
|
||||
[%give %fact ~ %json !>(jon)]~
|
||||
::
|
||||
?> ?=([%clients *] pax)
|
||||
?> ?| ?=([%clients ~] pax)
|
||||
?& ?=([%clients @ ~] pax)
|
||||
=(src.bowl (slav %p i.t.pax))
|
||||
==
|
||||
==
|
||||
?. (is-whitelisted:hc src.bowl)
|
||||
~|("btc-provider: blocked client {<src.bowl>}" !!)
|
||||
~& > "btc-provider: accepted client {<src.bowl>}"
|
||||
@ -248,8 +252,8 @@
|
||||
(connection-error status)
|
||||
?^ conn-err
|
||||
:_ state(connected.host-info %.n)
|
||||
:~ (send-status:hc [%disconnected ~])
|
||||
(send-update:hc [%| u.conn-err])
|
||||
:~ (send-status:hc [%disconnected ~] ~)
|
||||
(send-update:hc [%| u.conn-err] ~)
|
||||
==
|
||||
::
|
||||
%+ handle-rpc-result wire
|
||||
@ -259,32 +263,35 @@
|
||||
++ handle-rpc-result
|
||||
|= [=wire r=result:rpc-types]
|
||||
^- (quip card _state)
|
||||
=/ ship=(unit ship)
|
||||
(slaw %p (snag 1 wire))
|
||||
?+ -.wire ~|("Unexpected HTTP response" !!)
|
||||
%address-info
|
||||
?> ?=([%get-address-info *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %address-info +.r])]
|
||||
~[(send-update:hc [%.y %address-info +.r] ship)]
|
||||
::
|
||||
%tx-info
|
||||
?> ?=([%get-tx-vals *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %tx-info +.r])]
|
||||
~[(send-update:hc [%.y %tx-info +.r] ship)]
|
||||
::
|
||||
%raw-tx
|
||||
?> ?=([%get-raw-tx *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %raw-tx +.r])]
|
||||
~[(send-update:hc [%.y %raw-tx +.r] ship)]
|
||||
::
|
||||
%broadcast-tx
|
||||
?> ?=([%broadcast-tx *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %broadcast-tx +.r])]
|
||||
~[(send-update:hc [%.y %broadcast-tx +.r] ship)]
|
||||
::
|
||||
%ping
|
||||
?> ?=([%get-block-info *] r)
|
||||
:_ state(connected.host-info %.y, block.host-info block.r)
|
||||
:_ ~
|
||||
%- send-status:hc
|
||||
:_ ~
|
||||
?: =(block.host-info block.r)
|
||||
[%connected network.host-info block.r fee.r]
|
||||
[%new-block network.host-info block.r fee.r blockhash.r blockfilter.r]
|
||||
@ -292,7 +299,7 @@
|
||||
%block-info
|
||||
?> ?=([%get-block-info *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %block-info network.host-info +.r])]
|
||||
~[(send-update:hc [%.y %block-info network.host-info +.r] ship)]
|
||||
==
|
||||
::
|
||||
++ connection-error
|
||||
@ -327,21 +334,24 @@
|
||||
~% %btc-provider-helper ..card ~
|
||||
|_ =bowl:gall
|
||||
++ send-status
|
||||
|= =status
|
||||
|= [=status ship=(unit ship)]
|
||||
^- card
|
||||
%- ?: ?=(%new-block -.status)
|
||||
~&(>> "%new-block: {<block.status>}" same)
|
||||
same
|
||||
[%give %fact ~[/clients] %btc-provider-status !>(status)]
|
||||
=- [%give %fact ~[-] %btc-provider-status !>(status)]
|
||||
?~ ship /clients
|
||||
/clients/(scot %p u.ship)
|
||||
::
|
||||
++ send-update
|
||||
|= =update
|
||||
|= [=update ship=(unit ship)]
|
||||
^- card
|
||||
=+ c=[%give %fact ~[/clients] %btc-provider-update !>(update)]
|
||||
?: ?=(%.y -.update)
|
||||
c
|
||||
~& >> "prov. err: {<p.update>}"
|
||||
c
|
||||
%- ?: ?=(%.y -.update)
|
||||
same
|
||||
~&(>> "prov. err: {<p.update>}" same)
|
||||
=- [%give %fact ~[-] %btc-provider-update !>(update)]
|
||||
?~ ship /clients
|
||||
/clients/(scot %p u.ship)
|
||||
::
|
||||
++ is-whitelisted
|
||||
~/ %is-whitelisted
|
||||
|
@ -23,6 +23,7 @@
|
||||
+$ versioned-state
|
||||
$% state-0
|
||||
state-1
|
||||
state-2
|
||||
==
|
||||
::
|
||||
+$ state-0
|
||||
@ -40,9 +41,8 @@
|
||||
ahistorical-txs=(set txid)
|
||||
==
|
||||
::
|
||||
+$ state-1
|
||||
$: %1
|
||||
prov=(unit provider)
|
||||
+$ base-state
|
||||
$: prov=(unit provider)
|
||||
walts=(map xpub:bc walt)
|
||||
=btc-state
|
||||
=history
|
||||
@ -54,8 +54,11 @@
|
||||
=poym
|
||||
ahistorical-txs=(set txid)
|
||||
==
|
||||
::
|
||||
+$ state-1 [%1 base-state]
|
||||
+$ state-2 [%2 base-state]
|
||||
--
|
||||
=| state-1
|
||||
=| state-2
|
||||
=* state -
|
||||
%- agent:dbug
|
||||
^- agent:gall
|
||||
@ -113,8 +116,17 @@
|
||||
=| cards=(list card)
|
||||
|-
|
||||
?- -.ver
|
||||
%1
|
||||
%2
|
||||
[cards this(state ver)]
|
||||
::
|
||||
%1
|
||||
=? cards ?=(^ prov.ver)
|
||||
:_ cards
|
||||
=/ =dock [u.prov.ver %btc-provider]
|
||||
=/ wir=wire /set-provider/(scot %p u.prov.ver)
|
||||
=/ priv-wire=^wire (welp wir [%priv ~])
|
||||
[%pass priv-wire %agent dock %watch /clients/(scot %p our.bowl)]
|
||||
$(-.ver %2)
|
||||
::
|
||||
%0
|
||||
=/ new-walts=(map xpub:bc walt)
|
||||
@ -161,10 +173,11 @@
|
||||
==
|
||||
:_ state(prov `[u.provider.comm %.n])
|
||||
?~ prov
|
||||
[(watch-provider:hc u.provider.comm)]~
|
||||
:~ (leave-provider host.u.prov)
|
||||
(watch-provider:hc u.provider.comm)
|
||||
%- zing
|
||||
:~ (leave-provider host.u.prov)^~
|
||||
(watch-provider:hc u.provider.comm)
|
||||
(give-update:hc %change-provider `[u.provider.comm %.n])
|
||||
(give-update:hc %change-provider `[u.provider.comm %.n])^~
|
||||
==
|
||||
::
|
||||
++ leave-provider
|
||||
@ -646,8 +659,9 @@
|
||||
==
|
||||
`this
|
||||
:_ this(prov [~ src.bowl %.n])
|
||||
%- zing
|
||||
:~ (watch-provider:hc src.bowl)
|
||||
(give-update:hc %change-provider `[src.bowl %.n])
|
||||
(give-update:hc %change-provider `[src.bowl %.n])^~
|
||||
==
|
||||
::
|
||||
%fact
|
||||
@ -1208,10 +1222,13 @@
|
||||
::
|
||||
++ watch-provider
|
||||
|= who=@p
|
||||
^- card
|
||||
:* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider]
|
||||
%watch /clients
|
||||
==
|
||||
^- (list card)
|
||||
=/ =dock [who %btc-provider]
|
||||
=/ wir=wire /set-provider/(scot %p who)
|
||||
=/ priv-wire=^wire (welp wir [%priv ~])
|
||||
:+ [%pass wir %agent dock %watch /clients]
|
||||
[%pass priv-wire %agent dock %watch /clients/(scot %p our.bowl)]
|
||||
~
|
||||
::
|
||||
++ give-initial
|
||||
^- card
|
||||
|
Loading…
Reference in New Issue
Block a user