Anoncoin  0.9.4
P2P Digital Currency
util.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Copyright (c) 2013-2014 The Anoncoin Core developers
4 // Distributed under the MIT/X11 software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef ANONCOIN_UTIL_H
8 #define ANONCOIN_UTIL_H
9 
10 #if defined(HAVE_CONFIG_H)
11 #include "config/anoncoin-config.h"
12 #endif
13 
14 #include "compat.h"
15 #include "serialize.h"
16 #include "tinyformat.h"
17 
18 #include <cstdio>
19 #include <exception>
20 #include <map>
21 #include <stdarg.h>
22 #include <stdint.h>
23 #include <string>
24 #include <utility>
25 #include <vector>
26 
27 #ifndef WIN32
28 #include <sys/resource.h>
29 #include <sys/time.h>
30 #include <sys/types.h>
31 #endif
32 
33 #include <boost/filesystem/path.hpp>
34 #include <boost/thread.hpp>
35 
36 class CNetAddr;
37 class uint256;
38 
39 static const int64_t COIN = 100000000;
40 static const int64_t CENT = 1000000;
41 
42 #define BEGIN(a) ((char*)&(a))
43 #define END(a) ((char*)&((&(a))[1]))
44 #define UBEGIN(a) ((unsigned char*)&(a))
45 #define UEND(a) ((unsigned char*)&((&(a))[1]))
46 #define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
47 
48 // This is needed because the foreach macro can't get over the comma in pair<t1, t2>
49 #define PAIRTYPE(t1, t2) std::pair<t1, t2>
50 
51 // Align by increasing pointer, must have extra space at end of buffer
52 template <size_t nBytes, typename T>
53 T* alignup(T* p)
54 {
55  union
56  {
57  T* ptr;
58  size_t n;
59  } u;
60  u.ptr = p;
61  u.n = (u.n + (nBytes-1)) & ~(nBytes-1);
62  return u.ptr;
63 }
64 
65 #ifdef WIN32
66 #define MSG_DONTWAIT 0
67 
68 #ifndef S_IRUSR
69 #define S_IRUSR 0400
70 #define S_IWUSR 0200
71 #endif
72 #else
73 #define MAX_PATH 1024
74 #endif // WIN32
75 // As Solaris does not have the MSG_NOSIGNAL flag for send(2) syscall, it is defined as 0
76 #if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
77 #define MSG_NOSIGNAL 0
78 #endif
79 
80 inline void MilliSleep(int64_t n)
81 {
82 // Boost's sleep_for was uninterruptable when backed by nanosleep from 1.50
83 // until fixed in 1.52. Use the deprecated sleep method for the broken case.
84 // See: https://svn.boost.org/trac/boost/ticket/7238
85 #if defined(HAVE_WORKING_BOOST_SLEEP_FOR)
86  boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
87 #elif defined(HAVE_WORKING_BOOST_SLEEP)
88  boost::this_thread::sleep(boost::posix_time::milliseconds(n));
89 #else
90 //should never get here
91 #error missing boost sleep implementation
92 #endif
93 }
94 
95 
96 
97 extern std::map<std::string, std::string> mapArgs;
98 extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
99 extern bool fDebug;
100 extern bool fPrintToConsole;
101 extern bool fPrintToDebugLog;
102 extern bool fServer;
103 extern std::string strMiscWarning;
104 extern bool fNoListen;
105 extern bool fLogTimestamps;
106 extern volatile bool fReopenDebugLog;
107 
108 void RandAddSeed();
109 void RandAddSeedPerfmon();
110 void SetupEnvironment();
111 
112 /* Return true if log accepts specified category */
113 bool LogAcceptCategory(const char* category);
114 /* Send a string to the log output */
115 int LogPrintStr(const std::string &str);
116 
117 #define strprintf tfm::format
118 #define LogPrintf(...) LogPrint(NULL, __VA_ARGS__)
119 
120 /* When we switch to C++11, this can be switched to variadic templates instead
121  * of this macro-based construction (see tinyformat.h).
122  */
123 #define MAKE_ERROR_AND_LOG_FUNC(n) \
124  /* Print to debug.log if -debug=category switch is given OR category is NULL. */ \
125  template<TINYFORMAT_ARGTYPES(n)> \
126  static inline int LogPrint(const char* category, const char* format, TINYFORMAT_VARARGS(n)) \
127  { \
128  if(!LogAcceptCategory(category)) return 0; \
129  return LogPrintStr(tfm::format(format, TINYFORMAT_PASSARGS(n))); \
130  } \
131  /* Log error and return false */ \
132  template<TINYFORMAT_ARGTYPES(n)> \
133  static inline bool error(const char* format, TINYFORMAT_VARARGS(n)) \
134  { \
135  LogPrintStr("ERROR: " + tfm::format(format, TINYFORMAT_PASSARGS(n)) + "\n"); \
136  return false; \
137  }
138 
140 
141 /* Zero-arg versions of logging and error, these are not covered by
142  * TINYFORMAT_FOREACH_ARGNUM
143  */
144 static inline int LogPrint(const char* category, const char* format)
145 {
146  if(!LogAcceptCategory(category)) return 0;
147  return LogPrintStr(format);
148 }
149 static inline bool error(const char* format)
150 {
151  LogPrintStr(std::string("ERROR: ") + format + "\n");
152  return false;
153 }
154 
155 
156 void LogException(std::exception* pex, const char* pszThread);
157 void PrintExceptionContinue(std::exception* pex, const char* pszThread);
158 std::string FormatMoney(int64_t n, bool fPlus=false);
159 bool ParseMoney(const std::string& str, int64_t& nRet);
160 bool ParseMoney(const char* pszIn, int64_t& nRet);
161 std::string SanitizeString(const std::string& str);
162 std::vector<unsigned char> ParseHex(const char* psz);
163 std::vector<unsigned char> ParseHex(const std::string& str);
164 bool IsHex(const std::string& str);
165 std::vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid = NULL);
166 std::string DecodeBase64(const std::string& str);
167 std::string EncodeBase64(const unsigned char* pch, size_t len);
168 std::string EncodeBase64(const std::string& str);
169 std::vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid = NULL);
170 std::string DecodeBase32(const std::string& str);
171 std::string EncodeBase32(const unsigned char* pch, size_t len);
172 std::string EncodeBase32(const std::string& str);
173 void ParseParameters(int argc, const char*const argv[]);
174 bool WildcardMatch(const char* psz, const char* mask);
175 bool WildcardMatch(const std::string& str, const std::string& mask);
176 void FileCommit(FILE *fileout);
177 bool TruncateFile(FILE *file, unsigned int length);
178 int RaiseFileDescriptorLimit(int nMinFD);
179 void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
180 bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest);
181 bool TryCreateDirectory(const boost::filesystem::path& p);
182 boost::filesystem::path GetDefaultDataDir();
183 const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
184 boost::filesystem::path GetConfigFile();
185 boost::filesystem::path GetQtStyleFile();
186 boost::filesystem::path GetPidFile();
187 #ifndef WIN32
188 void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
189 #endif
190 void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
191 #ifdef WIN32
192 boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
193 #endif
194 boost::filesystem::path GetTempPath();
195 void ShrinkDebugFile();
196 int GetRandInt(int nMax);
197 uint64_t GetRand(uint64_t nMax);
199 int64_t GetTime();
200 void SetMockTime(int64_t nMockTimeIn);
201 int64_t GetAdjustedTime();
202 int64_t GetTimeOffset();
203 void AddTimeData(const CNetAddr& ip, int64_t nTime);
204 void runCommand(std::string strCommand);
205 
206 
207 inline std::string i64tostr(int64_t n)
208 {
209  return strprintf("%d", n);
210 }
211 
212 inline std::string itostr(int n)
213 {
214  return strprintf("%d", n);
215 }
216 
217 inline int64_t atoi64(const char* psz)
218 {
219 #ifdef _MSC_VER
220  return _atoi64(psz);
221 #else
222  return strtoll(psz, NULL, 10);
223 #endif
224 }
225 
226 inline int64_t atoi64(const std::string& str)
227 {
228 #ifdef _MSC_VER
229  return _atoi64(str.c_str());
230 #else
231  return strtoll(str.c_str(), NULL, 10);
232 #endif
233 }
234 
235 inline int atoi(const std::string& str)
236 {
237  return atoi(str.c_str());
238 }
239 
240 inline int roundint(double d)
241 {
242  return (int)(d > 0 ? d + 0.5 : d - 0.5);
243 }
244 
245 inline int64_t roundint64(double d)
246 {
247  return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
248 }
249 
250 inline int64_t abs64(int64_t n)
251 {
252  return (n >= 0 ? n : -n);
253 }
254 
255 template<typename T>
256 std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
257 {
258  std::string rv;
259  static const char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
260  '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
261  rv.reserve((itend-itbegin)*3);
262  for(T it = itbegin; it < itend; ++it)
263  {
264  unsigned char val = (unsigned char)(*it);
265  if(fSpaces && it != itbegin)
266  rv.push_back(' ');
267  rv.push_back(hexmap[val>>4]);
268  rv.push_back(hexmap[val&15]);
269  }
270 
271  return rv;
272 }
273 
274 template<typename T>
275 inline std::string HexStr(const T& vch, bool fSpaces=false)
276 {
277  return HexStr(vch.begin(), vch.end(), fSpaces);
278 }
279 
280 template<typename T>
281 void PrintHex(const T pbegin, const T pend, const char* pszFormat="%s", bool fSpaces=true)
282 {
283  LogPrintf(pszFormat, HexStr(pbegin, pend, fSpaces).c_str());
284 }
285 
286 inline void PrintHex(const std::vector<unsigned char>& vch, const char* pszFormat="%s", bool fSpaces=true)
287 {
288  LogPrintf(pszFormat, HexStr(vch, fSpaces).c_str());
289 }
290 
291 inline int64_t GetPerformanceCounter()
292 {
293  int64_t nCounter = 0;
294 #ifdef WIN32
295  QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
296 #else
297  timeval t;
298  gettimeofday(&t, NULL);
299  nCounter = (int64_t) t.tv_sec * 1000000 + t.tv_usec;
300 #endif
301  return nCounter;
302 }
303 
304 inline int64_t GetTimeMillis()
305 {
306  return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) -
307  boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
308 }
309 
310 inline int64_t GetTimeMicros()
311 {
312  return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) -
313  boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_microseconds();
314 }
315 
316 std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime);
317 
318 template<typename T>
319 void skipspaces(T& it)
320 {
321  while (isspace(*it))
322  ++it;
323 }
324 
325 inline bool IsSwitchChar(char c)
326 {
327 #ifdef WIN32
328  return c == '-' || c == '/';
329 #else
330  return c == '-';
331 #endif
332 }
333 
341 std::string GetArg(const std::string& strArg, const std::string& strDefault);
342 
350 int64_t GetArg(const std::string& strArg, int64_t nDefault);
351 
359 bool GetBoolArg(const std::string& strArg, bool fDefault);
360 
368 bool SoftSetArg(const std::string& strArg, const std::string& strValue);
369 
377 bool SoftSetBoolArg(const std::string& strArg, bool fValue);
378 
386 extern uint32_t insecure_rand_Rz;
387 extern uint32_t insecure_rand_Rw;
388 static inline uint32_t insecure_rand(void)
389 {
390  insecure_rand_Rz = 36969 * (insecure_rand_Rz & 65535) + (insecure_rand_Rz >> 16);
391  insecure_rand_Rw = 18000 * (insecure_rand_Rw & 65535) + (insecure_rand_Rw >> 16);
392  return (insecure_rand_Rw << 16) + insecure_rand_Rz;
393 }
394 
399 void seed_insecure_rand(bool fDeterministic=false);
400 
406 template <typename T>
407 bool TimingResistantEqual(const T& a, const T& b)
408 {
409  if (b.size() == 0) return a.size() == 0;
410  size_t accumulator = a.size() ^ b.size();
411  for (size_t i = 0; i < a.size(); i++)
412  accumulator |= a[i] ^ b[i%b.size()];
413  return accumulator == 0;
414 }
415 
419 template <typename T> class CMedianFilter
420 {
421 private:
422  std::vector<T> vValues;
423  std::vector<T> vSorted;
424  unsigned int nSize;
425 public:
426  CMedianFilter(unsigned int size, T initial_value):
427  nSize(size)
428  {
429  vValues.reserve(size);
430  vValues.push_back(initial_value);
431  vSorted = vValues;
432  }
433 
434  void input(T value)
435  {
436  if(vValues.size() == nSize)
437  {
438  vValues.erase(vValues.begin());
439  }
440  vValues.push_back(value);
441 
442  vSorted.resize(vValues.size());
443  std::copy(vValues.begin(), vValues.end(), vSorted.begin());
444  std::sort(vSorted.begin(), vSorted.end());
445  }
446 
447  T median() const
448  {
449  int size = vSorted.size();
450  assert(size>0);
451  if(size & 1) // Odd number of elements
452  {
453  return vSorted[size/2];
454  }
455  else // Even number of elements
456  {
457  return (vSorted[size/2-1] + vSorted[size/2]) / 2;
458  }
459  }
460 
461  int size() const
462  {
463  return vValues.size();
464  }
465 
466  std::vector<T> sorted () const
467  {
468  return vSorted;
469  }
470 };
471 
472 #ifdef WIN32
473 inline void SetThreadPriority(int nPriority)
474 {
475  SetThreadPriority(GetCurrentThread(), nPriority);
476 }
477 #else
478 
479 // PRIO_MAX is not defined on Solaris
480 #ifndef PRIO_MAX
481 #define PRIO_MAX 20
482 #endif
483 #define THREAD_PRIORITY_LOWEST PRIO_MAX
484 #define THREAD_PRIORITY_BELOW_NORMAL 2
485 #define THREAD_PRIORITY_NORMAL 0
486 #define THREAD_PRIORITY_ABOVE_NORMAL (-2)
487 
488 inline void SetThreadPriority(int nPriority)
489 {
490  // It's unclear if it's even possible to change thread priorities on Linux,
491  // but we really and truly need it for the generation threads.
492 #ifdef PRIO_THREAD
493  setpriority(PRIO_THREAD, 0, nPriority);
494 #else
495  setpriority(PRIO_PROCESS, 0, nPriority);
496 #endif
497 }
498 #endif
499 
500 void RenameThread(const char* name);
501 
502 inline uint32_t ByteReverse(uint32_t value)
503 {
504  value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8);
505  return (value<<16) | (value>>16);
506 }
507 
508 // Standard wrapper for do-something-forever thread functions.
509 // "Forever" really means until the thread is interrupted.
510 // Use it like:
511 // new boost::thread(boost::bind(&LoopForever<void (*)()>, "dumpaddr", &DumpAddresses, 900000));
512 // or maybe:
513 // boost::function<void()> f = boost::bind(&FunctionWithArg, argument);
514 // threadGroup.create_thread(boost::bind(&LoopForever<boost::function<void()> >, "nothing", f, milliseconds));
515 template <typename Callable> void LoopForever(const char* name, Callable func, int64_t msecs)
516 {
517  std::string s = strprintf("anoncoin-%s", name);
518  RenameThread(s.c_str());
519  LogPrintf("%s thread start\n", name);
520  try
521  {
522  while (1)
523  {
524  MilliSleep(msecs);
525  func();
526  }
527  }
528  catch (boost::thread_interrupted)
529  {
530  LogPrintf("%s thread stop\n", name);
531  throw;
532  }
533  catch (std::exception& e) {
534  PrintExceptionContinue(&e, name);
535  throw;
536  }
537  catch (...) {
538  PrintExceptionContinue(NULL, name);
539  throw;
540  }
541 }
542 // .. and a wrapper that just calls func once
543 template <typename Callable> void TraceThread(const char* name, Callable func)
544 {
545  std::string s = strprintf("anoncoin-%s", name);
546  RenameThread(s.c_str());
547  try
548  {
549  LogPrintf("%s thread start\n", name);
550  func();
551  LogPrintf("%s thread exit\n", name);
552  }
553  catch (boost::thread_interrupted)
554  {
555  LogPrintf("%s thread interrupt\n", name);
556  throw;
557  }
558  catch (std::exception& e) {
559  PrintExceptionContinue(&e, name);
560  throw;
561  }
562  catch (...) {
563  PrintExceptionContinue(NULL, name);
564  throw;
565  }
566 }
567 
568 #endif
void skipspaces(T &it)
Definition: util.h:319
uint64_t GetRand(uint64_t nMax)
Definition: util.cpp:186
void PrintHex(const T pbegin, const T pend, const char *pszFormat="%s", bool fSpaces=true)
Definition: util.h:281
void MilliSleep(int64_t n)
Definition: util.h:80
void ShrinkDebugFile()
Definition: util.cpp:1187
bool fPrintToConsole
Definition: util.cpp:92
void LogException(std::exception *pex, const char *pszThread)
Definition: util.cpp:922
std::vector< unsigned char > DecodeBase32(const char *p, bool *pfInvalid=NULL)
Definition: util.cpp:752
void SetMockTime(int64_t nMockTimeIn)
Definition: util.cpp:1227
int64_t GetAdjustedTime()
Definition: util.cpp:1241
void RandAddSeedPerfmon()
Definition: util.cpp:159
std::string i64tostr(int64_t n)
Definition: util.h:207
void RenameThread(const char *name)
Definition: util.cpp:1368
Median filter over a stream of values.
Definition: util.h:419
void ReadConfigFile(std::map< std::string, std::string > &mapSettingsRet, std::map< std::string, std::vector< std::string > > &mapMultiSettingsRet)
#define strprintf
Definition: util.h:117
std::string SanitizeString(const std::string &str)
int GetRandInt(int nMax)
Definition: util.cpp:201
std::map< std::string, std::vector< std::string > > mapMultiArgs
Definition: util.cpp:90
std::vector< T > vSorted
Definition: util.h:423
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
Definition: util.cpp:1058
void SetupEnvironment()
Definition: util.cpp:1394
int64_t GetTime()
Definition: util.cpp:1220
std::map< std::string, std::string > mapArgs
Definition: util.cpp:89
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
Definition: util.cpp:531
std::vector< unsigned char > ParseHex(const char *psz)
Definition: util.cpp:419
std::vector< T > vValues
Definition: util.h:422
int64_t GetTimeOffset()
Definition: util.cpp:1235
#define LogPrintf(...)
Definition: util.h:118
const boost::filesystem::path & GetDataDir(bool fNetSpecific=true)
Definition: util.cpp:968
void RandAddSeed()
Definition: util.cpp:151
void input(T value)
Definition: util.h:434
std::string itostr(int n)
Definition: util.h:212
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
Definition: util.cpp:539
bool fNoListen
Definition: util.cpp:97
int64_t atoi64(const char *psz)
Definition: util.h:217
void TraceThread(const char *name, Callable func)
Definition: util.h:543
bool ParseMoney(const std::string &str, int64_t &nRet)
CMedianFilter(unsigned int size, T initial_value)
Definition: util.h:426
void ParseParameters(int argc, const char *const argv[])
Definition: util.cpp:460
T median() const
Definition: util.h:447
uint256 GetRandHash()
Definition: util.cpp:206
int64_t GetTimeMillis()
Definition: util.h:304
int64_t GetTimeMicros()
Definition: util.h:310
bool fServer
Definition: util.cpp:95
T * alignup(T *p)
Definition: util.h:53
bool IsHex(const std::string &str)
std::string EncodeBase64(const unsigned char *pch, size_t len)
Definition: util.cpp:548
#define MAKE_ERROR_AND_LOG_FUNC(n)
Definition: util.h:123
void SetThreadPriority(int nPriority)
Definition: util.h:488
void PrintExceptionContinue(std::exception *pex, const char *pszThread)
Definition: util.cpp:928
std::vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid=NULL)
Definition: util.cpp:599
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
Definition: netbase.h:45
std::string EncodeBase32(const unsigned char *pch, size_t len)
Definition: util.cpp:688
int size() const
Definition: util.h:461
256-bit unsigned integer
Definition: uint256.h:532
int64_t GetPerformanceCounter()
Definition: util.h:291
std::string strMiscWarning
Definition: util.cpp:96
bool IsSwitchChar(char c)
Definition: util.h:325
uint32_t insecure_rand_Rz
MWC RNG of George Marsaglia This is intended to be fast.
Definition: util.cpp:1301
std::string FormatMoney(int64_t n, bool fPlus=false)
Definition: util.cpp:308
bool TryCreateDirectory(const boost::filesystem::path &p)
Definition: util.cpp:1083
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
Definition: util.cpp:1069
uint32_t ByteReverse(uint32_t value)
Definition: util.h:502
void FileCommit(FILE *fileout)
Definition: util.cpp:1097
bool fDebug
Definition: util.cpp:91
boost::filesystem::path GetConfigFile()
Definition: util.cpp:1007
void seed_insecure_rand(bool fDeterministic=false)
Seed insecure_rand using the random pool.
Definition: util.cpp:1303
boost::filesystem::path GetTempPath()
Definition: util.cpp:1339
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
Definition: util.cpp:506
bool TimingResistantEqual(const T &a, const T &b)
Timing-attack-resistant comparison.
Definition: util.h:407
bool WildcardMatch(const char *psz, const char *mask)
Definition: util.cpp:876
bool LogAcceptCategory(const char *category)
Definition: util.cpp:240
int RaiseFileDescriptorLimit(int nMinFD)
Definition: util.cpp:1124
std::vector< T > sorted() const
Definition: util.h:466
int64_t roundint64(double d)
Definition: util.h:245
boost::filesystem::path GetPidFile()
Definition: util.cpp:1050
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length)
Definition: util.cpp:1145
bool TruncateFile(FILE *file, unsigned int length)
Definition: util.cpp:1114
unsigned int nSize
Definition: util.h:424
int64_t abs64(int64_t n)
Definition: util.h:250
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
Definition: util.h:256
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
Definition: util.cpp:520
int LogPrintStr(const std::string &str)
Definition: util.cpp:268
volatile bool fReopenDebugLog
Definition: util.cpp:99
#define TINYFORMAT_FOREACH_ARGNUM(m)
Definition: tinyformat.h:430
bool fLogTimestamps
Definition: util.cpp:98
void LoopForever(const char *name, Callable func, int64_t msecs)
Definition: util.h:515
void format(FormatIterator &fmtIter)
Definition: tinyformat.h:870
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
Definition: util.cpp:1411
boost::filesystem::path GetQtStyleFile()
Definition: util.cpp:1014
boost::filesystem::path GetDefaultDataDir()
Definition: util.cpp:936
uint32_t insecure_rand_Rw
Definition: util.cpp:1302
int roundint(double d)
Definition: util.h:240
int atoi(const std::string &str)
Definition: util.h:235
void runCommand(std::string strCommand)
Definition: util.cpp:1361
bool fPrintToDebugLog
Definition: util.cpp:93
void AddTimeData(const CNetAddr &ip, int64_t nTime)
Definition: util.cpp:1246