From 7aa8d7178eb2c4a46020689f6d825e827c6ef1c8 Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Tue, 15 Feb 2022 14:37:43 -0800 Subject: [PATCH] refactor(bootstrap): Store public key as ToxPk rather than QString --- src/core/core.cpp | 3 +-- src/core/dhtserver.cpp | 2 +- src/core/dhtserver.h | 4 +++- src/net/bootstrapnodeupdater.cpp | 6 ++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index c11718e28..327eb92cf 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -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) { diff --git a/src/core/dhtserver.cpp b/src/core/dhtserver.cpp index 20b1689c5..24235a381 100644 --- a/src/core/dhtserver.cpp +++ b/src/core/dhtserver.cpp @@ -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); } diff --git a/src/core/dhtserver.h b/src/core/dhtserver.h index 259a5e5f7..8a3088db2 100644 --- a/src/core/dhtserver.h +++ b/src/core/dhtserver.h @@ -19,6 +19,8 @@ #pragma once +#include "toxpk.h" + #include #include @@ -29,7 +31,7 @@ struct DhtServer QString ipv4; QString ipv6; QString maintainer; - QString userId; + ToxPk publicKey; quint16 udpPort; std::vector tcpPorts; diff --git a/src/net/bootstrapnodeupdater.cpp b/src/net/bootstrapnodeupdater.cpp index 601552559..49199a215 100644 --- a/src/net/bootstrapnodeupdater.cpp +++ b/src/net/bootstrapnodeupdater.cpp @@ -20,6 +20,8 @@ #include "bootstrapnodeupdater.h" #include "src/persistence/paths.h" +#include "src/core/toxpk.h" +#include "src/core/toxid.h" #include #include @@ -120,7 +122,7 @@ void jsonNodeToDhtServer(const QJsonObject& node, QList& 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; @@ -182,7 +184,7 @@ QByteArray serialize(QList 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);