mirror of
https://github.com/Qortal/qortal.git
synced 2025-02-14 11:15:49 +00:00
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:
parent
522ae2bce7
commit
e71f22fd2c
@ -29,6 +29,7 @@ import org.bitcoinj.wallet.SendRequest;
|
|||||||
import org.bitcoinj.wallet.Wallet;
|
import org.bitcoinj.wallet.Wallet;
|
||||||
import org.qortal.api.model.SimpleForeignTransaction;
|
import org.qortal.api.model.SimpleForeignTransaction;
|
||||||
import org.qortal.crypto.Crypto;
|
import org.qortal.crypto.Crypto;
|
||||||
|
import org.qortal.settings.Settings;
|
||||||
import org.qortal.utils.Amounts;
|
import org.qortal.utils.Amounts;
|
||||||
import org.qortal.utils.BitTwiddling;
|
import org.qortal.utils.BitTwiddling;
|
||||||
|
|
||||||
@ -409,9 +410,6 @@ public abstract class Bitcoiny implements ForeignBlockchain {
|
|||||||
Set<BitcoinyTransaction> walletTransactions = new HashSet<>();
|
Set<BitcoinyTransaction> walletTransactions = new HashSet<>();
|
||||||
Set<String> keySet = 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 unusedCounter = 0;
|
||||||
int ki = 0;
|
int ki = 0;
|
||||||
do {
|
do {
|
||||||
@ -438,12 +436,12 @@ public abstract class Bitcoiny implements ForeignBlockchain {
|
|||||||
|
|
||||||
if (areAllKeysUnused) {
|
if (areAllKeysUnused) {
|
||||||
// No transactions
|
// No transactions
|
||||||
if (unusedCounter >= numberOfAdditionalBatchesToSearch) {
|
if (unusedCounter >= Settings.getInstance().getGapLimit()) {
|
||||||
// ... and we've hit our search limit
|
// ... and we've hit our search limit
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// We haven't hit our search limit yet so increment the counter and keep looking
|
// We haven't hit our search limit yet so increment the counter and keep looking
|
||||||
unusedCounter++;
|
unusedCounter += WALLET_KEY_LOOKAHEAD_INCREMENT;
|
||||||
} else {
|
} else {
|
||||||
// Some keys in this batch were used, so reset the counter
|
// Some keys in this batch were used, so reset the counter
|
||||||
unusedCounter = 0;
|
unusedCounter = 0;
|
||||||
|
@ -284,6 +284,13 @@ public class Settings {
|
|||||||
private Long testNtpOffset = null;
|
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 (QDN)
|
||||||
|
|
||||||
/** Data storage enabled/disabled*/
|
/** Data storage enabled/disabled*/
|
||||||
@ -872,6 +879,11 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getGapLimit() {
|
||||||
|
return this.gapLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isQdnEnabled() {
|
public boolean isQdnEnabled() {
|
||||||
return this.qdnEnabled;
|
return this.qdnEnabled;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user