Commit Graph

7072 Commits

Author SHA1 Message Date
HenrikJannsen
0327872550
Remove BurningManService.isActivated and apply changed to client code.
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-17 13:36:40 +07:00
Alejandro García
ac8ad24807
Merge pull request #6697 from stejbac/speed-up-burningman-and-statistics-view-loads
Speed up burningman and statistics view loads
2023-05-16 15:53:44 +00:00
Alejandro García
2a79370bb9
Merge pull request #6692 from alvasw/fix_broken_coin_util_test_test_get_adjusted_amount
core: Fix broken CoinUtilTest.testGetAdjustedAmount
2023-05-13 15:33:30 +00:00
Alva Swanson
e94da0d74f
core: Fix broken CoinUtilTest.testGetAdjustedAmount
Relates to #6619
2023-05-13 14:09:34 +07:00
Steven Barclay
f0b011e0ac
Optimise Price.getVolumeByAmount to speed up USD & BSQ conversions
Short circuit the BigInteger arithmetic in 'AltcoinExchangeRate' &
'org.bitcoinj.utils.ExchangeRate' (from which the former is adapted), by
using ordinary long arithmetic when it is guaranteed not to overflow due
to the two quantities to be multiplied fitting in an int. This will be
the case most of the time. Also remove duplicated logic, to ensure that
all conversions of BTC amounts to volumes happen via the 'Price'
instance methods, so that the optimisation always applies.

In particular, this speeds up the BTC -> BSQ conversions in the burning
man view, as well as the USD price calculations for the candles in the
trades charts view via 'TradeStatistics3.getTradeVolume()'.

Additionally, fix the lazy initialisation pattern in TradeStatistics3 to
ensure that it is thread safe (that is, it only has benign data races),
by making it of the form:

  Foo foo = this.foo;
  if (foo == null) {
      this.foo = foo = computeFoo();
  }
  return foo;

This avoids the problem that 'foo' is a nonvolatile field and can
therefore be seen to alternate any number of times between null and
nonnull from the PoV of the thread initialising it (at least when the
initialisation is racy).
2023-05-10 19:41:27 +01:00
Steven Barclay
b8505db48d
Memoise BurningManAccountingService.getAverageBsqPriceByMonth()
Add an 'averagePricesValid' boolean field to avoid needless refilling of
the cached BSQ prices map when calling 'getAverageBsqPriceByMonth()'.
(Also skip a redundant filling of the map will non-historical data upon
startup of the service.) Since the prices are calculated from the
(observable) set of all trade statistics, add a listener to the set to
invalidate the cache whenever it changes.

This significantly speeds up the burning man view, since the getter is
called several times when activating it.
2023-05-10 19:41:26 +01:00
Steven Barclay
ade339349c
Clean up BurningManAccountingService: deduplicate code
Factor out duplicated logic in the 'Stream.map' lambdas to compute the
BSQ value of the BTC of each streamed ReceivedBtcBalanceEntry, returned
as an 'Optional<Long>'. Also simplify the logic slightly and return an
OptionalLong instead for greater efficiency.

(Also replace a statement lambda with an expression lambda.)
2023-05-10 19:41:26 +01:00
Steven Barclay
e287177e49
Speed up burn target calculations in burning man view
Optimise 'BurningManPresentationService.getCandidateBurnTarget' to avoid
the repeated computation of the total accumulated decayed burned amount
for every listed burning man. To this end, cache the total in a nullable
Long field, along with the method 'getAccumulatedDecayedBurnedAmount()'
to lazily initialise it. (This eliminates a minor hotspot in the burning
man view revealed by JProfiler.)
2023-05-10 19:41:25 +01:00
Steven Barclay
914d75682c
Cache enum.values() in ChartCalculations & TradeStatistics3
Cache enum arrays 'TickUnit.values()' & 'PaymentMethodWrapper.values()'
as the JVM makes defensive copies of them every time they are returned,
and they are both being used in tight loops. In particular, profiling
suggests this will make 'TradeStatistics3.isValid' about twice as fast.
2023-05-10 19:41:22 +01:00
Steven Barclay
0ba2e491ca
Fix quadratic time bug in AveragePriceUtil.getUSDAverage
Now that the trade statistics are retrieved as a sorted set, it can be
assumed that the USD & BSQ trade lists passed to 'getUSDAverage' are
already sorted. Use this to avoid repeatedly scanning the USD trade list
for the first trade dated after each given BSQ trade, by moving two
cursors in a single pass across the respective lists simultaneously.
2023-05-10 19:41:20 +01:00
Steven Barclay
b417e36a28
Make TradeStatistics3 comparable & hold in a TreeSet
Make TradeStatistics3 implement the previously added ComparableExt
interface and make TradeStatisticsManager hold them as a TreeSet instead
of a HashSet, to support fast retrieval of statistics in any given date
range. (Even though red-black trees are generally slower than hash
tables, this should not matter here since the set is only being iterated
over and infrequently appended, and does not benefit from O(1) lookups/
additions/removals.)

