HomePhabricator

[Cashtab] [WS update engine Part 4] On successful websocket connection, change…

Description

[Cashtab] [WS update engine Part 4] On successful websocket connection, change wallet utxo refresh interval from 1s to 30s

Summary:
T2447

Depends on D11673

Part 4 (of 4 planned) stacked diff for converting Cashtab from a static refresh rate to an on-demand refresh rate depending on Websocket transaction messages

Start Cashtab with the legacy refresh rate of 1 second (this is how often an API call is performed to see if the utxo set has changed).

If the websocket connects successfully, reduce this rate to 30s (because the websocket connection will now trigger an update on demand when a new tx is seen).

Re-adjusting the refresh rate back to 1s on a websocket disconnect event was considered and rejected, as this should be properly handled by T2522. This means that if chronik goes down while a user has their browser open, the refresh rate will be slow until the websocket reconnects.

Test Plan:
npm start
Check the dev console to see refresh rate
Send and receive transactions, see that wallet refreshes in line with the tx notification.
Try to break it. Send lots of txs at the same time, receive and send tx at the same time.

Reviewers: #bitcoin_abc, emack

Reviewed By: #bitcoin_abc, emack

Subscribers: emack

Differential Revision: https://reviews.bitcoinabc.org/D11691

Details