Added "gapLimit" setting.

This replaces the previously hardcoded "numberOfAdditionalBatchesToSearch" variable, and specifies the minimum number of empty consecutive addresses required before a set of wallet transactions is considered complete. Used for foreign transaction lists and balances.
This commit is contained in:
CalDescent 2022-07-31 11:59:14 +01:00
parent 522ae2bce7
commit e71f22fd2c
2 changed files with 15 additions and 5 deletions

View File

@ -29,6 +29,7 @@ import org.bitcoinj.wallet.SendRequest;
import org.bitcoinj.wallet.Wallet;
import org.qortal.api.model.SimpleForeignTransaction;
import org.qortal.crypto.Crypto;
import org.qortal.settings.Settings;
import org.qortal.utils.Amounts;
import org.qortal.utils.BitTwiddling;
@ -409,9 +410,6 @@ public abstract class Bitcoiny implements ForeignBlockchain {
Set<BitcoinyTransaction> walletTransactions = new HashSet<>();
Set<String> keySet = new HashSet<>();
// Set the number of consecutive empty batches required before giving up
final int numberOfAdditionalBatchesToSearch = 7;
int unusedCounter = 0;
int ki = 0;
do {
@ -438,12 +436,12 @@ public abstract class Bitcoiny implements ForeignBlockchain {
if (areAllKeysUnused) {
// No transactions
if (unusedCounter >= numberOfAdditionalBatchesToSearch) {
if (unusedCounter >= Settings.getInstance().getGapLimit()) {
// ... and we've hit our search limit
break;
}
// We haven't hit our search limit yet so increment the counter and keep looking
unusedCounter++;
unusedCounter += WALLET_KEY_LOOKAHEAD_INCREMENT;
} else {
// Some keys in this batch were used, so reset the counter
unusedCounter = 0;

View File

@ -284,6 +284,13 @@ public class Settings {
private Long testNtpOffset = null;
/* Foreign chains */
/** Set the number of consecutive empty addresses required before treating a wallet's transaction set as complete */
private int gapLimit = 24;
// Data storage (QDN)
/** Data storage enabled/disabled*/
@ -872,6 +879,11 @@ public class Settings {
}
public int getGapLimit() {
return this.gapLimit;
}
public boolean isQdnEnabled() {
return this.qdnEnabled;
}