mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-26 01:56:44 +00:00
optimize retrieving unspent utxos
This commit is contained in:
parent
377843a4a5
commit
c4d2041a77
1 changed files with 6 additions and 1 deletions
|
@ -166,8 +166,13 @@ public class WalletNode extends Persistable implements Comparable<WalletNode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<BlockTransactionHashIndex> getUnspentTransactionOutputs(boolean includeSpentMempoolOutputs) {
|
public Set<BlockTransactionHashIndex> getUnspentTransactionOutputs(boolean includeSpentMempoolOutputs) {
|
||||||
|
if(transactionOutputs.isEmpty()) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
Set<BlockTransactionHashIndex> unspentTXOs = new TreeSet<>(transactionOutputs);
|
Set<BlockTransactionHashIndex> unspentTXOs = new TreeSet<>(transactionOutputs);
|
||||||
return unspentTXOs.stream().filter(txo -> !txo.isSpent() || (includeSpentMempoolOutputs && txo.getSpentBy().getHeight() <= 0)).collect(Collectors.toCollection(HashSet::new));
|
unspentTXOs.removeIf(txo -> txo.isSpent() && (!includeSpentMempoolOutputs || txo.getSpentBy().getHeight() > 0));
|
||||||
|
return unspentTXOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getUnspentValue() {
|
public long getUnspentValue() {
|
||||||
|
|
Loading…
Reference in a new issue