mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-25 17:46:44 +00:00
improve performance of wallet transactions update
This commit is contained in:
parent
87b5f992d0
commit
6b89a0c5ea
1 changed files with 4 additions and 2 deletions
|
@ -421,8 +421,10 @@ public class Wallet extends Persistable implements Comparable<Wallet> {
|
||||||
public synchronized void updateTransactions(Map<Sha256Hash, BlockTransaction> updatedTransactions) {
|
public synchronized void updateTransactions(Map<Sha256Hash, BlockTransaction> updatedTransactions) {
|
||||||
for(BlockTransaction blockTx : updatedTransactions.values()) {
|
for(BlockTransaction blockTx : updatedTransactions.values()) {
|
||||||
if(!transactions.isEmpty()) {
|
if(!transactions.isEmpty()) {
|
||||||
Optional<String> optionalLabel = transactions.values().stream().filter(oldBlTx -> oldBlTx.getHash().equals(blockTx.getHash())).map(BlockTransaction::getLabel).filter(Objects::nonNull).findFirst();
|
BlockTransaction oldTx = transactions.get(blockTx.getHash());
|
||||||
optionalLabel.ifPresent(blockTx::setLabel);
|
if(oldTx != null && oldTx.getLabel() != null) {
|
||||||
|
blockTx.setLabel(oldTx.getLabel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!detachedLabels.isEmpty()) {
|
if(!detachedLabels.isEmpty()) {
|
||||||
|
|
Loading…
Reference in a new issue