Files
thehub/hub/server/serverutil.h
T

65 lines
1.8 KiB
C++
Raw Permalink Normal View History

2019-08-24 13:20:37 +02:00
/*
* This file is part of the Flowee project
* Copyright (C) 2009-2010 Satoshi Nakamoto
* Copyright (C) 2009-2015 The Bitcoin Core developers
2021-06-20 22:44:44 +02:00
* Copyright (C) 2017 Tom Zander <tom@flowee.org>
2019-08-24 13:20:37 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FLOWEE_SERVERUTIL_H
#define FLOWEE_SERVERUTIL_H
#include <Logger.h>
#include <util.h>
#include <boost/filesystem/path.hpp>
extern bool fServer;
extern std::string strMiscWarning;
extern bool fLogIPs;
void SetupEnvironment();
bool SetupNetworking();
/**
* .. and a wrapper that just calls func once
*/
template <typename Callable> void TraceThread(const char* name, Callable func)
{
std::string s = strprintf("bitcoin-%s", name);
RenameThread(s.c_str());
2020-10-27 14:28:07 +01:00
try {
logDebug() << name << "thread start";
2019-08-24 13:20:37 +02:00
func();
2020-10-27 14:28:07 +01:00
logDebug() << name << "thread exit";
2019-08-24 13:20:37 +02:00
}
2020-10-27 14:28:07 +01:00
catch (const boost::thread_interrupted&) {
logDebug() << name << "thread interrupt";
2019-08-24 13:20:37 +02:00
throw;
}
2020-10-27 14:28:07 +01:00
catch (const std::exception &e) {
logWarning() << name << e;
2019-08-24 13:20:37 +02:00
throw;
}
catch (...) {
2020-10-27 14:28:07 +01:00
logWarning() << "Exception received" << name;
2019-08-24 13:20:37 +02:00
throw;
}
}
2020-10-27 14:28:07 +01:00
void runCommand(const std::string &strCommand);
2019-08-24 13:20:37 +02:00
#endif