aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
AgeCommit message (Collapse)Author
2015-09-03Move windows socket init to utility functionWladimir J. van der Laan
2015-07-06Buffer log messages and explicitly open logsAdam Weiss
Prevents stomping on debug logs in datadirs that are locked by other instances and lost parameter interaction messages that can get wiped by ShrinkDebugFile(). The log is now opened explicitly and all emitted messages are buffered until this open occurs. The version message and log cut have also been moved to the earliest possible sensible location.
2015-07-01Use real number of cores for default -par, ignore virtual coresWladimir J. van der Laan
To determine the default for `-par`, the number of script verification threads, use [boost::thread::physical_concurrency()](http://www.boost.org/doc/libs/1_58_0/doc/html/thread/thread_management.html#thread.thread_management.thread.physical_concurrency) which counts only physical cores, not virtual cores. Virtual cores are roughly a set of cached registers to avoid context switches while threading, they cannot actually perform work, so spawning a verification thread for them could even reduce efficiency and will put undue load on the system. Should fix issue #6358, as well as some other reported system overload issues, especially on Intel processors. The function was only introduced in boost 1.56, so provide a utility function `GetNumCores` to fall back for older Boost versions.
2015-06-04use const references where appropriatePhilip Kaufmann
2015-05-14Use CScheduler for net's DumpAddressesGavin Andresen
Instead of starting Yet Another Thread to dump addresses, use CScheduler to do it.
2015-04-16Separate CTranslationInterface from CClientUIInterfaceJorge Timón
2015-03-10Help messages correctly formatted (79 chars)Luca Venturini
Help messages are formatted programmatically with FormatParagraph in order not to break existing strings in Transifex. The new format works even if the translation of the strings modifies the lenght of the message. Sqashed 6 commits in a single one. Help messages correctly formatted for SVGA text mode (132 chars) Help messages are formatted programmatically with FormatParagraph in order not to break existing strings in Transifex. The new format should work even if the translation of the strings modifies the lenght of the message. Fix - syntax error Correct formatting for 79 chars Correctly based on C++ functions Removed spare spaces from option strings Fix - syntax error
2015-03-03Reinitialize state in between individual unit tests.Pieter Wuille
This changes the TestingSetup fixture to be per-unit-test rather than global. Most tests don't need it, so it's only invoked in a few.
2014-12-19Added "Core" to copyright headerssandakersmann
Github-Pull: #5494 Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-17make all catch() arguments constPhilip Kaufmann
- I saw this on http://en.cppreference.com/w/cpp/language/try_catch and thought it would be a good idea - also unify used format to better be able to search for exception uses in our codebase
2014-11-17Update comments in util to be doxygen compatibleMichael Ford
2014-10-02amount.h: update license, add header end comment + rem from util.hPhilip Kaufmann
2014-09-26Use a typedef for monetary valuesMark Friedenbach
2014-09-20Also create pid file in non-daemon modeWladimir J. van der Laan
Always make a pid file, not only when `-daemon` specified. This is useful for troubleshooting, for attaching debuggers and loggers and such. - Write the pid file only after the datadir lock was acquired - Don't create or remove a pid file on WIN32, and also don't show the option
2014-09-14header include cleanupPhilip Kaufmann
- ensures alphabetical ordering for includes etc. in source file headers
2014-08-28add missing header end commentsPhilip Kaufmann
- ensures a consistent usage in header files - also add a blank line after the copyright header where missing - also remove orphan new-lines at the end of some files
2014-08-26Split up util.cpp/hWladimir J. van der Laan
Split up util.cpp/h into: - string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach) - money utilities (parsesmoney, formatmoney) - time utilities (gettime*, sleep, format date): - and the rest (logging, argument parsing, config file parsing) The latter is basically the environment and OS handling, and is stripped of all utility functions, so we may want to rename it to something else than util.cpp/h for clarity (Matt suggested osinterface). Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-26Move `COIN` and `CENT` to core.hWladimir J. van der Laan
Eventually these should end up in `money.h` after monetary amounts are typedef'ed, but at least they don't belong in `util.h`.
2014-08-26Move `*Version()` functions to version.h/cppWladimir J. van der Laan
2014-08-26Move `S_I*` constants and `MSG_NOSIGNAL` to compat.hWladimir J. van der Laan
2014-08-26Move SetThreadPriority implementation to util.cpp instead of the headerWladimir J. van der Laan
Put the THREAD_* and PRIO_ constants in compat.h.
2014-08-26Remove unused function `ByteReverse` from util.hWladimir J. van der Laan
2014-08-26Remove unused `alignup` function from util.hWladimir J. van der Laan
2014-08-26Move CMedianFilter to timedata.cppWladimir J. van der Laan
Now that we no longer use the median filter to keep track of the number of blocks of peers, that's the only place it is used.
2014-08-20Move strprintf define to tinyformat.hWladimir J. van der Laan
This avoids a dependency on util.h if just tinyformat is needed.
2014-07-09move rand functions from util to new random.h/.cppPhilip Kaufmann
2014-07-09add GetRandBytes() as wrapper for RAND_bytes()Philip Kaufmann
- add a small wrapper in util around RAND_bytes() and replace with GetRandBytes() in the code to log errors from calling RAND_bytes() - remove OpenSSL header rand.h where no longer needed
2014-07-04Show nodeid instead of addresses (for anonymity) unless otherwise requested.R E Broadley
2014-06-28Move non-trivial uint256.h methods to uint256.cppPieter Wuille
2014-06-25Move network-time related functions to timedata.cpp/hWladimir J. van der Laan
The network time-offset-mangement functions from util.cpp are moved to timedata.(cpp|h). This breaks the dependency of util on netbase.
2014-06-23build: fix build weirdness after 54372482.Cory Fields
bitcoin-config.h moved, but the old file is likely to still exist when reconfiguring or switching branches. This would've caused files to not rebuild correctly, and other strange problems. Make the path explicit so that the old one cannot be found. Core libs use config/bitcoin-config.h. Libs (like crypto) which don't want access to bitcoin's headers continue to use -Iconfig and #include bitcoin-config.h.
2014-06-11util: Add function FormatParagraph to format paragraph to fixed-widthWladimir J. van der Laan
This is to be used for the `-version` and `-help` messages.
2014-06-10Remove unused Print/PrintHex functionsWladimir J. van der Laan
You can just use HexStr(script) or script.ToString() for debugging, no need for these extra functions.
2014-05-29rename fNoListen to fListen and move to netPhilip Kaufmann
- better code readability and it belongs to net - this is a prerequisite for a pull to add -listen to the GUI
2014-05-25Merge pull request #4183Wladimir J. van der Laan
f40dbee remove CPubKey::VerifyCompact( ) which is never used (Kamil Domanski) 28b6c1d remove GetMedianTime( ) which is never used (Kamil Domanski) 5bd4adc remove LookupHostNumeric( ) which is never used (Kamil Domanski) 595f691 remove LogException( ) which is never used (Kamil Domanski) f4057cb remove CTransaction::IsNewerThan which is never used (Kamil Domanski) 0e31e56 remove CWallet::AddReserveKey which is never used (Kamil Domanski)
2014-05-23Replace non-threadsafe gmtime and setlocaleWladimir J. van der Laan
Make DateTimeStrFormat use boost::posix_time. Also re-enable the util_DateTimeStrFormat tests, as they are no longer platform specific.
2014-05-20remove LogException( ) which is never usedKamil Domanski
2014-05-19Merge pull request #4174Wladimir J. van der Laan
5248ff4 SetupEnvironment() - clean commit (Stuart Cardall)
2014-05-13SetupEnvironment() - clean commitStuart Cardall
2014-05-13remove ParseString(...) which is never usedKamil Domanski
2014-05-12Merge pull request #4138Wladimir J. van der Laan
783b182 Remove dummy PRIszX macros for formatting (Wladimir J. van der Laan)
2014-05-09Remove unused function WildcardMatchWladimir J. van der Laan
No longer necessary after implementing netmask-based matching. Also remove a longer-unused function `skipspaces`.
2014-05-09util: add parseint32 function with strict error reportingWladimir J. van der Laan
None of the current integer parsing functions in util check whether the result is valid and fits in the range of the type. This is required for less sloppy error reporting.
2014-05-06Remove dummy PRIszX macros for formattingWladimir J. van der Laan
Size specifiers are no longer needed now that we use typesafe tinyformat for string formatting, instead of the system's sprintf. No functional changes. This continues the work in #3735.
2014-03-31Wrap create_directory calls in try...catch blocks.Brandon Dahler
Ignores any exceptions thrown if directory exists, otherwise re-throws exception. Rebased-By: Wladimir J. van der Laan <laanwj@gmail.com>
2014-03-03replace custom GetFilesize() with boost::filesystem::file_size()Philip Kaufmann
2014-02-26Merge pull request #3749Wladimir J. van der Laan
4423571 Replace PrintException with PrintExceptionContinue + throw (Wladimir J. van der Laan)
2014-02-26Replace PrintException with PrintExceptionContinue + throwWladimir J. van der Laan
Just a pet peeve. (PrintException has exactly the same body as PrintExceptionContinue but does a re-throw at the end. Move these re-throws to the call site, this aids understanding what is going on as well as eliminates a bit of code duplication in util.cpp)
2014-02-24Remove definition of PRI?64 in util.hWladimir J. van der Laan
This was a bad idea. This can't be solved with macros as any other library that includes inttypes.h will get in the way. The parent commit has removed all usages from the source, this commit removes the definition.
2014-02-24Get rid of C99 PRI?64 usage in source filesWladimir J. van der Laan
Amend to d5f1e72. It turns out that BerkelyDB was including inttypes.h indirectly, so we cannot fix this with just macros. Trivial commit: apply the following script to all .cpp and .h files: # Middle sed -i 's/"PRIx64"/x/g' "$1" sed -i 's/"PRIu64"/u/g' "$1" sed -i 's/"PRId64"/d/g' "$1" # Initial sed -i 's/PRIx64"/"x/g' "$1" sed -i 's/PRIu64"/"u/g' "$1" sed -i 's/PRId64"/"d/g' "$1" # Trailing sed -i 's/"PRIx64/x"/g' "$1" sed -i 's/"PRIu64/u"/g' "$1" sed -i 's/"PRId64/d"/g' "$1" After this commit, `git grep` for PRI.64 should turn up nothing except the defines in util.h.