mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
add additional public servers, restart immediately on another when public server connection fails
This commit is contained in:
parent
9b6ef1f3ca
commit
d13bc8c313
4 changed files with 16 additions and 1 deletions
|
@ -209,6 +209,12 @@ public class AppServices {
|
||||||
onlineProperty.setValue(false);
|
onlineProperty.setValue(false);
|
||||||
onlineProperty.addListener(onlineServicesListener);
|
onlineProperty.addListener(onlineServicesListener);
|
||||||
|
|
||||||
|
if(Config.get().getServerType() == ServerType.PUBLIC_ELECTRUM_SERVER) {
|
||||||
|
List<String> otherServers = Arrays.stream(PublicElectrumServer.values()).map(PublicElectrumServer::getUrl).filter(url -> !url.equals(Config.get().getPublicElectrumServer())).collect(Collectors.toList());
|
||||||
|
Config.get().setPublicElectrumServer(otherServers.get(new Random().nextInt(otherServers.size())));
|
||||||
|
restartService(connectionService);
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("Connection failed", failEvent.getSource().getException());
|
log.debug("Connection failed", failEvent.getSource().getException());
|
||||||
EventManager.get().post(new ConnectionFailedEvent(failEvent.getSource().getException()));
|
EventManager.get().post(new ConnectionFailedEvent(failEvent.getSource().getException()));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,9 @@ package com.sparrowwallet.sparrow.net;
|
||||||
public enum PublicElectrumServer {
|
public enum PublicElectrumServer {
|
||||||
BLOCKSTREAM_INFO("blockstream.info", "ssl://blockstream.info:700"),
|
BLOCKSTREAM_INFO("blockstream.info", "ssl://blockstream.info:700"),
|
||||||
ELECTRUM_BLOCKSTREAM_INFO("electrum.blockstream.info", "ssl://electrum.blockstream.info:50002"),
|
ELECTRUM_BLOCKSTREAM_INFO("electrum.blockstream.info", "ssl://electrum.blockstream.info:50002"),
|
||||||
LUKECHILDS_CO("bitcoin.lukechilds.co", "ssl://bitcoin.lukechilds.co:50002");
|
LUKECHILDS_CO("bitcoin.lukechilds.co", "ssl://bitcoin.lukechilds.co:50002"),
|
||||||
|
EMZY_DE("electrum.emzy.de", "ssl://electrum.emzy.de:50002"),
|
||||||
|
BITAROO_NET("electrum.bitaroo.net", "ssl://electrum.bitaroo.net:50002");
|
||||||
|
|
||||||
PublicElectrumServer(String name, String url) {
|
PublicElectrumServer(String name, String url) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
|
@ -215,6 +215,11 @@ public class TransactionsController extends WalletFormController implements Init
|
||||||
walletHistoryStatus(new WalletHistoryStatusEvent(walletForm.getWallet(), false));
|
walletHistoryStatus(new WalletHistoryStatusEvent(walletForm.getWallet(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
private void connectionFailed(ConnectionFailedEvent event) {
|
||||||
|
walletHistoryStatus(new WalletHistoryStatusEvent(walletForm.getWallet(), false));
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void walletUtxoStatusChanged(WalletUtxoStatusChangedEvent event) {
|
public void walletUtxoStatusChanged(WalletUtxoStatusChangedEvent event) {
|
||||||
if(event.getWallet().equals(getWalletForm().getWallet())) {
|
if(event.getWallet().equals(getWalletForm().getWallet())) {
|
||||||
|
|
|
@ -77,6 +77,8 @@
|
||||||
<PublicElectrumServer fx:constant="BLOCKSTREAM_INFO" />
|
<PublicElectrumServer fx:constant="BLOCKSTREAM_INFO" />
|
||||||
<PublicElectrumServer fx:constant="ELECTRUM_BLOCKSTREAM_INFO" />
|
<PublicElectrumServer fx:constant="ELECTRUM_BLOCKSTREAM_INFO" />
|
||||||
<PublicElectrumServer fx:constant="LUKECHILDS_CO" />
|
<PublicElectrumServer fx:constant="LUKECHILDS_CO" />
|
||||||
|
<PublicElectrumServer fx:constant="EMZY_DE" />
|
||||||
|
<PublicElectrumServer fx:constant="BITAROO_NET" />
|
||||||
</FXCollections>
|
</FXCollections>
|
||||||
</items>
|
</items>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
|
|
Loading…
Reference in a new issue