mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-02 18:26:43 +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) {
|
||||
//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<>();
|
||||
for(int i = 0; i <= index; i++) {
|
||||
WalletNode node = new WalletNode(wallet, getKeyPurpose(), i);
|
||||
|
|
Loading…
Reference in a new issue