fix various refresh history issues when updating node sets

This commit is contained in:
Craig Raw 2022-03-04 10:36:47 +02:00
parent 001e368775
commit 7b3ff2a6d3
3 changed files with 10 additions and 6 deletions

2
drongo

@ -1 +1 @@
Subproject commit 0734757a177627600a63cb3347804ea126b0d417
Subproject commit 04631be8c10bf0ef72ebd7f7ef26254cccecb282

View file

@ -1303,6 +1303,11 @@ public class ElectrumServer {
return false;
}
Set<WalletNode> nodes = (filterToNodes == null ? null : filterToNodes.stream().filter(node -> node.getWallet().equals(wallet)).collect(Collectors.toSet()));
if(filterToNodes != null && nodes.isEmpty()) {
return false;
}
boolean initial = (walletSynchronizeLocks.putIfAbsent(wallet, new Object()) == null);
synchronized(walletSynchronizeLocks.get(wallet)) {
if(initial) {
@ -1311,7 +1316,6 @@ public class ElectrumServer {
if(isConnected()) {
ElectrumServer electrumServer = new ElectrumServer();
Set<WalletNode> nodes = (filterToNodes == null ? null : filterToNodes.stream().filter(node -> node.getWallet().equals(wallet)).collect(Collectors.toSet()));
Map<String, String> previousScriptHashes = getCalculatedScriptHashes(wallet);
Map<WalletNode, Set<BlockTransactionHash>> nodeTransactionMap = (nodes == null ? electrumServer.getHistory(wallet) : electrumServer.getHistory(wallet, nodes));

View file

@ -259,12 +259,12 @@ public class WalletForm {
}
private List<WalletNode> getHistoryChangedNodes(Set<WalletNode> previousNodes, Set<WalletNode> currentNodes) {
Map<WalletNode, WalletNode> previousNodeMap = new HashMap<>(previousNodes.size());
previousNodes.forEach(walletNode -> previousNodeMap.put(walletNode, walletNode));
Map<String, WalletNode> previousNodeMap = new HashMap<>(previousNodes.size());
previousNodes.forEach(walletNode -> previousNodeMap.put(walletNode.getDerivationPath(), walletNode));
List<WalletNode> changedNodes = new ArrayList<>();
for(WalletNode currentNode : currentNodes) {
WalletNode previousNode = previousNodeMap.get(currentNode);
WalletNode previousNode = previousNodeMap.get(currentNode.getDerivationPath());
if(previousNode != null) {
if(!currentNode.getTransactionOutputs().equals(previousNode.getTransactionOutputs())) {
changedNodes.add(currentNode);
@ -286,7 +286,7 @@ public class WalletForm {
return null;
}
Set<WalletNode> allNodes = new LinkedHashSet<>();
Set<WalletNode> allNodes = new LinkedHashSet<>(walletNodes);
for(WalletNode walletNode : walletNodes) {
for(Set<WalletNode> nodes : walletTransactionNodes) {
if(nodes.contains(walletNode)) {