aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Split up util.cpp/hWladimir J. van der Laan2014-08-261-547/+4
| | | | | | | | | | | | | | | | 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.
* Move `*Version()` functions to version.h/cppWladimir J. van der Laan2014-08-261-25/+0
|
* Move SetThreadPriority implementation to util.cpp instead of the headerWladimir J. van der Laan2014-08-261-0/+13
| | | | Put the THREAD_* and PRIO_ constants in compat.h.
* build: check for sys/prctl.h in the proper wayWladimir J. van der Laan2014-08-121-1/+8
| | | | | Use AC_CHECK_HEADERS to check for the header, and include it only if detected and the subsequent HAVE_SYS_PRCTL_H is set.
* Fix thread name settingWladimir J. van der Laan2014-08-121-2/+2
| | | | | | Because of a typo, thread names no longer appeared in the overview. This was broken in 51ed9ec.
* Can't log to debug log before chain params initializedWladimir J. van der Laan2014-07-151-1/+1
| | | | | | | | | Add a function `AreBaseParamsConfigured` and use this to check before writing to the debug log. This avoids assertions when the application happens to log too early, which happens in the GUI. Messages logged before the base parameters are configured can be shown using `-printtoconsole`.
* move rand functions from util to new random.h/.cppPhilip Kaufmann2014-07-091-108/+1
|
* add GetRandBytes() as wrapper for RAND_bytes()Philip Kaufmann2014-07-091-13/+16
| | | | | | - 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
* Merge pull request #4401Wladimir J. van der Laan2014-07-071-2/+4
|\ | | | | | | cf04d83 add OpenSSL RAND_cleanup() on OpenSSL shutdown (Philip Kaufmann)
| * add OpenSSL RAND_cleanup() on OpenSSL shutdownPhilip Kaufmann2014-06-261-2/+4
| | | | | | | | | | - to securely erase the memory used by the PNRG - also rework 2 comments in OpenSSL init
* | Move ui_interface to bitcoin_server.aWladimir J. van der Laan2014-07-071-2/+0
| | | | | | | | | | There is no need for it in the utility libraries or tools. Put it in init.cpp, and in the tests separately (as they can't link init).
* | Show nodeid instead of addresses (for anonymity) unless otherwise requested.R E Broadley2014-07-041-0/+1
| |
* | Merge pull request #4437Wladimir J. van der Laan2014-06-301-0/+5
|\ \ | | | | | | | | | de79aaa Move non-trivial uint256.h methods to uint256.cpp (Pieter Wuille)
| * | Move non-trivial uint256.h methods to uint256.cppPieter Wuille2014-06-281-0/+5
| | |
* | | Merge pull request #4398Wladimir J. van der Laan2014-06-281-1/+2
|\ \ \ | |/ / |/| | | | | | | | 86fe1b8 update coding.md to reflect changes by pull (Philip Kaufmann) e10dcf2 ensure clean and consistent "namespace" usage (Philip Kaufmann)
| * | ensure clean and consistent "namespace" usagePhilip Kaufmann2014-06-261-1/+2
| |/ | | | | | | | | | | - remove some missplaced ; - ensure end of a namespace is clearly visible - use same formatting when using namespace
* | Merge pull request #4392Wladimir J. van der Laan2014-06-261-11/+26
|\ \ | |/ |/| | | | | | | 8ae973c Allocate more space if necessary in RandSeedAddPerfMon (Wladimir J. van der Laan) be873f6 Issue warning if collecting RandSeed data failed (Wladimir J. van der Laan) fcb0a1b change "char pch[200000]" to "new char[200000]" (daniel)
| * Allocate more space if necessary in RandSeedAddPerfMonWladimir J. van der Laan2014-06-261-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently we use a fixed buffer of 250000 bytes to request HKEY_PERFORMANCE_DATA. In many cases this is not enough, causing the entropy collection to be skipped. Use a loop that grows the buffer as specified in the RegQueryValueEx documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724911%28v=vs.85%29.aspx (as the size of the performance data can differ for every call, the normal solution of requesting the size then allocating that can't work)
| * Issue warning if collecting RandSeed data failedWladimir J. van der Laan2014-06-231-1/+8
| |
| * change "char pch[200000]" to "new char[200000]"daniel2014-06-231-10/+9
| |
* | Remove unnecessary dependencies for bitcoin-cliWladimir J. van der Laan2014-06-251-6/+6
| | | | | | | | | | | | | | | | | | This commit removes all the unnecessary dependencies (key, core, netbase, sync, ...) from bitcoin-cli. To do this it shards the chain parameters into BaseParams, which contains just the RPC port and data directory (as used by utils and bitcoin-cli) and Params, with the rest.
* | Move network-time related functions to timedata.cpp/hWladimir J. van der Laan2014-06-251-77/+0
|/ | | | | The network time-offset-mangement functions from util.cpp are moved to timedata.(cpp|h). This breaks the dependency of util on netbase.
* Merge pull request #4193Wladimir J. van der Laan2014-06-121-12/+8
|\ | | | | | | 71aaff3 Remove double-dash parameters from mapArgs (Kosta Zertsekel)
| * Remove double-dash parameters from mapArgsKosta Zertsekel2014-06-041-12/+8
| | | | | | | | | | | | | | | | | | Should be merged after pull request #4281 ("Add `-version` option to get just the version #4281"), because is changed "--help" to "-help". Checked that grep of 'mapArgs.count("--' returned only three places that are fixed by pull request #4281.
* | util: Add function FormatParagraph to format paragraph to fixed-widthWladimir J. van der Laan2014-06-111-0/+35
| | | | | | | | This is to be used for the `-version` and `-help` messages.
* | small formatting, indentation and comment fixesPhilip Kaufmann2014-06-101-10/+12
| | | | | | | | - contains zero code changes
* | rename fNoListen to fListen and move to netPhilip Kaufmann2014-05-291-1/+0
| | | | | | | | | | - better code readability and it belongs to net - this is a prerequisite for a pull to add -listen to the GUI
* | Merge pull request #4183Wladimir J. van der Laan2014-05-251-6/+0
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | 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)
| * | remove LogException( ) which is never usedKamil Domanski2014-05-201-6/+0
| | |
* | | Replace non-threadsafe gmtime and setlocaleWladimir J. van der Laan2014-05-231-0/+12
|/ / | | | | | | | | | | | | Make DateTimeStrFormat use boost::posix_time. Also re-enable the util_DateTimeStrFormat tests, as they are no longer platform specific.
* | Merge pull request #4174Wladimir J. van der Laan2014-05-191-0/+16
|\ \ | |/ |/| | | 5248ff4 SetupEnvironment() - clean commit (Stuart Cardall)
| * SetupEnvironment() - clean commitStuart Cardall2014-05-131-0/+16
| |
* | remove ParseString(...) which is never usedKamil Domanski2014-05-131-20/+0
|/
* Remove unused function WildcardMatchWladimir J. van der Laan2014-05-091-37/+0
| | | | | No longer necessary after implementing netmask-based matching. Also remove a longer-unused function `skipspaces`.
* util: add parseint32 function with strict error reportingWladimir J. van der Laan2014-05-091-0/+14
| | | | | | 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.
* Wrap create_directory calls in try...catch blocks.Brandon Dahler2014-03-311-1/+18
| | | | | | Ignores any exceptions thrown if directory exists, otherwise re-throws exception. Rebased-By: Wladimir J. van der Laan <[email protected]>
* replace custom GetFilesize() with boost::filesystem::file_size()Philip Kaufmann2014-03-031-18/+1
|
* Merge pull request #3749Wladimir J. van der Laan2014-02-261-9/+0
|\ | | | | | | 4423571 Replace PrintException with PrintExceptionContinue + throw (Wladimir J. van der Laan)
| * Replace PrintException with PrintExceptionContinue + throwWladimir J. van der Laan2014-02-261-9/+0
| | | | | | | | | | | | | | | | | | 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)
* | Get rid of C99 PRI?64 usage in source filesWladimir J. van der Laan2014-02-241-4/+4
|/ | | | | | | | | | | | | | | | | | | | | | | 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.
* Copyright header updates s/2013/2014 on files whose last git commit was done ↵gubatron2014-02-091-1/+1
| | | | | | in 2014. contrib/devtools/fix-copyright-headers.py script to be able to perform this maintenance task with ease during the rest of the year, every year. Modifications to contrib/devtools/README.md to document what fix-copyright-headers.py does.
* Merge pull request #3450Wladimir J. van der Laan2014-01-291-2/+3
|\ | | | | | | 4c0b2cd Win32: use a more modern API call in FileCommit() (Philip Kaufmann)
| * Win32: use a more modern API call in FileCommit()Philip Kaufmann2013-12-201-2/+3
| | | | | | | | | | | | - this seems to be a more recent API call and also supports e.g. SMB3, ReFS, which is not guaranteed for commit_() - link to MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/aa364439%28v=vs.85%29.aspx
* | Remove redundant .c_str()sWladimir J. van der Laan2014-01-231-5/+5
| | | | | | | | | | | | | | After the tinyformat switch sprintf() family functions support passing actual std::string objects. Remove unnecessary c_str calls (236 of them) in logging and formatting.
* | Typesafe strprintf/error/LogPrint functionsWladimir J. van der Laan2014-01-231-68/+10
|/ | | | | | | Switch to tinyformat-based formatting. Tinyformat is a typesafe drop-in replacement for C99 printf functions: https://github.com/c42f/tinyformat
* Remove -logtodebuggerWladimir J. van der Laan2013-12-151-25/+2
| | | | | | | | | `-logtodebugger` is a strange, obscure, WIN32-only (mostly MSVC) thing. Let's clean up the options a bit get rid of it. test_bitcoin was using fLogToDebugger as a way to prevent logging to debug.log. For this, add a boolean (not exposed as option) fLogToDebugLog that defaults to true and is disabled in the tests.
* Use thread-local storage for LogPrint(category...)Gavin Andresen2013-12-101-9/+15
| | | | | | This prevents crashes at shutdown where a global destructor calls LogPrint(category...) after mapMultiArgs has been deleted.
* Fix infinite loop with LogPrint on WindowsGavin Andresen2013-12-101-17/+14
| | | | | | | | | Running -printtodebugger -debug (or -debug=lock), compiled with -DDEBUG_LOCKORDER would infinite loop on Windows because every critical section lock/unlock triggers a LogPrint. Solution is to use the raw boost mutex instead of a CCriticalSection.
* bitcoin-cli: remove unneeded dependencies (only code movement)Wladimir J. van der Laan2013-12-031-0/+2
| | | | | | | | | | | | | | Remove unnecessary dependencies for bitcoin-cli (leveldb, berkelydb, wallet, RPC server) Build system changes: - split libbitcoin.a into libbitcoin_common.a, libbitcoin_server.a and libbitcoin_cli.a Code changes (movement only): - split up HelpMessage into HelpMessage in init.cpp and HelpMessageCli in rpcclient.cpp - move uiInterface from init.cpp to util.cpp
* core: remove includes in .cpp, if header is already in .hPhilip Kaufmann2013-11-151-2/+0
| | | | | - example: if util.h includes stdint.h, remove it from util.cpp, as util.h is the first header included in util.cpp