[bisq-network/bisq] Add UI OfferBook list add/remove checks (#5659)
Stan
notifications at github.com
Wed Aug 11 16:42:43 CEST 2021
Problem: Using the API's CLI to edit offers causes add/remove messages to be received on peers in the same envelope batch, then passed to the UI in random order. When `OfferBook` receives a remove(offer) event after an add(offer) event, the edited offer will be removed immediately after being added to the UI's `OfferBook` list.
Fix: This change uses storage entry sequence number and storage entry payload hash comparisons to avoid the problem.
- `OfferBookListItem` Added new constructor taking `P2PDataStorage.ByteArray hashOfPayload`,
and `int sequenceNumber` params. Defined a `toString` method.
- `OfferBook` Added new checks on `OfferBookListItem`'s `hashOfPayload` and `sequenceNumber` while
determining if offer candidates should be added or removed from the UI's OfferBook List.
See OfferBook contructor's implementation of OfferBookChangedListener#onAdded and
OfferBookChangedListener#onRemoved. Added many (maybe too many) comments explaining the add/remove rules,
and plenty of debug statements (maybe too many) to help trace the add/remove event process.
- `OfferBookService#OfferBookChangedListener` Added new `P2PDataStorage.ByteArray` hashOfPayload,
and `int sequenceNumber` params to listener's `onAdded` and `onRemoved` method signatures.
Added these two new parameter values to listener.onAdded and listener.onRemoved calls.
- `TakeOfferDataModel` Replaced unused `tradeManager` param in `offerBook.removeOffer`
with `P2PDataStorage.ByteArray hashOfPayload` (null), and `int sequenceNumber` (-1) params.
`OfferBook` will remove the candidate offer as before.
- MarketAlerts` Adjusted `onAdded` & `onRemoved` listener method signatures.
This PR is based on https://github.com/bisq-network/bisq/pull/5577, which should be reviewed and merged before this one.
You can view, comment on, or merge this pull request online at:
https://github.com/bisq-network/bisq/pull/5659
-- Commit Summary --
* Refactor EditOfferDataModel for new editoffer api method
* Fix comment
* Add OfferInfo field isActivated, rpc EditOffer to proto
* Add server/core editOffer, adjust getMyOffer(s) impls
* Refactor GrpcClient: request builders moved bisq.cli.request pkg
* Add new EditOfferOptionParser and test
* Add editoffer method help
* Add editoffer to CLI
* Add editoffer api tests & minor apitest refactoring
* Remove chase quickpay acct test
* Remove unused import
* Fix problems found in codacy check
* Fix codacy issue
* Fix log arg spec bug
* Add bool isMyOffer to OfferInfo proto
* Fix editoffer validation bugs, tidy up CoreOffersService
* Show enable/trigger-price cols for 'getmyoffer'
* Improve 'editoffer' opt parsing, fix test pkg name
* Add editoffer test case, suppress annoying warnings
* Remove unused field
* Throw exception is edit altcoin offer is attempted
* Avoid duplicate test run
* Make codacy just a bit happier
* Force codacy check after codacy config change
* Include isMyOffer flag in API's trade/offer proto wrappers
* Pass isMyOffer flag to trade/offer proto wrappers from core services
* Add altcoin (bsq) offer editing validation check
* Optionally show ENABLED column in CLI's getoffer(bsq) output
* Add BSQ offer editing tests to EditOfferTest
* Merge branch 'master' into 02-refactor-for-api-editoffer-method
* Merge branch '02-refactor-for-api-editoffer-method' into 03-api-editoffer-method
* Merge branch '03-api-editoffer-method' into 04-edit-bsq-offer
* Force rebuild after github action ECONNRESET
* Document api 'editoffer' usage
* Fix header
* Delete tmp main() method
* Rename and move private function
* Do not duplicate Price.parse on CLI side for only one use case
* Remove old TODO because relevant refactoring was approved
* Fix typo 'enabled' -> 'enable'
* Always use Locale.US in CLI DecimalFormats
* Merge branch 'master' into 05-update-api-beta-test-guide
* Do not start test harness deamons in dbg mode by default
* Add missing trigger-price param
* Fix peer add(offer) & remove(offer) event order problem
* Revert "Fix peer add(offer) & remove(offer) event order problem"
* Merge branch 'master' into 05-update-api-beta-test-guide
* Ensure UI OfferBook items are correctly added and removed
* Revert logback debug config changes
* Merge branch 'master' into 06-safe-offerbook-add-remove-events
* Remove comment (question answered)
-- File Changes --
M apitest/docs/api-beta-test-guide.md (114)
M apitest/src/test/java/bisq/apitest/method/offer/AbstractOfferTest.java (56)
M apitest/src/test/java/bisq/apitest/method/offer/CancelOfferTest.java (3)
M apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java (57)
A apitest/src/test/java/bisq/apitest/method/offer/EditOfferTest.java (644)
M apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferTest.java (3)
M apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferWithNationalBankAcctTest.java (3)
M apitest/src/test/java/bisq/apitest/method/trade/TakeSellBTCOfferTest.java (3)
A apitest/src/test/java/bisq/apitest/scenario/LongRunningOfferDeactivationTest.java (167)
M apitest/src/test/java/bisq/apitest/scenario/OfferTest.java (30)
M apitest/src/test/java/bisq/apitest/scenario/bot/BotClient.java (11)
M apitest/src/test/java/bisq/apitest/scenario/bot/RandomOffer.java (9)
M cli/src/main/java/bisq/cli/CliMain.java (42)
M cli/src/main/java/bisq/cli/ColumnHeaderConstants.java (3)
M cli/src/main/java/bisq/cli/CurrencyFormat.java (75)
M cli/src/main/java/bisq/cli/GrpcClient.java (377)
M cli/src/main/java/bisq/cli/Method.java (1)
M cli/src/main/java/bisq/cli/TableFormat.java (185)
M cli/src/main/java/bisq/cli/opts/AbstractMethodOptionParser.java (4)
A cli/src/main/java/bisq/cli/opts/EditOfferOptionParser.java (281)
M cli/src/main/java/bisq/cli/opts/OptLabel.java (2)
A cli/src/main/java/bisq/cli/request/OffersServiceRequest.java (319)
A cli/src/main/java/bisq/cli/request/PaymentAccountsServiceRequest.java (85)
A cli/src/main/java/bisq/cli/request/TradesServiceRequest.java (94)
A cli/src/main/java/bisq/cli/request/WalletsServiceRequest.java (192)
A cli/src/test/java/bisq/cli/opts/EditOfferOptionParserTest.java (346)
R cli/src/test/java/bisq/cli/opts/OptionParsersTest.java (11)
M core/src/main/java/bisq/core/api/CoreApi.java (47)
M core/src/main/java/bisq/core/api/CoreOffersService.java (193)
A core/src/main/java/bisq/core/api/EditOfferValidator.java (141)
M core/src/main/java/bisq/core/api/model/OfferInfo.java (45)
M core/src/main/java/bisq/core/api/model/TradeInfo.java (10)
M core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java (6)
A core/src/main/java/bisq/core/offer/MutableOfferPayloadFields.java (89)
M core/src/main/java/bisq/core/offer/OfferBookService.java (22)
M core/src/main/java/bisq/core/offer/OfferUtil.java (47)
A core/src/main/resources/help/editoffer-help.txt (95)
M daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java (31)
M daemon/src/main/java/bisq/daemon/grpc/GrpcTradesService.java (6)
M desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java (161)
M desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookListItem.java (45)
M desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java (2)
M desktop/src/main/java/bisq/desktop/main/portfolio/editoffer/EditOfferDataModel.java (49)
M desktop/src/main/resources/logback.xml (1)
M proto/src/main/proto/grpc.proto (33)
-- Patch Links --
https://github.com/bisq-network/bisq/pull/5659.patch
https://github.com/bisq-network/bisq/pull/5659.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/5659
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210811/c1fbef7d/attachment-0001.htm>
More information about the bisq-github
mailing list