synchronize on wallet during restart
This commit is contained in:
parent
2b84c44ef7
commit
290912c333
1 changed files with 18 additions and 6 deletions
|
@ -840,8 +840,10 @@ public class XmrWalletService {
|
||||||
if (wallet == null) maybeInitMainWallet();
|
if (wallet == null) maybeInitMainWallet();
|
||||||
else if (wallet instanceof MoneroWalletRpc && !StringUtils.equals(oldProxyUri, newProxyUri)) {
|
else if (wallet instanceof MoneroWalletRpc && !StringUtils.equals(oldProxyUri, newProxyUri)) {
|
||||||
log.info("Restarting main wallet since proxy URI has changed");
|
log.info("Restarting main wallet since proxy URI has changed");
|
||||||
closeMainWallet(true);
|
synchronized (wallet) {
|
||||||
maybeInitMainWallet();
|
closeMainWallet(true);
|
||||||
|
maybeInitMainWallet();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
wallet.setDaemonConnection(connection);
|
wallet.setDaemonConnection(connection);
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
|
@ -1126,19 +1128,29 @@ public class XmrWalletService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigInteger getBalanceForSubaddress(int subaddressIndex) {
|
public BigInteger getBalanceForSubaddress(int subaddressIndex) {
|
||||||
return wallet.getBalance(0, subaddressIndex);
|
synchronized (wallet) {
|
||||||
|
return wallet.getBalance(0, subaddressIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigInteger getAvailableBalanceForSubaddress(int subaddressIndex) {
|
public BigInteger getAvailableBalanceForSubaddress(int subaddressIndex) {
|
||||||
return wallet.getUnlockedBalance(0, subaddressIndex);
|
synchronized (wallet) {
|
||||||
|
return wallet.getUnlockedBalance(0, subaddressIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigInteger getBalance() {
|
public BigInteger getBalance() {
|
||||||
return wallet != null ? wallet.getBalance(0) : BigInteger.valueOf(0);
|
if (wallet == null) return BigInteger.valueOf(0);
|
||||||
|
synchronized (wallet) {
|
||||||
|
return wallet.getBalance(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigInteger getAvailableBalance() {
|
public BigInteger getAvailableBalance() {
|
||||||
return wallet != null ? wallet.getUnlockedBalance(0) : BigInteger.valueOf(0);
|
if (wallet == null) return BigInteger.valueOf(0);
|
||||||
|
synchronized (wallet) {
|
||||||
|
return wallet.getUnlockedBalance(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream<XmrAddressEntry> getAddressEntriesForAvailableBalanceStream() {
|
public Stream<XmrAddressEntry> getAddressEntriesForAvailableBalanceStream() {
|
||||||
|
|
Loading…
Reference in a new issue