Don't init gRPC if it's not used
This commit is contained in:
+6
-2
@@ -343,7 +343,9 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
grpc_init();
|
||||
if (params.grpc_needed()) {
|
||||
grpc_init();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_TLS
|
||||
@@ -362,7 +364,9 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
grpc_shutdown();
|
||||
if (params.grpc_needed()) {
|
||||
grpc_shutdown();
|
||||
}
|
||||
#endif
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
#include "p2p_server.h"
|
||||
#include <fstream>
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
#include "merge_mining_client.h"
|
||||
#include "merge_mining_client_tari.h"
|
||||
#endif
|
||||
|
||||
LOG_CATEGORY(Params)
|
||||
|
||||
void p2pool_usage();
|
||||
@@ -476,6 +481,20 @@ bool Params::valid() const
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
bool Params::grpc_needed() const
|
||||
{
|
||||
for (const MergeMiningHost& h : m_mergeMiningHosts) {
|
||||
if (h.m_host.find(MergeMiningClientTari::TARI_PREFIX) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool Params::Host::init_display_name(const Params& p)
|
||||
{
|
||||
m_displayName = m_address;
|
||||
|
||||
@@ -33,6 +33,10 @@ struct Params
|
||||
|
||||
bool valid() const;
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
bool grpc_needed() const;
|
||||
#endif
|
||||
|
||||
struct Host
|
||||
{
|
||||
Host() : m_address("127.0.0.1"), m_rpcPort(18081), m_zmqPort(18083), m_rpcSSL(false) {}
|
||||
|
||||
Reference in New Issue
Block a user