Misc networking fixes

- connecting to nodes is much faster and more reliable now
- reduced the amount of spaghetti in libwalletqt and greatly simplified the logic in nodes.cpp
- Settings -> Node dialog should feel slightly more responsive
- during synchronization the status bar will now display the amount of data downloaded
- fixed some edge cases that could cause unreasonably long hangs
- Help -> Debug Info screen now auto-updates every 5 seconds
- Don't use SSL over Tor
This commit is contained in:
tobtoht
2020-11-23 17:57:42 +01:00
parent c8bc66a287
commit 5a08bc353e
21 changed files with 325 additions and 278 deletions
+20 -2
View File
@@ -541,9 +541,8 @@ QFont Utils::relativeFont(int delta) {
double Utils::roundSignificant(double N, double n)
{
int h;
double l, a, b, c, d, e, i, j, m, f, g;
double b, d, e, i, j, m, f;
b = N;
c = floor(N);
for (i = 0; b >= 1; ++i)
b = b / 10;
@@ -564,3 +563,22 @@ double Utils::roundSignificant(double N, double n)
j = j / m;
return j;
}
QString Utils::formatBytes(quint64 bytes)
{
QVector<QString> sizes = { "B", "KB", "MB", "GB", "TB" };
int i;
double _data;
for (i = 0; i < sizes.count() && bytes >= 1000; i++, bytes /= 1000)
_data = bytes / 1000.0;
if (_data < 0)
_data = 0;
// unrealistic
if (_data > 1000)
_data = 0;
return QString("%1 %2").arg(QString::number(_data, 'f', 1), sizes[i]);
}