aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
AgeCommit message (Collapse)Author
2014-06-26Merge pull request #4392Wladimir J. van der Laan
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)
2014-06-26Allocate more space if necessary in RandSeedAddPerfMonWladimir J. van der Laan
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)
2014-06-25Remove unnecessary dependencies for bitcoin-cliWladimir J. van der Laan
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.
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-23Issue warning if collecting RandSeed data failedWladimir J. van der Laan
2014-06-23change "char pch[200000]" to "new char[200000]"daniel
2014-06-12Merge pull request #4193Wladimir J. van der Laan
71aaff3 Remove double-dash parameters from mapArgs (Kosta Zertsekel)
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-10small formatting, indentation and comment fixesPhilip Kaufmann
- contains zero code changes
2014-06-04Remove double-dash parameters from mapArgsKosta Zertsekel
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.
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-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-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-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.
2014-02-09Copyright header updates s/2013/2014 on files whose last git commit was done ↵gubatron
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.
2014-01-29Merge pull request #3450Wladimir J. van der Laan
4c0b2cd Win32: use a more modern API call in FileCommit() (Philip Kaufmann)
2014-01-23Remove redundant .c_str()sWladimir J. van der Laan
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.
2014-01-23Typesafe strprintf/error/LogPrint functionsWladimir J. van der Laan
Switch to tinyformat-based formatting. Tinyformat is a typesafe drop-in replacement for C99 printf functions: https://github.com/c42f/tinyformat
2013-12-20Win32: use a more modern API call in FileCommit()Philip Kaufmann
- 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
2013-12-15Remove -logtodebuggerWladimir J. van der Laan
`-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.
2013-12-10Use thread-local storage for LogPrint(category...)Gavin Andresen
This prevents crashes at shutdown where a global destructor calls LogPrint(category...) after mapMultiArgs has been deleted.
2013-12-10Fix infinite loop with LogPrint on WindowsGavin Andresen
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.
2013-12-03bitcoin-cli: remove unneeded dependencies (only code movement)Wladimir J. van der Laan
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
2013-11-15core: remove includes in .cpp, if header is already in .hPhilip Kaufmann
- example: if util.h includes stdint.h, remove it from util.cpp, as util.h is the first header included in util.cpp
2013-11-13Use C99 printf statements in mingwWladimir J. van der Laan
Otherwise, format specifiers such as %llu will not work on XP or earlier. This bug was introduced with 51ed9ec9. http://sourceforge.net/apps/trac/mingw-w64/wiki/gnu%20printf
2013-11-11Refactor: pull alert string sanitization into utilGavin Andresen
2013-11-10Cleanup code using forward declarations.Brandon Dahler
Use misc methods of avoiding unnecesary header includes. Replace int typedefs with int##_t from stdint.h. Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h. Normalize QT_VERSION ifs where possible. Resolve some indirect dependencies as direct ones. Remove extern declarations from .cpp files.
2013-11-04Merge pull request #3076 from lano1106/uint256_utilWladimir J. van der Laan
Make util phexdigit array reusable
2013-11-01Merge pull request #3114Pieter Wuille
a616206 Give peer time-adjustment data an own lock (Pieter Wuille)
2013-10-30re-work -debug switch handlingPhilip Kaufmann
- re-work -debug help message text - make -debug log every debugging information again (even all categories) - remove unneeded fDebug checks in front of LogPrint()/qDebug(), as that check is done in LogPrintf() when category is != NULL (true for all LogPrint() calls - remove fDebug ONLY in code which is NOT performance-critical - harmonize addrman category name - deprecate -debugnet usage, should be used via -debug=net and remove the corresponding global
2013-10-27Make util phexdigit array reusableOlivier Langlois
class template base_uint had its own private lookup table. This is saving 256 bytes per instantiation. The result is not spectacular as bitcoin-qt has only shrinked of about 1Kb but it is still valid improvement. Also, I have replaced a for loop with a memset() call. Made CBigNum::SetHex() use the new HexDigit() function. Signed-off-by: Olivier Langlois <olivier@olivierlanglois.net>
2013-10-26Give peer time-adjustment data an own lockPieter Wuille
Instead of relying on cs_main (defined in a different module) to prevent concurrent access to it.
2013-10-20Merge pull request #3046 from sarchar/lockedpage-changeGavin Andresen
Changing LockedPageManager to use a managed instance
2013-10-20Bump Year Number to 2013super3
2013-10-20Changing LockedPageManager to use a managed instanceChuck
This ensures the allocator is ready no matter when it's needed (as some STL implementations allocate in constructors -- i.e., MSVC's STL in debug builds). Using boost::call_once to guarantee thread-safe static initialization. Adding some comments describing why the change was made. Addressing deinitialization of the LockedPageManager object by initializing it in a local static initializer and adding an assert in the base's destructor.
2013-10-08make fCommandLine a local variable in AppInit()Philip Kaufmann
2013-09-20fix some printf -> LogPrintf leftoversPhilip Kaufmann
2013-09-18Replace printf with LogPrintf / LogPrintGavin Andresen
2013-09-18Refactor: OutputDebugStringF -> LogPrint(category, ...)Gavin Andresen
2013-09-15More fixes for blockchain corruption on OSX.Gregory Maxwell
As we'd previously learned, OSX's fsync is a data eating lie. Since 0.8.4 we're still getting some reports of disk corruption on OSX but now all of it looks like the block files have gotten out of sync with the database. It turns out that we were still using fsync() on the block files, so this isn't surprising.