mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-22 20:26:50 +00:00
Fix some asset orders incorrectly matching worse prices.
This commit is contained in:
@@ -340,9 +340,17 @@ public class Order {
|
||||
LOGGER.trace(String.format("Their price: %s %s per %s", theirPrice.toPlainString(), wantAssetData.getName(), haveAssetData.getName()));
|
||||
}
|
||||
|
||||
// If their buyingPrice is less than what we're willing to accept then we're done as prices only get worse as we iterate through list of orders
|
||||
if (theirPrice.compareTo(ourPrice) < 0)
|
||||
break;
|
||||
// If their price is worse than what we're willing to accept then we're done as prices only get worse as we iterate through list of orders
|
||||
if (isOurOrderNewPricing) {
|
||||
if (haveAssetId < wantAssetId && theirPrice.compareTo(ourPrice) > 0)
|
||||
break;
|
||||
if (haveAssetId > wantAssetId && theirPrice.compareTo(ourPrice) < 0)
|
||||
break;
|
||||
} else {
|
||||
// 'old' pricing scheme
|
||||
if (theirPrice.compareTo(ourPrice) < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
// Calculate how much we could buy at their price.
|
||||
BigDecimal ourMaxAmount;
|
||||
|
@@ -284,11 +284,21 @@ public class HSQLDBAssetRepository implements AssetRepository {
|
||||
Collections.addAll(bindParams, haveAssetId, wantAssetId);
|
||||
|
||||
if (minimumPrice != null) {
|
||||
sql += "AND price >= ? ";
|
||||
// 'new' pricing scheme implied
|
||||
// NOTE: haveAssetId and wantAssetId are for TARGET orders, so different from Order.process() caller
|
||||
if (haveAssetId < wantAssetId)
|
||||
sql += "AND price >= ? ";
|
||||
else
|
||||
sql += "AND price <= ? ";
|
||||
|
||||
bindParams.add(minimumPrice);
|
||||
}
|
||||
|
||||
sql += "ORDER BY price DESC, ordered";
|
||||
sql += "ORDER BY price";
|
||||
if (minimumPrice == null || haveAssetId < wantAssetId)
|
||||
sql += " DESC";
|
||||
|
||||
sql += ", ordered";
|
||||
|
||||
List<OrderData> orders = new ArrayList<OrderData>();
|
||||
|
||||
|
Reference in New Issue
Block a user