aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix bugs on 'unsigned char' platforms.Dwayne C. Litzenberger2012-04-181-4/+4
| | | | | | | | | | | | | | | | | | In ISO C++, the signedness of 'char' is undefined. On some platforms (e.g. ARM), 'char' is an unsigned type, but some of the code relies on 'char' being signed (as it is on x86). This is indicated by compiler warnings like this: bignum.h: In constructor 'CBigNum::CBigNum(char)': bignum.h:81:59: warning: comparison is always true due to limited range of data type [-Wtype-limits] util.cpp: In function 'bool IsHex(const string&)': util.cpp:427:28: warning: comparison is always false due to limited range of data type [-Wtype-limits] In particular, IsHex erroneously returned true regardless of the input characters, as long as the length of the string was a positive multiple of 2. Note: For testing, it's possible using GCC to force char to be unsigned by adding the -funsigned-char parameter to xCXXFLAGS.
* Fix phexdigits[255] is undefined.Dwayne C. Litzenberger2012-04-181-1/+1
|
* Further reduce header dependenciesPieter Wuille2012-04-171-0/+1
| | | | | | | This commit removes the dependency of serialize.h on PROTOCOL_VERSION, and makes this parameter required instead of implicit. This is much saner, as it makes the places where changing a version number can have an influence obvious.
* Remove headers.hPieter Wuille2012-04-171-1/+170
|
* Remove unused and unreachable codeWladimir J. van der Laan2012-04-171-1/+0
|
* fix warnings: array subscript is of type 'char' [-Wchar-subscripts]Wladimir J. van der Laan2012-04-151-3/+3
|
* work around issue in boost::program_options that prevents from compiling in ↵Wladimir J. van der Laan2012-04-151-0/+11
| | | | clang
* Merge pull request #1087 from sipa/fix_1086Gavin Andresen2012-04-121-2/+2
|\ | | | | Fix #1086: add /testnet to passed datadir
| * Fix #1086: add /testnet to passed datadirPieter Wuille2012-04-131-2/+2
| |
* | Fix OSX build errors.Gavin Andresen2012-04-121-1/+1
|/
* Use filesystem::path instead of manual string tinkeringPieter Wuille2012-04-111-83/+59
| | | | | | | | | | | | | | Where possible, use boost::filesystem::path instead of std::string or char* for filenames. This avoids a lot of manual string tinkering, in favor of path::operator/. GetDataDir is also reworked significantly, it now only keeps two cached directory names (the network-specific data dir, and the root data dir), which are decided through a parameter instead of pre-initialized global variables. Finally, remove the "upgrade from 0.1.5" case where a debug.log in the current directory has to be removed.
* Remove path.make_preferred() calls, and fix compiler error in bitcoinrpc RE: ↵Gavin Andresen2012-04-111-3/+0
| | | | boost::system
* Merge pull request #1054 from sipa/buildinfoPieter Wuille2012-04-101-6/+1
|\ | | | | Build identification strings
| * Build identification stringsPieter Wuille2012-04-101-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All client version information is moved to version.cpp, which optionally (-DHAVE_BUILD_INFO) includes build.h. build.h is automatically generated on supporting platforms via contrib/genbuild.sh, using git describe. The git export-subst attribute is used to put the commit id statically in version.cpp inside generated archives, and this value is used if no build.h is present. The gitian descriptors are modified to use git archive instead of a copy, to create the src/ directory in the output. This way, src/src/version.cpp will contain the static commit id. To prevent gitian builds from getting the "-dirty" marker in their git-describe generated identifiers, no touching of files or running sed on the makefile is performed anymore. This does not seem to influence determinism.
* | Merge pull request #1052 from sipa/scopedlocksPieter Wuille2012-04-091-12/+12
|\ \ | | | | | | Use scoped locks instead of CRITICAL_BLOCK
| * | Do not report spurious deadlocks caused by TRY_LOCKPieter Wuille2012-04-091-4/+4
| | |
| * | Support for parametrized locks in deadlock detectorPieter Wuille2012-04-091-9/+9
| | |
| * | Use scoped locks instead of CRITICAL_BLOCKPieter Wuille2012-04-091-1/+1
| |/
* / updated util.cpp to use make_preferred()Philip Kaufmann2012-04-061-9/+14
|/
* Merge pull request #1033 from sipa/waitPieter Wuille2012-04-061-52/+4
|\ | | | | Condition variables instead of polling
| * Locking system overhaul, add condition variablesPieter Wuille2012-04-041-52/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit simplifies the locking system: CCriticalSection becomes a simple typedef for boost::interprocess::interprocess_recursive_mutex, and CCriticalBlock and CTryCriticalBlock are replaced by a templated CMutexLock, which wraps boost::interprocess::scoped_lock. By making the lock type a template parameter, some critical sections can now be changed to non-recursive locks, which support waiting via condition variables. These are implemented in CWaitableCriticalSection and WAITABLE_CRITICAL_BLOCK. CWaitableCriticalSection is a wrapper for a different Boost mutex, which supports waiting/notification via condition variables. This should enable us to remove much of the used polling code. Important is that this mutex is not recursive, so functions that perform the locking must not call eachother. Because boost::interprocess::scoped_lock does not support assigning and copying, I had to revert to the older CRITICAL_BLOCK macros that use a nested for loop instead of a simple if.
* | removed obsolete boost workaround (boost ticket #4258)Philip Kaufmann2012-04-051-10/+0
|/
* qtui.h/noui.h interface cleanupWladimir J. van der Laan2012-04-041-1/+1
| | | | | | | - rename wxMessageBox, remove redundant arguments to noui/qtui calls - also, add flag to force blocking, modal dialog box for disk space warning etc - clarify function naming - no more special MessageBox needed from AppInit2, as window object is created before calling AppInit2
* VC2010 compile fixesWladimir J. van der Laan2012-04-031-4/+4
|
* remove unused functions from util.h/util.cppWladimir J. van der Laan2012-03-251-11/+0
|
* Merge branch '2012_02_getspecialfolderpath_overflow' of ↵Gavin Andresen2012-02-281-33/+10
|\ | | | | | | https://github.com/laanwj/bitcoin
| * Simplify MyGetSpecialFolderPath and fix possible buffer overflow (#901)Wladimir J. van der Laan2012-02-261-33/+10
| |
* | Reworked QT settingsGavin Andresen2012-02-261-2/+16
|/
* Fix #846. Allow negative options such as "nolisten=1" in bitcoin.conf as ↵Chris Moore2012-02-161-11/+21
| | | | well as on the command line.
* Update all copyrights to 2012Gavin Andresen2012-02-071-1/+1
|
* New GetArg features: allow --, and booleans can be -foo or -nofooGavin Andresen2012-02-071-0/+28
|
* Unit tests for the GetArg() methodsGavin Andresen2012-02-071-1/+26
|
* -bip16 option (default: 1) to support / not support BIP 16. And bumped ↵Gavin Andresen2012-02-061-1/+1
| | | | default BIP16 switchover date from Feb 15 to Mar 1
* Add DEBUG_LOCKCONTENTION, to warn each time a thread waits to lock.Matt Corallo2012-01-211-1/+22
| | | | | If compiled with -DDEBUG_LOCKCONTENTION, Bitcoin will print to debug.log each time a thread has to wait for a lock to continue.
* Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).Gavin Andresen2012-01-131-18/+28
|
* Network stack refactorPieter Wuille2012-01-061-3/+3
| | | | | | | | | | | | | | | This introduces CNetAddr and CService, respectively wrapping an (IPv6) IP address and an IP+port combination. This functionality used to be part of CAddress, which also contains network flags and connection attempt information. These extra fields are however not always necessary. These classes, along with logic for creating connections and doing name lookups, are moved to netbase.{h,cpp}, which does not depend on headers.h. Furthermore, CNetAddr is mostly IPv6-ready, though IPv6 functionality is not yet enabled for the application itself.
* Fix issue #659, and cleanup wallet/command-line argument handling a bitGavin Andresen2012-01-031-0/+17
|
* Revert "Use standard C99 (and Qt) types for 64-bit integers"Wladimir J. van der Laan2011-12-211-30/+27
| | | | This reverts commit 21d9f36781604e4ca9fc35dc65265593423b73e9.
* Use standard C99 (and Qt) types for 64-bit integersLuke Dashjr2011-12-201-27/+30
|
* Merge pull request #673 from mndrix/less-time-dataGavin Andresen2011-12-201-12/+12
|\ | | | | Store fewer time samples
| * Retain only the most recent time samplesMichael Hendricks2011-12-011-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remembering all time samples makes nTimeOffset slow to respond to system clock corrections. For instance, I start my node with a system clock that's 30 minutes slow and run it for a few days. During that time, I accumulate 10,000 offset samples with a median of 1800 seconds. Now I correct my system clock. Without this change, my node must collect another 10,000 samples before nTimeOffset is correct again. With this change, I must only accumulate 100 samples to correct the offset. Storing unlimited time samples also allows an attacker with many IP addresses (ex, a large botnet) to perform a memory exhaustion attack against Bitcoin nodes. The attacker sends a version message from each IP to his target, consuming more of the target's memory each time. Time samples are small, so this attack might be impractical under the old code, but it's impossible with the new code.
| * Only log time samples in debug modeMichael Hendricks2011-12-011-3/+6
| | | | | | | | | | | | The full list of time samples is rarely useful outside of debugging. The node's time offset, however is useful for discovering local clock drift, so it's displayed in all logging modes.
* | Use std::numeric_limits<> for typesafe INT_MAX/etcGavin Andresen2011-12-191-1/+1
| |
* | Implement BIP 14 : separate protocol version from client versionGavin Andresen2011-12-191-1/+13
|/
* Fix build on windows and macGavin Andresen2011-10-071-8/+8
| | | | | | Replaced all occurrences of #if* __WXMSW__ with WIN32, and all occurrences of __WXMAC_OSX__ with MAC_OSX, and made sure those are defined appropriately in the makefile and bitcoin-qt.pro.
* remove possibility of 63 bit overflow in ParseMoneyWladimir J. van der Laan2011-10-011-1/+1
| | | | - also, add unit tests for various functions in util.cpp/util.h
* Inline base64 encoder/decoderPieter Wuille2011-09-271-35/+114
| | | | | | | This replaces the openssl-based base64 encoder and decoder with a more efficient internal one. Tested against the rfc4648 test vectors. Decoder is based on JoelKatz' version.
* Faster Base64 decoder.JoelKatz2011-09-271-0/+59
|
* Remove wxWidgetsGavin Andresen2011-09-261-42/+0
| | | | | | | Makefiles now build bitcoind only. qmake/make in top-level directory is used to build Bitcoin QT Deleted almost all #ifdef GUI from the code (left one possibly controversial one) Deleted xpm/ files.
* Merge pull request #517 from gavinandresen/DoSpreventionGavin Andresen2011-09-261-0/+9
|\ | | | | Denial-of-service prevention