mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-27 02:26:44 +00:00
highest used index
This commit is contained in:
parent
60a0d450e0
commit
d0a75fd268
2 changed files with 16 additions and 3 deletions
|
@ -105,7 +105,7 @@ public class Wallet {
|
||||||
public int getLookAhead(WalletNode node) {
|
public int getLookAhead(WalletNode node) {
|
||||||
//TODO: Calculate using seen transactions
|
//TODO: Calculate using seen transactions
|
||||||
int lookAhead = DEFAULT_LOOKAHEAD;
|
int lookAhead = DEFAULT_LOOKAHEAD;
|
||||||
Integer maxIndex = node.getHighestIndex();
|
Integer maxIndex = node.getHighestUsedIndex();
|
||||||
if(maxIndex != null) {
|
if(maxIndex != null) {
|
||||||
lookAhead = Math.max(maxIndex + lookAhead/2, lookAhead);
|
lookAhead = Math.max(maxIndex + lookAhead/2, lookAhead);
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,17 @@ public class Wallet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearHistory() {
|
||||||
|
for(WalletNode purposeNode : purposeNodes) {
|
||||||
|
purposeNode.getHistory().clear();
|
||||||
|
for(WalletNode addressNode : purposeNode.getChildren()) {
|
||||||
|
addressNode.getHistory().clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
if(policyType == null || scriptType == null || defaultPolicy == null || keystores.isEmpty()) {
|
if(policyType == null || scriptType == null || defaultPolicy == null || keystores.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -112,11 +112,13 @@ public class WalletNode implements Comparable<WalletNode> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getHighestIndex() {
|
public Integer getHighestUsedIndex() {
|
||||||
WalletNode highestNode = null;
|
WalletNode highestNode = null;
|
||||||
for(WalletNode childNode : getChildren()) {
|
for(WalletNode childNode : getChildren()) {
|
||||||
|
if(!childNode.getHistory().isEmpty()) {
|
||||||
highestNode = childNode;
|
highestNode = childNode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return highestNode == null ? null : highestNode.index;
|
return highestNode == null ? null : highestNode.index;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue