mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-26 18:16:45 +00:00
return boolean if labels have changed
This commit is contained in:
parent
08acfe5ba1
commit
faa8f71313
1 changed files with 12 additions and 3 deletions
|
@ -208,13 +208,16 @@ public class WalletNode implements Comparable<WalletNode> {
|
|||
return copy;
|
||||
}
|
||||
|
||||
public void copyLabels(WalletNode pastNode) {
|
||||
public boolean copyLabels(WalletNode pastNode) {
|
||||
if(pastNode == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
if(label == null && pastNode.label != null) {
|
||||
label = pastNode.label;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
for(BlockTransactionHashIndex txo : getTransactionOutputs()) {
|
||||
|
@ -223,16 +226,22 @@ public class WalletNode implements Comparable<WalletNode> {
|
|||
BlockTransactionHashIndex pastTxo = optPastTxo.get();
|
||||
if(txo.getLabel() == null && pastTxo.getLabel() != null) {
|
||||
txo.setLabel(pastTxo.getLabel());
|
||||
changed = true;
|
||||
}
|
||||
if(txo.isSpent() && pastTxo.isSpent() && txo.getSpentBy().getLabel() == null && pastTxo.getSpentBy().getLabel() != null) {
|
||||
txo.getSpentBy().setLabel(pastTxo.getSpentBy().getLabel());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(WalletNode childNode : getChildren()) {
|
||||
Optional<WalletNode> optPastChildNode = pastNode.getChildren().stream().filter(node -> node.equals(childNode)).findFirst();
|
||||
optPastChildNode.ifPresent(childNode::copyLabels);
|
||||
if(optPastChildNode.isPresent()) {
|
||||
changed |= childNode.copyLabels(optPastChildNode.get());
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue