From f0a813d0316351777e3cb009489c0346e3ef3153 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 29 Oct 2021 14:39:51 +0200 Subject: [PATCH] handle concurrent modifications when saving address nodes --- .../java/com/sparrowwallet/sparrow/io/db/WalletNodeDao.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/io/db/WalletNodeDao.java b/src/main/java/com/sparrowwallet/sparrow/io/db/WalletNodeDao.java index 1dc0b65b..6d8a1c43 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/db/WalletNodeDao.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/db/WalletNodeDao.java @@ -11,6 +11,7 @@ import org.jdbi.v3.sqlobject.statement.SqlQuery; import org.jdbi.v3.sqlobject.statement.SqlUpdate; import org.jdbi.v3.sqlobject.statement.UseRowReducer; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -60,7 +61,8 @@ public interface WalletNodeDao { for(WalletNode purposeNode : wallet.getPurposeNodes()) { long purposeNodeId = insertWalletNode(purposeNode.getDerivationPath(), truncate(purposeNode.getLabel()), wallet.getId(), null); purposeNode.setId(purposeNodeId); - for(WalletNode addressNode : purposeNode.getChildren()) { + List childNodes = new ArrayList<>(purposeNode.getChildren()); + for(WalletNode addressNode : childNodes) { long addressNodeId = insertWalletNode(addressNode.getDerivationPath(), truncate(addressNode.getLabel()), wallet.getId(), purposeNodeId); addressNode.setId(addressNodeId); addTransactionOutputs(addressNode);