Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce # of hash calculations in UI OfferBook view #5682

Merged
merged 1 commit into from
Sep 6, 2021

Conversation

ghubstan
Copy link
Member

@ghubstan ghubstan commented Sep 1, 2021

We can cache an offer payload hash as soon as its offerFeePaymentTxIdis 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 theOfferBookListItem 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 to support API editoffer method.

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`.
   Also 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`.
Copy link
Contributor

@ripcurlx ripcurlx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK - Tested it on Mainnet and everything seems to be as before.

@ripcurlx ripcurlx added this to the v1.7.4 milestone Sep 6, 2021
@ripcurlx ripcurlx merged commit 5595f7d into bisq-network:master Sep 6, 2021
@ghubstan ghubstan deleted the cache-the-offerpayload-hash branch September 6, 2021 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants