mirror of
https://github.com/cygnusxi/CurecoinSource.git
synced 2025-07-27 15:44:25 +02:00
commit
c06a7b2e5f
@ -25,12 +25,13 @@
|
|||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef u_int SOCKET;
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define MSG_NOSIGNAL 0
|
#define MSG_NOSIGNAL 0
|
||||||
#define MSG_DONTWAIT 0
|
#define MSG_DONTWAIT 0
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
#else
|
#else
|
||||||
|
typedef u_int SOCKET;
|
||||||
#include "errno.h"
|
#include "errno.h"
|
||||||
#define WSAGetLastError() errno
|
#define WSAGetLastError() errno
|
||||||
#define WSAEINVAL EINVAL
|
#define WSAEINVAL EINVAL
|
||||||
|
@ -478,7 +478,7 @@ bool AppInit2()
|
|||||||
}
|
}
|
||||||
if (pid > 0)
|
if (pid > 0)
|
||||||
{
|
{
|
||||||
CreatePidFile(GetPidFile(), pid);
|
CreatePidFile(GetPidFile(), pid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "wallet.h"
|
#include "wallet.h"
|
||||||
|
#include "util.h"
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
@ -4537,9 +4538,9 @@ void curecoinMiner(CWallet *pwallet, bool fProofOfStake)
|
|||||||
}
|
}
|
||||||
strMintWarning = "";
|
strMintWarning = "";
|
||||||
printf("CPUMiner : proof-of-stake block found %s\n", pblock->GetHash().ToString().c_str());
|
printf("CPUMiner : proof-of-stake block found %s\n", pblock->GetHash().ToString().c_str());
|
||||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||||
CheckWork(pblock.get(), *pwalletMain, reservekey);
|
CheckWork(pblock.get(), *pwalletMain, reservekey);
|
||||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||||
}
|
}
|
||||||
Sleep(500);
|
Sleep(500);
|
||||||
continue;
|
continue;
|
||||||
@ -4589,9 +4590,9 @@ void curecoinMiner(CWallet *pwallet, bool fProofOfStake)
|
|||||||
pblock->nNonce = ByteReverse(nNonceFound);
|
pblock->nNonce = ByteReverse(nNonceFound);
|
||||||
assert(hash == pblock->GetHash());
|
assert(hash == pblock->GetHash());
|
||||||
|
|
||||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||||
CheckWork(pblock.get(), *pwalletMain, reservekey);
|
CheckWork(pblock.get(), *pwalletMain, reservekey);
|
||||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1738,14 +1738,17 @@ bool BindListenPort(const CService &addrBind, std::string& strError)
|
|||||||
// some systems don't have IPV6_V6ONLY but are always v6only; others do have the option
|
// some systems don't have IPV6_V6ONLY but are always v6only; others do have the option
|
||||||
// and enable it by default or not. Try to enable it, if possible.
|
// and enable it by default or not. Try to enable it, if possible.
|
||||||
if (addrBind.IsIPv6()) {
|
if (addrBind.IsIPv6()) {
|
||||||
|
#ifndef WIN32
|
||||||
#ifdef IPV6_V6ONLY
|
#ifdef IPV6_V6ONLY
|
||||||
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int));
|
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int));
|
||||||
#endif
|
#endif
|
||||||
#ifdef WIN32
|
#else
|
||||||
int nProtLevel = 10 /* PROTECTION_LEVEL_UNRESTRICTED */;
|
int nProtLevel = 10 /* PROTECTION_LEVEL_UNRESTRICTED */;
|
||||||
int nParameterId = 23 /* IPV6_PROTECTION_LEVEl */;
|
int nParameterId = 23 /* IPV6_PROTECTION_LEVEl */;
|
||||||
// this call is allowed to fail
|
// this call is allowed to fail
|
||||||
|
#ifdef IPV6_V6ONLY
|
||||||
setsockopt(hListenSocket, IPPROTO_IPV6, nParameterId, (const char*)&nProtLevel, sizeof(int));
|
setsockopt(hListenSocket, IPPROTO_IPV6, nParameterId, (const char*)&nProtLevel, sizeof(int));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
13
src/util.cpp
13
src/util.cpp
@ -67,7 +67,6 @@ namespace boost {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::map<std::string, std::string> mapArgs;
|
std::map<std::string, std::string> mapArgs;
|
||||||
std::map<std::string, std::vector<std::string> > mapMultiArgs;
|
std::map<std::string, std::vector<std::string> > mapMultiArgs;
|
||||||
bool fDebug = false;
|
bool fDebug = false;
|
||||||
@ -1114,6 +1113,17 @@ boost::filesystem::path GetPidFile()
|
|||||||
return pathPidFile;
|
return pathPidFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
void CreatePidFile(const boost::filesystem::path &path, util_pid_t pid)
|
||||||
|
{
|
||||||
|
FILE* file = fopen(path.string().c_str(), "w");
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
fprintf(file, "%d\n", pid);
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
|
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
|
||||||
{
|
{
|
||||||
FILE* file = fopen(path.string().c_str(), "w");
|
FILE* file = fopen(path.string().c_str(), "w");
|
||||||
@ -1123,6 +1133,7 @@ void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
|
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
|
||||||
{
|
{
|
||||||
|
17
src/util.h
17
src/util.h
@ -7,16 +7,18 @@
|
|||||||
|
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#else
|
#else
|
||||||
typedef int pid_t; /* define for Windows compatibility */
|
#include <processthreadsapi.h>
|
||||||
|
typedef int util_pid_t; /* define for Windows compatibility */
|
||||||
#endif
|
#endif
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
@ -29,6 +31,7 @@ typedef int pid_t; /* define for Windows compatibility */
|
|||||||
|
|
||||||
#include "netbase.h" // for AddTimeData
|
#include "netbase.h" // for AddTimeData
|
||||||
|
|
||||||
|
|
||||||
typedef long long int64;
|
typedef long long int64;
|
||||||
typedef unsigned long long uint64;
|
typedef unsigned long long uint64;
|
||||||
|
|
||||||
@ -215,7 +218,11 @@ boost::filesystem::path GetDefaultDataDir();
|
|||||||
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
|
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
|
||||||
boost::filesystem::path GetConfigFile();
|
boost::filesystem::path GetConfigFile();
|
||||||
boost::filesystem::path GetPidFile();
|
boost::filesystem::path GetPidFile();
|
||||||
|
#ifdef WIN32
|
||||||
|
void CreatePidFile(const boost::filesystem::path &path, util_pid_t pid);
|
||||||
|
#else
|
||||||
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
|
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
|
||||||
|
#endif
|
||||||
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
|
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
|
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
|
||||||
@ -591,7 +598,7 @@ bool NewThread(void(*pfn)(void*), void* parg);
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
inline void SetThreadPriority(int nPriority)
|
inline void SetThreadPriority(int nPriority)
|
||||||
{
|
{
|
||||||
SetThreadPriority(GetCurrentThread(), nPriority);
|
SetThreadPriority(GetCurrentThread(), nPriority);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user