mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
correct handling of nodeTransactionMap empty map references
This commit is contained in:
parent
76e148a107
commit
4c58ebf138
1 changed files with 4 additions and 4 deletions
|
@ -158,17 +158,17 @@ public class ElectrumServer {
|
|||
gapLimitSize = getGapLimitSize(wallet, nodeTransactionMap);
|
||||
}
|
||||
|
||||
//All WalletNode keys in nodeTransactionMap with non-null values need to have their history fetched
|
||||
Collection<WalletNode> usedNodes = nodeTransactionMap.entrySet().stream().filter(entry -> entry.getValue() != null).map(Map.Entry::getKey).collect(Collectors.toList());
|
||||
//All WalletNode keys in nodeTransactionMap need to have their history fetched
|
||||
Collection<WalletNode> usedNodes = new ArrayList<>(nodeTransactionMap.keySet());
|
||||
log.debug("Retrieving history for " + usedNodes.stream().map(WalletNode::getDerivationPath).collect(Collectors.joining(", ")));
|
||||
getReferences(wallet, usedNodes, nodeTransactionMap);
|
||||
|
||||
//Set the remaining WalletNode keys to empty sets to indicate no history
|
||||
nodeTransactionMap.entrySet().stream().filter(entry -> entry.getValue() == null).forEach(entry -> entry.setValue(Collections.emptySet()));
|
||||
purposeNode.getChildren().stream().filter(node -> !nodeTransactionMap.containsKey(node)).forEach(node -> nodeTransactionMap.put(node, Collections.emptySet()));
|
||||
}
|
||||
|
||||
private int getGapLimitSize(Wallet wallet, Map<WalletNode, Set<BlockTransactionHash>> nodeTransactionMap) {
|
||||
int highestIndex = nodeTransactionMap.entrySet().stream().filter(entry -> !entry.getValue().isEmpty()).map(entry -> entry.getKey().getIndex()).max(Comparator.comparing(Integer::valueOf)).orElse(-1);
|
||||
int highestIndex = nodeTransactionMap.keySet().stream().map(WalletNode::getIndex).max(Comparator.comparing(Integer::valueOf)).orElse(-1);
|
||||
return highestIndex + wallet.getGapLimit() + 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue