Repository navigation
Conversation
…events Push DEX and atomic swap offer-board changes to ev_subunsub subscribers instead of requiring clients to poll assets_swap_offers_list or swap_offers_board. - Payload follows the other ev_*_changed events: change, change_str and an offers array in the format of assets_swap_offers_list and swap_offers_board respectively. A reset with the full board follows the subscription. - ev_assets_swap_offers_changed needs --enable_assets and API v7.2+, otherwise -32024. ev_swap_offers_changed returns -32016 when atomic swaps are unavailable. A failed request changes no subscription. - Both events are blocked for DApps, like the list methods. - ISwapsProvider::getSwapOffersBoard() returns a non-const board so the API can subscribe to it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Author: Maxnflaxl (me@maxnflaxl.dev). His GitHub account is suspended, so he sent this patch by email and I'm opening the PR for him; the commit keeps him as the author.
Adds two
ev_subunsubevents to wallet-api, so clients get offer-board changes pushed instead of polling:ev_assets_swap_offers_changed, fed byDexBoard::IObserver. Needs--enable_assetsand API 7.2+, otherwise-32024.ev_swap_offers_changed, fed byISwapOffersObserver. Returns-32016when atomic swaps are unavailable.The payload matches the other
ev_*_changedevents (change,change_str,offers). Each offer has the same JSON asassets_swap_offers_listorswap_offers_board; the DEX list response and the event now share one serializer. A reset with the full board is sent right after subscribing. A failed request changes no subscription. Both events are blocked for DApps, as the list methods are.The server already subscribed to both boards with empty callbacks (
api_cli.cpp,api_cli_swap.h). This patch subscribes eachV61Apiinstance lazily and unsubscribes in its destructor.ISwapsProvider::getSwapOffersBoard()now returns a non-const reference, becauseSwapOffersBoard::Subscribeis non-const.Testing
From Maxnflaxl (macOS, Release, asset and atomic swaps on):
wallet_api_testandwallet_testpass.assets_swap_cancel), reset on subscribe and resubscribe, unsubscribe, the -32016/-32024/DApp errors, and that a destroyed API instance gets no more callbacks.assets_swap_offers_list, the error cases behave as above, and dropping subscribed sockets then reconnecting does not crash the daemon. The mainnet DEX board was empty during the test, so no live add/remove was seen there.api_cli.cppdoes not build, same as on master (BroadcastRouteris only included throughapi_cli_swap.h).Re-checked here on top of master daf7191 (macOS, RelWithDebInfo, both swap options on):
wallet-api,wallet_api_testandwallet_testbuild with no new warnings, and both tests pass.Docs for API v7.4: BeamMW/docs-gitbook#27