mirror of
https://github.com/feather-wallet/feather.git
synced 2025-03-12 09:37:47 +00:00
Nodes: initSyncThreshold
This commit is contained in:
parent
58b927f9a3
commit
fba93e98fc
3 changed files with 27 additions and 2 deletions
|
@ -74,7 +74,8 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
|||
{Config::socks5Port, {QS("socks5Port"), "9050"}},
|
||||
{Config::socks5User, {QS("socks5User"), ""}}, // Unused
|
||||
{Config::socks5Pass, {QS("socks5Pass"), ""}}, // Unused
|
||||
{Config::useLocalTor, {QS("useLocalTor"), false}}
|
||||
{Config::useLocalTor, {QS("useLocalTor"), false}},
|
||||
{Config::initSyncThreshold, {QS("initSyncThreshold"), 360}}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
socks5User,
|
||||
socks5Pass,
|
||||
useLocalTor, // Prevents Feather from starting bundled Tor daemon
|
||||
initSyncThreshold
|
||||
};
|
||||
|
||||
enum PrivacyLevel {
|
||||
|
|
|
@ -359,10 +359,18 @@ void Nodes::setCustomNodes(const QList<FeatherNode> &nodes) {
|
|||
|
||||
void Nodes::onWalletRefreshed() {
|
||||
if (config()->get(Config::torPrivacyLevel).toInt() == Config::allTorExceptInitSync) {
|
||||
// Don't reconnect if we're connected to a local node (traffic will not be routed through Tor)
|
||||
if (m_connection.isLocal())
|
||||
return;
|
||||
|
||||
// Don't reconnect if we're already connected to an .onion node
|
||||
if (m_connection.isOnion())
|
||||
return;
|
||||
|
||||
// Don't reconnect on Tails or Whonix (all traffic is already routed through Tor)
|
||||
if (TailsOS::detect() || WhonixOS::detect())
|
||||
return;
|
||||
|
||||
this->autoConnect(true);
|
||||
}
|
||||
}
|
||||
|
@ -372,9 +380,24 @@ bool Nodes::useOnionNodes() {
|
|||
return true;
|
||||
}
|
||||
auto privacyLevel = config()->get(Config::torPrivacyLevel).toInt();
|
||||
if (privacyLevel == Config::allTor || (privacyLevel == Config::allTorExceptInitSync && m_ctx->refreshed)) {
|
||||
if (privacyLevel == Config::allTor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (privacyLevel == Config::allTorExceptInitSync) {
|
||||
if (m_ctx->refreshed)
|
||||
return true;
|
||||
|
||||
if (appData()->heights.contains(constants::networkType)) {
|
||||
int initSyncThreshold = config()->get(Config::initSyncThreshold).toInt();
|
||||
int networkHeight = appData()->heights[constants::networkType];
|
||||
|
||||
if (m_ctx->wallet->blockChainHeight() > (networkHeight - initSyncThreshold)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue