various improvements

This commit is contained in:
Craig Raw 2020-06-19 15:35:29 +02:00
parent 601c11bd50
commit 81378b28b2
2 changed files with 15 additions and 7 deletions

View file

@ -13,7 +13,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class Wallet { public class Wallet {
private static final int DEFAULT_LOOKAHEAD = 20; public static final int DEFAULT_LOOKAHEAD = 20;
private String name; private String name;
private PolicyType policyType; private PolicyType policyType;
@ -75,10 +75,6 @@ public class Wallet {
return keystores; return keystores;
} }
public void setKeystores(List<Keystore> keystores) {
this.keystores = keystores;
}
private Set<WalletNode> getPurposeNodes() { private Set<WalletNode> getPurposeNodes() {
return purposeNodes; return purposeNodes;
} }
@ -113,7 +109,7 @@ public class Wallet {
int lookAhead = DEFAULT_LOOKAHEAD; int lookAhead = DEFAULT_LOOKAHEAD;
Integer highestUsed = node.getHighestUsedIndex(); Integer highestUsed = node.getHighestUsedIndex();
if(highestUsed != null) { if(highestUsed != null) {
lookAhead = Math.max(highestUsed + lookAhead/2, lookAhead); lookAhead = highestUsed + lookAhead;
} }
return lookAhead; return lookAhead;

View file

@ -157,7 +157,19 @@ public class WalletNode implements Comparable<WalletNode> {
@Override @Override
public int compareTo(WalletNode node) { public int compareTo(WalletNode node) {
return getIndex() - node.getIndex(); if(getDerivation().size() != node.getDerivation().size()) {
return getDerivation().size() - node.getDerivation().size();
}
for(int i = 0; i < getDerivation().size(); i++) {
ChildNumber thisChild = getDerivation().get(i);
ChildNumber nodeChild = node.getDerivation().get(i);
if(thisChild.num() != nodeChild.num()) {
return thisChild.num() - nodeChild.num();
}
}
return 0;
} }
public void clearHistory() { public void clearHistory() {