mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-23 20:36:44 +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.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());
|
||||
EventManager.get().post(new ConnectionFailedEvent(failEvent.getSource().getException()));
|
||||
});
|
||||
|
|
|
@ -3,7 +3,9 @@ package com.sparrowwallet.sparrow.net;
|
|||
public enum PublicElectrumServer {
|
||||
BLOCKSTREAM_INFO("blockstream.info", "ssl://blockstream.info:700"),
|
||||
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) {
|
||||
this.name = name;
|
||||
|
|
|
@ -215,6 +215,11 @@ public class TransactionsController extends WalletFormController implements Init
|
|||
walletHistoryStatus(new WalletHistoryStatusEvent(walletForm.getWallet(), false));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void connectionFailed(ConnectionFailedEvent event) {
|
||||
walletHistoryStatus(new WalletHistoryStatusEvent(walletForm.getWallet(), false));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void walletUtxoStatusChanged(WalletUtxoStatusChangedEvent event) {
|
||||
if(event.getWallet().equals(getWalletForm().getWallet())) {
|
||||
|
|
|
@ -77,6 +77,8 @@
|
|||
<PublicElectrumServer fx:constant="BLOCKSTREAM_INFO" />
|
||||
<PublicElectrumServer fx:constant="ELECTRUM_BLOCKSTREAM_INFO" />
|
||||
<PublicElectrumServer fx:constant="LUKECHILDS_CO" />
|
||||
<PublicElectrumServer fx:constant="EMZY_DE" />
|
||||
<PublicElectrumServer fx:constant="BITAROO_NET" />
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ComboBox>
|
||||
|
|
Loading…
Reference in a new issue