mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-26 01:56:44 +00:00
add performance optimization when requesting purpose node for deep wallets
This commit is contained in:
parent
6d0d5b7f62
commit
377843a4a5
1 changed files with 14 additions and 0 deletions
|
@ -205,6 +205,20 @@ public class WalletNode extends Persistable implements Comparable<WalletNode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Set<WalletNode> fillToIndex(int index) {
|
public synchronized Set<WalletNode> fillToIndex(int index) {
|
||||||
|
//Optimization to check if child nodes already monotonically increment to the desired index
|
||||||
|
int indexCheck = 0;
|
||||||
|
for(WalletNode childNode : getChildren()) {
|
||||||
|
if(childNode.index == indexCheck) {
|
||||||
|
indexCheck++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(childNode.index == index) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Set<WalletNode> newNodes = new TreeSet<>();
|
Set<WalletNode> newNodes = new TreeSet<>();
|
||||||
for(int i = 0; i <= index; i++) {
|
for(int i = 0; i <= index; i++) {
|
||||||
WalletNode node = new WalletNode(wallet, getKeyPurpose(), i);
|
WalletNode node = new WalletNode(wallet, getKeyPurpose(), i);
|
||||||
|
|
Loading…
Reference in a new issue