From 0fe385df1fe1f5a21098387eaa8810c622a2202f Mon Sep 17 00:00:00 2001 From: ixv Date: Thu, 17 Jun 2021 03:33:22 -0700 Subject: [PATCH] btc: don't use blockfilter if gap > 50; resubscribe on kick --- pkg/arvo/app/btc-wallet.hoon | 43 ++++++++++++++++++++---------------- pkg/arvo/lib/bitcoin.hoon | 2 +- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/pkg/arvo/app/btc-wallet.hoon b/pkg/arvo/app/btc-wallet.hoon index ea6a4dd89..2049298c4 100644 --- a/pkg/arvo/app/btc-wallet.hoon +++ b/pkg/arvo/app/btc-wallet.hoon @@ -4,7 +4,7 @@ :: x/scanned: (list xpub) of all scanned wallets :: x/balance/xpub: balance (in sats) of wallet /- *btc-wallet, bp=btc-provider, file-server, launch-store -/+ dbug, default-agent, bl=btc, bc=bitcoin, bip32, bip-b158 +/+ dbug, default-agent, bl=btc, bc=bitcoin, bip32 |% ++ defaults |% @@ -168,12 +168,14 @@ ^- (quip card _this) ?+ -.sign (on-agent:def wire sign) %kick - ~& >>> "kicked from prov {}" ?~ prov `this ?: ?& ?=(%set-provider -.wire) =(host.u.prov src.bowl) == - `this(prov ~) + :_ this(prov [~ src.bowl %.n]) + :~ (watch-provider src.bowl) + (give-update %change-provider `[src.bowl %.n]) + == `this :: %fact @@ -238,7 +240,6 @@ ?> (team:title our.bowl src.bowl) ?- -.comm %set-provider - |^ ?~ provider.comm ?~ prov `state :_ state(prov ~) @@ -252,20 +253,6 @@ (watch-provider u.provider.comm) (give-update %change-provider `[u.provider.comm %.n]) == - :: - ++ watch-provider - |= who=@p - ^- card - :* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider] - %watch /clients - == - ++ leave-provider - |= who=@p - ^- card - :* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider] - %leave ~ - == - -- :: %check-provider =/ pax /permitted/(scot %p provider.comm) @@ -722,6 +709,7 @@ (gulf +(block.btc-state) (dec block)) =? blocks ?|(?=(~ blockhash) ?=(~ blockfilter)) (snoc blocks block) + =? blocks (gth gap 50) ~ :: =/ cards=(list card) ;: weld @@ -739,6 +727,10 @@ ;: weld cards (retry-filtered-addrs network u.blockhash u.blockfilter) == + =? cards (gth gap 50) + ;: weld cards + (retry-addrs network) + == :- cards %_ state prov `p(connected %.y) @@ -792,7 +784,7 @@ :- ~ %+ murn %~ tap in - %: all-match:bip-b158 + %: all-match:bip-b158:bc blockfilter blockhash :: @@ -1126,6 +1118,19 @@ ^- card [%give %fact ~[/all] %btc-wallet-update !>(upd)] :: +++ watch-provider + |= who=@p + ^- card + :* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider] + %watch /clients + == +++ leave-provider + |= who=@p + ^- card + :* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider] + %leave ~ + == +:: ++ give-initial ^- card =^ a=(unit address) state diff --git a/pkg/arvo/lib/bitcoin.hoon b/pkg/arvo/lib/bitcoin.hoon index d790ff5a0..eb09a4f6b 100644 --- a/pkg/arvo/lib/bitcoin.hoon +++ b/pkg/arvo/lib/bitcoin.hoon @@ -3,7 +3,7 @@ :: expose BIP libraries :: /- sur=bitcoin -/+ bech32=bip-b173, pbt=bip-b174, bcu=bitcoin-utils +/+ bech32=bip-b173, pbt=bip-b174, bcu=bitcoin-utils, bip-b158 =, sur =, bcu |%