mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-27 02:26:44 +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;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyLabels(WalletNode pastNode) {
|
public boolean copyLabels(WalletNode pastNode) {
|
||||||
if(pastNode == null) {
|
if(pastNode == null) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
if(label == null && pastNode.label != null) {
|
if(label == null && pastNode.label != null) {
|
||||||
label = pastNode.label;
|
label = pastNode.label;
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(BlockTransactionHashIndex txo : getTransactionOutputs()) {
|
for(BlockTransactionHashIndex txo : getTransactionOutputs()) {
|
||||||
|
@ -223,16 +226,22 @@ public class WalletNode implements Comparable<WalletNode> {
|
||||||
BlockTransactionHashIndex pastTxo = optPastTxo.get();
|
BlockTransactionHashIndex pastTxo = optPastTxo.get();
|
||||||
if(txo.getLabel() == null && pastTxo.getLabel() != null) {
|
if(txo.getLabel() == null && pastTxo.getLabel() != null) {
|
||||||
txo.setLabel(pastTxo.getLabel());
|
txo.setLabel(pastTxo.getLabel());
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
if(txo.isSpent() && pastTxo.isSpent() && txo.getSpentBy().getLabel() == null && pastTxo.getSpentBy().getLabel() != null) {
|
if(txo.isSpent() && pastTxo.isSpent() && txo.getSpentBy().getLabel() == null && pastTxo.getSpentBy().getLabel() != null) {
|
||||||
txo.getSpentBy().setLabel(pastTxo.getSpentBy().getLabel());
|
txo.getSpentBy().setLabel(pastTxo.getSpentBy().getLabel());
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(WalletNode childNode : getChildren()) {
|
for(WalletNode childNode : getChildren()) {
|
||||||
Optional<WalletNode> optPastChildNode = pastNode.getChildren().stream().filter(node -> node.equals(childNode)).findFirst();
|
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