aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
AgeCommit message (Collapse)Author
2013-06-19Introduce a CChainParameters singleton class and regtest mode.Mike Hearn
The new class is accessed via the Params() method and holds most things that vary between main, test and regtest networks. The regtest mode has two purposes, one is to run the bitcoind/bitcoinj comparison tool which compares two separate implementations of the Bitcoin protocol looking for divergence. The other is that when run, you get a local node which can mine a single block instantly, which is highly convenient for testing apps during development as there's no need to wait 10 minutes for a block on the testnet.
2013-06-10changes to thread code (directly use boost::thread)Philip Kaufmann
- removes our NewThread() function an replaces remaining calls with boost::thread with our TraceThread template - remove ExitThread() function - fix THREAD_PRIORITY_ABOVE_NORMAL for non Windows OSes
2013-06-08Create parent directories if needed in GetDataDirWladimir J. van der Laan
One-line change. Fixes #2752.
2013-06-01remove GetBoolArg() fDefault parameter defaulting to falsePhilip Kaufmann
- explicitly set the default of all GetBoolArg() calls - rework getarg_test.cpp and util_tests.cpp to cover this change - some indentation fixes - move macdockiconhandler.h include in bitcoin.cpp to the "our headers" section
2013-05-02clear path cache after getting a proper config file (fixes #2605)Jonas Schnelli
Signed-off-by: Jonas Schnelli <jonas.schnelli@include7.ch>
2013-04-29Try to increase file descriptor rlimit if necessaryPieter Wuille
As the default can be too low, especially on OSX.
2013-04-27Prevent prevent file descriptor leak in ShrinkDebugFile()Tariq Bashir
2013-04-06small indentation, space, formatting fixes (no code changes)Philip Kaufmann
2013-04-03Clean up shutdown processGavin Andresen
2013-04-03Shutdown cleanup prep-workGavin Andresen
Create a boost::thread_group object at the qt/bitcoind main-loop level that will hold pointers to all the main-loop threads. This will replace the vnThreadsRunning[] array. For testing, ported the BitcoinMiner threads to use its own boost::thread_group.
2013-02-22Merge pull request #2229 from sipa/preallocGavin Andresen
Native versions for AllocateFileRange()
2013-02-22Merge pull request #2312 from gmaxwell/random_randomGavin Andresen
ApproximateBestSubset internal RNG to prevent degenerate behavior.
2013-02-22Merge pull request #2160 from petertodd/add-adjustedtime-to-rpc-getinfoGavin Andresen
Add adjustedtime to getinfo RPC call
2013-02-18Internal RNG for approximateBestSubset to prevent degenerate behavior.Gregory Maxwell
This fixes test_bitcoin failures on openbsd reported by dhill on IRC. On some systems rand() is a simple LCG over 2^31 and so it produces an even-odd sequence. ApproximateBestSubset was only using the least significant bit and so every run of the iterative solver would be the same for some inputs, resulting in some pretty dumb decisions. Using something other than the least significant bit would paper over the issue but who knows what other way a system's rand() might get us here. Instead we use an internal RNG with a period of something like 2^60 which is well behaved. This also makes it possible to make the selection deterministic for the tests, if we wanted to implement that.
2013-01-30Drop padding in blk* when finalizing filePieter Wuille
2013-01-30Native versions for AllocateFileRange()Pieter Wuille
2013-01-11Add timeoffset to getinfo RPC callPeter Todd
Provides a method to get the difference between network adjusted time and local time from the RPC interface.
2013-01-01OutputDebugStringF code cleanupGavin Andresen
Initialize the OutputDebugStringF mutex and file pointer using boost::call_once, to be thread-safe. Make the return value of OutputDebugStringF really be the number of characters written (*printf() semantics). Declare the fReopenDebugLog flag volatile, since it is changed from a signal handler. And don't declare OutputDebugStringF() as inline.
2012-12-30Remove 'T' from debug log timestampsJeff Garzik
Space separation between major fields is easier for human eyes and libs to parse.
2012-12-13Merge pull request #2096 from 94m3k1n9/fix-time-formatsPieter Wuille
Change timestamps to use ISO8601 formatting
2012-12-12Change timestamps to use ISO8601 formattingRichard Schwab
2012-12-06Allow lengthy block reconnections to be interruptedPieter Wuille
When the coin database is out of date with the block database, the best block in it is automatically switched to. This reconnection process can take time, so allow it to be interrupted. This also stops block connection as soon as shutdown is requested, leading to a faster shutdown.
2012-11-29Add GetTempPath() to utilPieter Wuille
2012-11-26update CClientUIInterface and remove orphan Wx stuffPhilip Kaufmann
- fix ThreadSafeMessageBox always displays error icon - allow to specify MSG_ERROR / MSG_WARNING or MSG_INFORMATION without a custom caption / title - allow to specify CClientUIInterface::ICON_ERROR / ICON_WARNING and ICON_INFORMATION (which is default) as message box icon - remove CClientUIInterface::OK from ThreadSafeMessageBox-calls, as the OK button will be set as default, if none is specified - prepend "Bitcoin - " to used captions - rename BitcoinGUI::error() -> BitcoinGUI::message() and add function documentation - change all style parameters and enum flags to unsigned - update code to use that new API - update Client- and WalletModel to use new BitcoinGUI::message() and rename the classes error() method into message() - include the possibility to supply the wanted icon for messages from Client- and WalletModel via "style" parameter
2012-11-09don't use memset() in privacy/security relevant code partsPhilip Kaufmann
As memset() can be optimized out by a compiler it should not be used in privacy/security relevant code parts. OpenSSL provides the safe OPENSSL_cleanse() function in crypto.h, which perfectly does the job of clean and overwrite data. For details see: http://www.viva64.com/en/b/0178/ - change memset() to OPENSSL_cleanse() where appropriate - change a hard-coded number from netbase.cpp into a sizeof()
2012-10-20Pre-allocate block and undo files in chunksPieter Wuille
Introduce a AllocateFileRange() function in util, which wipes or at least allocates a given range of a file. It can be overriden by more efficient OS-dependent versions if necessary. Block and undo files are now allocated in chunks of 16 and 1 MiB, respectively.
2012-10-11Merge pull request #1879 from sipa/fdatasyncWladimir J. van der Laan
Use fdatasync instead of fsync on supported platforms
2012-10-11Merge pull request #1901 from laanwj/2012_10_remove_strlcpyWladimir J. van der Laan
get rid of strlcpy.h
2012-10-07Use fdatasync instead of fsync on supported platformsPieter Wuille
2012-10-07get rid of strlcpy.hWladimir J. van der Laan
Don't use hand-rolled string manipulation routine with a fixed buffer in the bitcoin core, instead make use of c++ strings and boost.
2012-10-04Avoid crashes at shutdown due to printf() in global destructors.Gavin Andresen
2012-10-01fix -Wformat warnings all over the sourcePhilip Kaufmann
2012-09-10HexStr: don't build a vector<char> firstWladimir J. van der Laan
Also const correctness for lookup tables in hex functions throughout the code.
2012-09-09Cleanup some unused macros from util.hWladimir J. van der Laan
Encapsulate _snprintf/sprintf difference in implementation not header
2012-09-09Add printf-style warnings to strprintf() and OutputDebugStringF()Wladimir J. van der Laan
This finds about ~150 potential problems with format characters on a 64 bit build.
2012-08-29Rename CreateThread to NewThreadWladimir J. van der Laan
Prevent clash with win32 API symbol
2012-08-29implement CreateThread with boost::threadWladimir J. van der Laan
I'm not sure why this wasn't done before. - Removes typedef of pthread_t on Windows, which fixes a native compile issue on mingw.
2012-08-23Handle locked pages more robustly (Fixes issue #1462)Wladimir J. van der Laan
Memory locks do not stack, that is, pages which have been locked several times by calls to mlock() will be unlocked by a single call to munlock(). This can result in keying material ending up in swap when those functions are used naively. In this commit a class "LockedPageManager" is added that simulates stacking memory locks by keeping a counter per page.
2012-08-21Restore OSX 10.5 compatibility (do not use pthread_setname_np)Gavin Andresen
2012-08-20Suppress output when running unit tests.Gavin Andresen
This does two things: 1) Now does not output to debug.log if -printtodebugger flag is passed 2) Unit tests set -printtodebugger so only test results are output to stdout Note that -printtodebugger only actually prints to the debugger on Windows.
2012-08-01Merge pull request #1632 from luke-jr/spellingJeff Garzik
Fix spelling and grammar errors
2012-08-01Bugfix: Correct English grammar regarding "'s"Luke Dashjr
2012-08-01Update Warning-strings to use a standard-formatPhilip Kaufmann
- ensure warnings always start with "Warning:" and that the first character after ":" is written uppercase - ensure the first sentence in warnings ends with an "!" - remove unneeded spaces from Warning-strings - add missing Warning-string translation - remove a "\n" and replace with untranslatable "<br><br>"
2012-07-21fix OpenSSL not written as proper noun in some commentsPhilip Kaufmann
2012-07-16Teach RenameThread to work on OSXGavin Andresen
2012-07-17Don't check for __linux__ specifically, check for PR_SET_NAME feature insteadGiel van Schijndel
Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-07-17Add support for renaming FreeBSD and OpenBSD threadsGiel van Schijndel
NOTE: This is currently disabled, until a developer with FreeBSD/OpenBSD can confirm that this works (without causing undefined behaviour preferrably). Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-07-17Give threads a recognisable name to aid in debuggingGiel van Schijndel
NOTE: These thread names are visible in gdb when using 'info threads'. Additionally both 'top' and 'ps' show these names *unless* told to display the command-line instead of task name. Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-06-29Fix a few typosfanquake
2012-06-23Merge pull request #1174 from sipa/torhsGregory Maxwell
Tor hidden service support