mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
trivial: misc. trivial refactoring (#4104)
* minor statsd refactoring * stacktrace refactoring * spork typos + unused include * need thread on windows builds
This commit is contained in:
parent
01dd958429
commit
91f4e71563
@ -11,7 +11,6 @@
|
|||||||
#include <key.h>
|
#include <key.h>
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
class CSporkMessage;
|
class CSporkMessage;
|
||||||
class CSporkManager;
|
class CSporkManager;
|
||||||
@ -192,7 +191,7 @@ public:
|
|||||||
READWRITE(strVersion);
|
READWRITE(strVersion);
|
||||||
}
|
}
|
||||||
// we don't serialize pubkey ids because pubkeys should be
|
// we don't serialize pubkey ids because pubkeys should be
|
||||||
// hardcoded or be setted with cmdline or options, should
|
// hardcoded or be set with cmdline or options, should
|
||||||
// not reuse pubkeys from previous dashd run
|
// not reuse pubkeys from previous dashd run
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
READWRITE(mapSporksByHash);
|
READWRITE(mapSporksByHash);
|
||||||
@ -284,7 +283,7 @@ public:
|
|||||||
* a spork to be considered active.
|
* a spork to be considered active.
|
||||||
*
|
*
|
||||||
* This value must be at least a majority of the total number of spork
|
* This value must be at least a majority of the total number of spork
|
||||||
* keys, and for obvious resons cannot be larger than that number.
|
* keys, and for obvious reasons cannot be larger than that number.
|
||||||
*/
|
*/
|
||||||
bool SetMinSporkKeys(int minSporkKeys);
|
bool SetMinSporkKeys(int minSporkKeys);
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include <stacktraces.h>
|
#include <stacktraces.h>
|
||||||
#include <fs.h>
|
#include <fs.h>
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <random.h>
|
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <utilstrencodings.h>
|
#include <utilstrencodings.h>
|
||||||
|
|
||||||
@ -17,18 +16,18 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
#if WIN32
|
#if WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <dbghelp.h>
|
#include <dbghelp.h>
|
||||||
|
#include <thread>
|
||||||
#else
|
#else
|
||||||
#ifdef ENABLE_STACKTRACES
|
#ifdef ENABLE_STACKTRACES
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#endif
|
#endif
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <csignal>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !WIN32
|
#if !WIN32
|
||||||
@ -49,7 +48,7 @@
|
|||||||
#include <backtrace.h>
|
#include <backtrace.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
std::string DemangleSymbol(const std::string& name)
|
std::string DemangleSymbol(const std::string& name)
|
||||||
{
|
{
|
||||||
@ -356,8 +355,8 @@ static std::vector<stackframe_info> GetStackFrameInfos(const std::vector<uint64_
|
|||||||
std::vector<stackframe_info> infos;
|
std::vector<stackframe_info> infos;
|
||||||
infos.reserve(stackframes.size());
|
infos.reserve(stackframes.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < stackframes.size(); i++) {
|
for (uint64_t stackframe : stackframes) {
|
||||||
if (backtrace_pcinfo(GetLibBacktraceState(), stackframes[i], my_backtrace_full_callback, my_backtrace_error_callback, &infos)) {
|
if (backtrace_pcinfo(GetLibBacktraceState(), stackframe, my_backtrace_full_callback, my_backtrace_error_callback, &infos)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -499,9 +498,7 @@ static std::string GetCrashInfoStr(const crash_info& ci, size_t spaces)
|
|||||||
std::vector<std::string> lstrs;
|
std::vector<std::string> lstrs;
|
||||||
lstrs.reserve(ci.stackframeInfos.size());
|
lstrs.reserve(ci.stackframeInfos.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < ci.stackframeInfos.size(); i++) {
|
for (const auto& si : ci.stackframeInfos) {
|
||||||
auto& si = ci.stackframeInfos[i];
|
|
||||||
|
|
||||||
std::string lstr;
|
std::string lstr;
|
||||||
if (!si.filename.empty()) {
|
if (!si.filename.empty()) {
|
||||||
lstr += fs::path(si.filename).filename().string();
|
lstr += fs::path(si.filename).filename().string();
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
|
|
||||||
#include <tinyformat.h>
|
|
||||||
|
|
||||||
std::string DemangleSymbol(const std::string& name);
|
std::string DemangleSymbol(const std::string& name);
|
||||||
|
|
||||||
std::string GetPrettyExceptionStr(const std::exception_ptr& e);
|
std::string GetPrettyExceptionStr(const std::exception_ptr& e);
|
||||||
|
@ -35,10 +35,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <random.h>
|
#include <random.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
#include <time.h>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
statsd::StatsdClient statsClient;
|
statsd::StatsdClient statsClient;
|
||||||
|
|
||||||
@ -88,7 +86,7 @@ StatsdClient::~StatsdClient()
|
|||||||
// close socket
|
// close socket
|
||||||
CloseSocket(d->sock);
|
CloseSocket(d->sock);
|
||||||
delete d;
|
delete d;
|
||||||
d = NULL;
|
d = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsdClient::config(const std::string& host, int port, const std::string& ns)
|
void StatsdClient::config(const std::string& host, int port, const std::string& ns)
|
||||||
|
@ -53,13 +53,13 @@ class StatsdClient {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
int init();
|
int init();
|
||||||
void cleanup(std::string& key);
|
static void cleanup(std::string& key);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct _StatsdClientData* d;
|
struct _StatsdClientData* d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace statsd
|
} // namespace statsd
|
||||||
|
|
||||||
extern statsd::StatsdClient statsClient;
|
extern statsd::StatsdClient statsClient;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user