Commit Graph

7106 Commits

Author SHA1 Message Date
jmacxx
9bc99f516a
Cleanup, SEPA instant countries same as SEPA. 2023-06-03 16:36:49 -05:00
jmacxx
ea2a4e57b2
Add Gibraltar (GI) to list of SEPA countries. 2023-06-03 16:26:26 -05:00
Gabriel Bernard
f4368b3185
Merge pull request #6675 from HenrikJannsen/clone_offer_with_shared_maker_fee
Add feature for cloning an offer with shared maker fee
2023-05-25 11:08:08 +00:00
HenrikJannsen
93ba24aabb
Exclude mostRecentAddress from EqualsAndHashCode
The getter was called by EqualsAndHashCode which throws an exception as it is is not intended to get used anymore.

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-25 00:52:53 +02:00
Alejandro García
ad2908b2fc
Merge pull request #6702 from HenrikJannsen/cleanup_date_check
Remove date check
2023-05-23 09:05:09 +00:00
Alejandro García
91e10d4970
Merge pull request #6701 from HenrikJannsen/remove_activation_date_for_distributed_BM
Remove BurningManService.isActivated and apply changed to client code.
2023-05-23 09:04:25 +00:00
HenrikJannsen
114af3fef4
Add link to wiki
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-21 19:33:50 +02:00
HenrikJannsen
3cd164588c
Remove USE_FEE_FROM_FILTER_ACTIVATION_DATE and new Date().before(USE_FEE_FROM_FILTER_ACTIVATION_DATE) as it would always be false
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-17 13:42:08 +07:00
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
HenrikJannsen
92f1c86687
Change activation date to July 15th
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-17 13:10:26 +07:00
HenrikJannsen
bf325938d5
Add getMostRecentAddress with throwing a UnsupportedOperationException to make sure the old field is not used anymore from any client.
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-17 13:08:34 +07:00
HenrikJannsen
95023216ec
Use new getReceiverAddress methods instead of getMostRecentAddress
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-17 13:05:36 +07:00
HenrikJannsen
7253411b79
Add new field receiverAddress to BurningManCandidate.
Implement new selection algorithm.
Add methods for accessing the receiverAddress (not used yet, but will be used in next commits)

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-17 12:58:40 +07:00
HenrikJannsen
694e101646
Add isCustomAddress to CompensationModel
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-17 12:54:56 +07:00
HenrikJannsen
6a649416c2
Refactor code for assigning address for better to make it more clear when we use the custom address and when the change address.
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-17 12:53:59 +07:00
HenrikJannsen
658a01e5ae
Refactoring: Rename HOTFIX_ACTIVATION_DATE to BUGFIX_6699_ACTIVATION_DATE,
isHotfixActivated to isBugfix6699Activated,
wasHotfixActivatedAtTradeDate to wasBugfix6699ActivatedAtTradeDate

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-17 12:45:26 +07:00
HenrikJannsen
23156a3286
Remove handling of isHotfixActivated in getReceivers method.
We still keep the parameter as it will be reused later for the new bugfix

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-17 12:41:17 +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
HenrikJannsen
4262e91f1f
Reapply original code from @jmacxx in AddressEntryList
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-13 22:45:39 +07: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
HenrikJannsen
60fad3ab6c
Fix incorrect filtering of offers with shared maker fee
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-10 11:42:00 +07:00
Alva Swanson
734650d43e
core: Fix broken PriceTest.testParse test
Relates to #6619
2023-05-09 21:23:18 +10:00
HenrikJannsen
2651a88d5e
Do not reset addressEntries if its from cloned offers at cleanUpAddressEntries
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-05 19:42:08 +07:00
HenrikJannsen
d42895637f
Publish cloned offer if activated
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-05 14:19:31 +07:00
HenrikJannsen
21672a1bd0
Add clone offer tab
Change flow of cloning an offer:
We open the clone offer tab similar like the duplicate/edit offer tab. When clicking the clone button we create and publish the cloned offer. if the clone would not have changed the payment method/currency we show a popup and deactivate the offer.
At editOffer we check if the offer is using a shared maker fee and if so we check if the edit triggered same payment method/currency. If so we show a popup and deactivate the offer.

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-05 13:34:03 +07:00
HenrikJannsen
4ae89e748c
Use link icon for cloned offers
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-05 11:11:58 +07:00
HenrikJannsen
384173c894
Rename translation string
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-05 10:01:57 +07:00
HenrikJannsen
a621973eed
Add translation string
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-05 09:41:05 +07:00
HenrikJannsen
8b91ed7a00
Only reset if there are no other shared maker fee offers
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-05 09:33:35 +07:00
napoly
e19ffe2308
Upgrade JUnit4 to JUnit5 Jupiter 2023-05-04 20:04:49 +02:00
HenrikJannsen
3403b1662c
User maker fee as column name (instead of group)
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-04 20:10:38 +07:00
HenrikJannsen
992854c9b9
Various refactorings and changes
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-04 18:31:20 +07:00
HenrikJannsen
cadf2073cf
Fix updateReservedBalance.
btcWalletService.getAddressEntriesForOpenOffer() contains also OFFER_FUNDING entries.
This version minimizes the change by mapping to address and use distinct to avoid duplicate entries to be summed up.

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-04 18:31:19 +07:00
HenrikJannsen
f6c31aa479
Remove added code with entryWithSameContextStillExists as it is not needed.
Multiple calls will call add on the hashset but as the entry is the same it will not trigger any change of the hashset.

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-04 18:31:18 +07:00
HenrikJannsen
966b9d8448
Add getAllRecentTransactions method.
The numTransactions param in getRecentTransactions delivers all transactions if it is 0 but that is not intuitive. Passing Integer.MAX_VALUE makes more sense.

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2023-05-04 18:31:18 +07:00
jmacxx
e66517fb8a
Code review changes.
Pick a more user friendly name instead of OCO.
Clean up code.
2023-05-04 18:31:16 +07:00
jmacxx
27dcec00e9
Code review changes. 2023-05-04 18:31:16 +07:00
jmacxx
1cc42aef77
Bug fix. 2023-05-04 18:31:15 +07:00