Skip to content

Commit 76f02d3

Browse files
committed
changes to persist nodekey
1 parent 90bd53d commit 76f02d3

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

chat_plugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ bool ChatPlugin::initialize(const QString &configJson)
6565
QString bootstrapNodes = config["bootstrapNodes"].toString();
6666
QString mixnodes = config["mixnodes"].toString();
6767
QString storeNode = config["storeNode"].toString();
68+
QString nodeKey = config["nodeKey"].toString();
6869

6970
// Parse comma-separated strings and convert to std::vector<std::string>
7071
QStringList bootstrapNodesList = bootstrapNodes.split(",", Qt::SkipEmptyParts);
@@ -105,7 +106,7 @@ bool ChatPlugin::initialize(const QString &configJson)
105106
{ emitEvent(QStringLiteral("lightpushPeersCountResponse"), data); });
106107

107108
void *result = ::initAndStart(logosAPI, logos, currentRelayTopic, actualCallback, discoveryMode, bootstrapNodesVec, mixnodesVec,
108-
storeNode.toStdString());
109+
storeNode.toStdString(), nodeKey.toStdString());
109110

110111
return (result != nullptr);
111112
}

src/chat_api.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,16 @@ void sendMessage(LogosAPI *logosAPI, LogosModules *logos, const std::string &cha
436436

437437
// Build Waku configuration based on discovery mode
438438
// mixnodes: list of "multiaddr:mixPubKey" strings from UI configuration
439-
std::string buildWakuConfig(DiscoveryMode discoveryMode, const std::vector<std::string> &bootstrapNodes, const std::vector<std::string> &mixnodes)
439+
std::string buildWakuConfig(DiscoveryMode discoveryMode, const std::vector<std::string> &bootstrapNodes, const std::vector<std::string> &mixnodes, const std::string &nodeKey)
440440
{
441441
std::ostringstream config;
442442
config << "{\n";
443443
config << " \"host\": \"0.0.0.0\",\n";
444444
config << " \"tcpPort\": 60010,\n";
445-
config << " \"key\": null,\n";
445+
if (nodeKey.empty())
446+
config << " \"key\": null,\n";
447+
else
448+
config << " \"key\": \"" << nodeKey << "\",\n";
446449
config << " \"clusterId\": 2,\n";
447450
config << " \"relay\": true,\n";
448451
config << " \"mix\": true,\n";
@@ -539,7 +542,7 @@ std::string buildWakuConfig(DiscoveryMode discoveryMode, const std::vector<std::
539542
// Function to initialize and start a Waku node
540543
void *initAndStart(LogosAPI *logosAPI, LogosModules *logos, const std::string &relayTopic, MessageCallback messageCallback,
541544
DiscoveryMode discoveryMode, const std::vector<std::string> &bootstrapNodes, const std::vector<std::string> &mixnodes,
542-
const std::string &storeNode)
545+
const std::string &storeNode, const std::string &nodeKey)
543546
{
544547
// Store the configured store node for use by retrieveHistory
545548
currentStoreNode = storeNode;
@@ -558,7 +561,7 @@ void *initAndStart(LogosAPI *logosAPI, LogosModules *logos, const std::string &r
558561
auto &wakuModule = logos->waku_module;
559562

560563
// Build Waku config based on discovery mode
561-
std::string configStr = buildWakuConfig(discoveryMode, bootstrapNodes, mixnodes);
564+
std::string configStr = buildWakuConfig(discoveryMode, bootstrapNodes, mixnodes, nodeKey);
562565

563566
std::cout << "Discovery mode: " << static_cast<int>(discoveryMode) << std::endl;
564567
std::cout << "Bootstrap nodes count: " << bootstrapNodes.size() << std::endl;

src/chat_api.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ void retrieveHistory(LogosAPI* logosAPI, LogosModules* logos, const std::string&
9191
void event_handler(int callerRet, const char* msg, size_t len, void* userData);
9292
void* initAndStart(LogosAPI* logosAPI, LogosModules* logos, const std::string& relayTopic, MessageCallback messageCallback,
9393
DiscoveryMode discoveryMode, const std::vector<std::string>& bootstrapNodes, const std::vector<std::string>& mixnodes,
94-
const std::string& storeNode);
94+
const std::string& storeNode, const std::string& nodeKey);
9595
bool joinChannel(LogosAPI* logosAPI, LogosModules* logos, const std::string& channelName, const std::string& relayTopic);
96-
std::string buildWakuConfig(DiscoveryMode discoveryMode, const std::vector<std::string>& bootstrapNodes, const std::vector<std::string>& mixnodes);
96+
std::string buildWakuConfig(DiscoveryMode discoveryMode, const std::vector<std::string>& bootstrapNodes, const std::vector<std::string>& mixnodes, const std::string& nodeKey);
9797

9898
#endif // CHAT_API_H

0 commit comments

Comments
 (0)