[bisq-network/bisq] Reduce # of hash calculations in UI OfferBook view (#5682)

Stan notifications at github.com
Wed Sep 1 20:58:44 CEST 2021

We can cache an offer payload hash as soon as its `offerFeePaymentTxId`is set.  (The payload hash cannot be calculated until the object can be transformed into a protobuf message, which requires a non-null `offerFeePaymentTxId`.)

Another benefit is removal of the payload hash argument from the`OfferBookListItem` constructor.

Changes include

- `OfferPayload` Added `transient byte[] hash` field + getter method (where hash is calculated and cached).

- `OfferBookService` Removed `P2PDataStorage.ByteArray hashOfPayload` parameter from `OfferBookChangedListener` listener methods `onAdded` & `onRemoved`.  (Hash is cached in `OfferPayload`.)

- `P2PDataStorage` Added null check to `ByteArray` class constructor.

- `OfferBook` Adjusted for change to `OfferBookChangedListener`, and removed redundant payload hash null checks.

- `TakeOfferDataModel` and `MarketAlerts` Adjusted for change to `OfferBookChangedListener`.

- `OfferBookListItem` Removed overloaded constructor with `@Nullable P2PDataStorage.ByteArray hashOfPayload` parameter.  (Field value is set from cached offer payload hash.)

- `OfferBookViewModelTest` and `OfferMaker`  Adjusted test and test fixture:  do not attempt to create offer payloads without an `offerFeePaymentTxId`.

_Follow up to the [last PR in series](https://github.com/bisq-network/bisq/pull/5666)  to support API `editoffer` method._
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * Reduce # of hash calculations in UI OfferBook view

-- File Changes --

    M core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java (6)
    M core/src/main/java/bisq/core/offer/OfferBookService.java (17)
    M core/src/main/java/bisq/core/offer/OfferPayload.java (26)
    M desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java (47)
    M desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookListItem.java (14)
    M desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java (2)
    M desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java (11)
    M desktop/src/test/java/bisq/desktop/maker/OfferMaker.java (112)
    M p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java (18)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210901/e1d4abc3/attachment.htm>

More information about the bisq-github mailing list