Skip to content

Commit

Permalink
refactor(bootstrap): Store public key as ToxPk rather than QString
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonybilinski committed Feb 21, 2022
1 parent e7e30ad commit 7aa8d71
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,7 @@ void Core::bootstrapDht()
address = dhtServer.ipv4.toLatin1();
}

ToxPk pk{dhtServer.userId};
const uint8_t* pkPtr = pk.getData();
const uint8_t* pkPtr = dhtServer.publicKey.getData();

Tox_Err_Bootstrap error;
if (dhtServer.statusUdp) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/dhtserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool DhtServer::operator==(const DhtServer& other) const
&& ipv4 == other.ipv4
&& ipv6 == other.ipv6
&& maintainer == other.maintainer
&& userId == other.userId
&& publicKey == other.publicKey
&& udpPort == other.udpPort
&& tcpPorts == other.tcpPorts);
}
Expand Down
4 changes: 3 additions & 1 deletion src/core/dhtserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#pragma once

#include "toxpk.h"

#include <QString>
#include <vector>

Expand All @@ -29,7 +31,7 @@ struct DhtServer
QString ipv4;
QString ipv6;
QString maintainer;
QString userId;
ToxPk publicKey;
quint16 udpPort;
std::vector<uint16_t> tcpPorts;

Expand Down
6 changes: 4 additions & 2 deletions src/net/bootstrapnodeupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "bootstrapnodeupdater.h"

#include "src/persistence/paths.h"
#include "src/core/toxpk.h"
#include "src/core/toxid.h"

#include <QDirIterator>
#include <QFile>
Expand Down Expand Up @@ -120,7 +122,7 @@ void jsonNodeToDhtServer(const QJsonObject& node, QList<DhtServer>& outList)
server.statusUdp = true;
server.statusTcp = status_tcp;
server.tcpPorts = tcp_ports;
server.userId = public_key;
server.publicKey = ToxPk{public_key};
server.udpPort = udp_port_u16;
server.maintainer = maintainer;
server.ipv4 = ipv4_address;
Expand Down Expand Up @@ -182,7 +184,7 @@ QByteArray serialize(QList<DhtServer> nodes)
nodeJson.insert(NodeFields::status_tcp, node.statusTcp);
nodeJson.insert(NodeFields::ipv4, node.ipv4);
nodeJson.insert(NodeFields::ipv6, node.ipv6);
nodeJson.insert(NodeFields::public_key, node.userId);
nodeJson.insert(NodeFields::public_key, node.publicKey.toString());
nodeJson.insert(NodeFields::udp_port, node.udpPort);
nodeJson.insert(NodeFields::maintainer, node.maintainer);

Expand Down

0 comments on commit 7aa8d71

Please sign in to comment.