Add a 'TradeStatisticsManager.getNavigableTradeStatisticsSet' accessor,
which returns the backing TreeSet of the current ObservableSet field, so
that callers can access its NavigableSet interface where needed (as
there is no ObservableSortedSet or similar in JavaFX). Use this to
optimise 'AveragePriceUtil.getAveragePriceTuple',
'DisputeAgentSelection.getLeastUsedDisputeAgent' and
'MutableOfferDataModel.getSuggestedSecurityDeposit', to obtain a narrow
date range of trade statistics without streaming over the entire set.

Additionally optimise & simplify the price collation in
'TradeStatisticsManager.onAllServicesInitialised', by exploiting the
fact that the statistics are now sorted in order of date (which is the
presently defined natural order).
2023-05-10 19:41:20 +01:00
Steven Barclay
e231c64cc2
Use primitive arrays & streams to optimise InlierUtil
Use a DoubleStream when streaming over 'List<Double>' method arguments
in InlierUtil, as well as a primitive array sort in 'InlierUtil.trim'
(followed by taking a sublist view), instead of calling 'Stream.sorted'.

To this end, use Guava 'Doubles.asList' to pass lists of Doubles to/from
the InlierUtil methods without incurring any boxing or unboxing costs,
since their spliterators can be simply downcast to Spliterator.OfDouble
(opportunistically), instead of needing to use 'mapToDouble' to unbox.

This was a minor hotspot when called from AveragePriceUtil (used by the
burning man and BSQ dashboard views).
2023-05-10 19:41:19 +01:00
Steven Barclay
069b20ae5f
Use correct bounds in AveragePriceUtil.removeOutliers
Use nonstrict bounds when filtering outliers from the provided trade
statistics list, since otherwise it will always remove the outermost two
inliers from the list. This is because the dependent call to
'InlierUtil.findInlierRange' returns the min & max inlier values.
2023-05-10 19:41:19 +01:00
Steven Barclay
277b170e3c
Further speedups of TradeStatistics3.isValid
Use a Map to speed up 'PaymentMethod.getPaymentMethod', called from
'isValid', instead of scanning the payment method list every invocation.
Make the list immutable to ensure the map never goes stale, which is OK
since no code modified it outside PaymentMethod's static initialisation.

Also speed up the global accessor 'TradeLimits.getMaxTradeLimit', by
caching the DAO param value in a volatile field, cleared upon each new
block arrival.

Furthermore, speed up 'TradeLimits.getFirstMonthRiskBasedTradeLimit' by
simplifying the rounding logic to avoid a pass through the (rather slow)
BigDecimal type.
2023-05-10 19:41:18 +01:00
Steven Barclay
4bc1d299e5
Avoid exception to speed up TradeStatistics3.isValid
Short circuit the exception control flow used in the method
'TradeStatistics3.getPaymentMethodId', which occurs whenever the payment
method code is stored directly in the 'paymentMethod' field instead of
first being converted into a numeric string. This occurs if the method
is unrecognised as it is not in listed into 'PaymentMethodWrapper' enum.

This fixes an unnecessary slowdown of 'TradeStatistics3.isValid', which
calls the above, when scanning the list of BSQ trade statistics in
AveragePriceUtil and elsewhere, due to the fact that the 'BSQ_SWAP'
payment method has been missed out of the above enum.

