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