forked from Qortal/qortal
Filter failed trade after 1 attempt
This commit is contained in:
parent
db7b17e52e
commit
404c5d0300
@ -712,30 +712,16 @@ public class TradeBot implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<byte[]> signatures = repository.getTransactionRepository().getSignaturesMatchingCriteria(null, null, null, Arrays.asList(Transaction.TransactionType.MESSAGE), null, null, crossChainTradeData.qortalCreatorTradeAddress, TransactionsResource.ConfirmationStatus.BOTH, null, null, null);
|
List<TransactionData> transactions = repository.getTransactionRepository().getUnconfirmedTransactions(Arrays.asList(Transaction.TransactionType.MESSAGE), null, null, null, null);
|
||||||
if (signatures.size() < getMaxTradeOfferAttempts) {
|
|
||||||
// Less than 3 (or user-specified number of) MESSAGE transactions relate to this trade, so assume it is ok
|
|
||||||
validTrades.put(crossChainTradeData.qortalAtAddress, now);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<TransactionData> transactions = new ArrayList<>(signatures.size());
|
for (TransactionData transactionData : transactions) {
|
||||||
for (byte[] signature : signatures) {
|
// Treat as failed if buy attempt was more than 60 mins ago (as it's still in the OFFERING state)
|
||||||
transactions.add(repository.getTransactionRepository().fromSignature(signature));
|
if (transactionData.getRecipient().equals(crossChainTradeData.qortalCreatorTradeAddress) && now - transactionData.getTimestamp() > 60*60*1000L) {
|
||||||
}
|
failedTrades.put(crossChainTradeData.qortalAtAddress, now);
|
||||||
transactions.sort(Transaction.getDataComparator());
|
updatedCrossChainTrades.remove(crossChainTradeData);
|
||||||
|
} else {
|
||||||
// Get timestamp of the first MESSAGE transaction
|
validTrades.put(crossChainTradeData.qortalAtAddress, now);
|
||||||
long firstMessageTimestamp = transactions.get(0).getTimestamp();
|
}
|
||||||
|
|
||||||
// Treat as failed if first buy attempt was more than 60 mins ago (as it's still in the OFFERING state)
|
|
||||||
boolean isFailed = (now - firstMessageTimestamp > 60*60*1000L);
|
|
||||||
if (isFailed) {
|
|
||||||
failedTrades.put(crossChainTradeData.qortalAtAddress, now);
|
|
||||||
updatedCrossChainTrades.remove(crossChainTradeData);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
validTrades.put(crossChainTradeData.qortalAtAddress, now);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
|
@ -75,6 +75,9 @@ public abstract class TransactionData {
|
|||||||
@Schema(description = "groupID for this transaction")
|
@Schema(description = "groupID for this transaction")
|
||||||
protected int txGroupId;
|
protected int txGroupId;
|
||||||
|
|
||||||
|
@Schema(description = "recipient for this transaction")
|
||||||
|
protected String recipient;
|
||||||
|
|
||||||
// Not always present
|
// Not always present
|
||||||
@Schema(accessMode = AccessMode.READ_ONLY, hidden = true, description = "height of block containing transaction")
|
@Schema(accessMode = AccessMode.READ_ONLY, hidden = true, description = "height of block containing transaction")
|
||||||
protected Integer blockHeight;
|
protected Integer blockHeight;
|
||||||
@ -105,7 +108,7 @@ public abstract class TransactionData {
|
|||||||
/** Constructor for use by transaction subclasses. */
|
/** Constructor for use by transaction subclasses. */
|
||||||
protected TransactionData(TransactionType type, BaseTransactionData baseTransactionData) {
|
protected TransactionData(TransactionType type, BaseTransactionData baseTransactionData) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.recipient = baseTransactionData.recipient;
|
||||||
this.timestamp = baseTransactionData.timestamp;
|
this.timestamp = baseTransactionData.timestamp;
|
||||||
this.txGroupId = baseTransactionData.txGroupId;
|
this.txGroupId = baseTransactionData.txGroupId;
|
||||||
this.reference = baseTransactionData.reference;
|
this.reference = baseTransactionData.reference;
|
||||||
@ -136,6 +139,10 @@ public abstract class TransactionData {
|
|||||||
return this.txGroupId;
|
return this.txGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRecipient() {
|
||||||
|
return this.recipient;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTxGroupId(int txGroupId) {
|
public void setTxGroupId(int txGroupId) {
|
||||||
this.txGroupId = txGroupId;
|
this.txGroupId = txGroupId;
|
||||||
}
|
}
|
||||||
@ -250,5 +257,4 @@ public abstract class TransactionData {
|
|||||||
|
|
||||||
return Arrays.equals(this.signature, otherTransactionData.signature);
|
return Arrays.equals(this.signature, otherTransactionData.signature);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user