mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(core): fix bootstrapping
This commit is contained in:
parent
a8494980da
commit
e56ee4a134
|
@ -203,6 +203,9 @@ ToxCorePtr Core::makeToxCore(const QByteArray &savedata, const ICoreSettings * c
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// provide a list of bootstrap nodes
|
||||||
|
core->bootstrapNodes = settings->getDhtServerList();
|
||||||
|
|
||||||
qsrand(time(nullptr)); // TODO(sudden6): needed?
|
qsrand(time(nullptr)); // TODO(sudden6): needed?
|
||||||
// tox should be valid by now
|
// tox should be valid by now
|
||||||
assert(core->tox != nullptr);
|
assert(core->tox != nullptr);
|
||||||
|
@ -349,9 +352,7 @@ bool Core::checkConnection()
|
||||||
*/
|
*/
|
||||||
void Core::bootstrapDht()
|
void Core::bootstrapDht()
|
||||||
{
|
{
|
||||||
// TODO(sudden6): fix bootstrapping
|
int listSize = bootstrapNodes.size();
|
||||||
QList<DhtServer> dhtServerList{};// = s->getDhtServerList();
|
|
||||||
int listSize = dhtServerList.size();
|
|
||||||
if (!listSize) {
|
if (!listSize) {
|
||||||
qWarning() << "no bootstrap list?!?";
|
qWarning() << "no bootstrap list?!?";
|
||||||
return;
|
return;
|
||||||
|
@ -361,7 +362,7 @@ void Core::bootstrapDht()
|
||||||
static int j = qrand() % listSize;
|
static int j = qrand() % listSize;
|
||||||
// i think the more we bootstrap, the more we jitter because the more we overwrite nodes
|
// i think the more we bootstrap, the more we jitter because the more we overwrite nodes
|
||||||
while (i < 2) {
|
while (i < 2) {
|
||||||
const DhtServer& dhtServer = dhtServerList[j % listSize];
|
const DhtServer& dhtServer = bootstrapNodes[j % listSize];
|
||||||
QString dhtServerAddress = dhtServer.address.toLatin1();
|
QString dhtServerAddress = dhtServer.address.toLatin1();
|
||||||
QString port = QString::number(dhtServer.port);
|
QString port = QString::number(dhtServer.port);
|
||||||
QString name = dhtServer.name;
|
QString name = dhtServer.name;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "toxid.h"
|
#include "toxid.h"
|
||||||
|
|
||||||
#include <tox/tox.h>
|
#include <tox/tox.h>
|
||||||
|
#include "src/core/dhtserver.h"
|
||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -258,6 +259,7 @@ private:
|
||||||
QMutex messageSendMutex;
|
QMutex messageSendMutex;
|
||||||
|
|
||||||
QThread* coreThread = nullptr;
|
QThread* coreThread = nullptr;
|
||||||
|
QList<DhtServer> bootstrapNodes{};
|
||||||
|
|
||||||
friend class Audio; ///< Audio can access our calls directly to reduce latency
|
friend class Audio; ///< Audio can access our calls directly to reduce latency
|
||||||
friend class CoreFile; ///< CoreFile can access tox* and emit our signals
|
friend class CoreFile; ///< CoreFile can access tox* and emit our signals
|
||||||
|
|
Loading…
Reference in New Issue
Block a user