Also add a (presently disabled) unit test to prevent any future payment
methods from being missed out of the enum. (Should fix the missing BSQ
swaps issue in a separate PR to make sure that the seed nodes recognise
the new payment method code before anyone else.)
2023-05-10 19:40:19 +01:00
Alva Swanson
734650d43e
core: Fix broken PriceTest.testParse test
Relates to #6619
2023-05-09 21:23:18 +10:00
napoly
e19ffe2308
Upgrade JUnit4 to JUnit5 Jupiter 2023-05-04 20:04:49 +02:00
Alejandro García
d17749110a
Merge pull request #6670 from jmacxx/trade_fee_leniency
Allow leniency of 50% when validating trade fees.
2023-05-04 05:59:13 +00:00
HenrikJannsen
35f69232fd
Increase fee limit for accounting data filter.
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-02 09:59:23 +07:00
jmacxx
8c05af1f0a
Allow leniency of 50% when validating trade fees. Issue #6669. 2023-04-30 14:04:03 -05:00
wiz
4df4c4bc3a
Update clearnet IPs for wiz's Bitcoin nodes 2023-04-19 17:21:13 +09:00
Gabriel Bernard
caab3dbe55
Merge pull request #6649 from bisq-network/release/v1.9.10
Release/v1.9.10
2023-04-17 08:15:12 +00:00
Alva Swanson
d969d497bb
OfferUtilTest: Remove broken testGetRandomOfferId test 2023-04-17 17:00:29 +10:00
Alejandro García
bfad06caae
Merge pull request #6647 from HenrikJannsen/show_total_distributed_btc_fees
Show total fees and total DPT
2023-04-15 02:32:21 +00:00
Alejandro García
e8a3d92d34
Merge pull request #6646 from helixx87/api-get-all
Support "all" attribute in getoffers API method
2023-04-15 02:31:02 +00:00
HenrikJannsen
1416b946a8
Add fields for total BTC fees and total DPT amounts
Add more data to CSV export

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-04-12 16:17:44 +07:00
helixx87
458f50dec9
Support "all" attribute in getoffers API method 2023-04-11 12:50:00 +02:00
HenrikJannsen
795964f06b
Add info if burningman accounting data processing is disabled or if it is in progress.
We use a postfix to the header title and not a busy animation, as the busy animation is quite CPU intense.

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-04-10 16:01:13 +07:00
HenrikJannsen
25fa962e5e
Enable processing of accounting data only if option in preferences is set.
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-04-10 14:52:45 +07:00
HenrikJannsen
cec05e13f9
Add toggle to PreferencesView
Add popup when selecting a burningman to ask for enabling processing

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-04-10 14:49:47 +07:00
HenrikJannsen
fb5b56d03c
Add processBurningManAccountingData field to preferences
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-04-10 14:38:37 +07:00
HenrikJannsen
874f6b4aa5
Add more validations
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-04-04 16:58:25 +10:00
Alejandro García
29c9e0077b
Merge pull request #6608 from helixx87/offer-util-test
Tests for OfferUtil
2023-04-04 06:54:36 +00:00
Alejandro García
2669d736b6
Merge pull request #6631 from alejandrogarcia83/update-data-stores-for-v1.9.10
Update data stores for v1.9.10
2023-04-04 06:53:23 +00:00
Alejandro García
f49be9ab3c
Merge pull request #6632 from HenrikJannsen/improve_validations
Add more validations
2023-04-04 06:52:47 +00:00
yonson2023
8e43f15114
Code review changes. 2023-04-03 11:45:18 +10:00
yonson2023
ce4bae99bb
Move knaccc test module to core/xmr. 2023-04-03 11:45:11 +10:00
yonson2023
2ec4dd256d
Check private view key is a valid scalar. 2023-04-03 11:45:05 +10:00
yonson2023
5f54905c71
Validate that XMR subaddress view key matches the main address. 2023-04-03 11:44:43 +10:00
Alejandro García
00c43196a3
Merge pull request #6612 from yonson2023/check_xmr_subaddress
Validate that XMR subaddress view key matches the main address
2023-04-03 01:38:39 +00:00
Alejandro García
1b6547b0c4
Update bitcoinj checkpoints for v1.9.10 2023-04-03 10:41:29 +10:00
Alejandro García
b5298fb848
Update translations for v1.9.10 2023-04-02 11:11:20 +10:00
HenrikJannsen
ee83607225
Add total received BTC field
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-03-31 19:47:34 +07:00
HenrikJannsen
aa5de89ee2
Add total revenue to burningman details.
We do not add a column to the overview table because calculating the balance entries is expensive and doing it over all burningmen would take too long. There is headroom for performance improvements in that area...

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-03-31 18:17:53 +07:00
HenrikJannsen
5165a1299e
Add more validations
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-03-31 15:07:24 +07:00
yonson2023
0e2b13924b
Code review changes. 2023-03-29 10:37:43 -05:00
yonson2023
3878a9f564
Move knaccc test module to core/xmr. 2023-03-29 10:35:35 -05:00
Christoph Atteneder
cf56ae316e
Merge pull request #6597 from jmacxx/support_ui_improvements
Support UI improvements
2023-03-27 13:46:20 +02:00
yonson2023
165f2d000a
Check private view key is a valid scalar. 2023-03-26 18:36:12 -05:00
jmacxx
9feccb6b46
BSQ trade fee validation NACK if tx unconfirmed for a long time. 2023-03-23 12:19:12 -05:00