Commit graph

83 commits

Author SHA1 Message Date
Jeff Garzik 768e5d52fb Add new utility functions FileCommit(), RenameOver() 2012-05-16 19:25:25 -04:00
Wladimir J. van der Laan 67d4cbab46 Move GetStartOnSystemStartup and SetStartOnSystemStartup to GUI code 2012-05-13 12:31:28 +02:00
Pieter Wuille 7f3ccb59da Split synchronization mechanisms from util.{h,cpp} 2012-05-11 18:13:51 +02:00
Pieter Wuille 5456ef3092 Use polling instead of boost's broken semaphore on OSX 2012-05-11 17:02:11 +02:00
Pieter Wuille c59abe2589 Use semaphores instead of condition variables 2012-05-11 17:02:11 +02:00
Jeff Garzik 11b729d8a2 Merge pull request #1134 from Diapolo/util-updates
small util.cpp/h changes
2012-05-09 07:54:25 -07:00
Philip Kaufmann 3e468840bd util.h/.ccp: modifiy some comments / rename MyGetSpecialFolderPath() -> GetSpecialFolderPath(), set fCreate default to true and remove the fallback (not Win >= Vista compatible anyway) / remove namespace fs stuff where only used once / misc small changes' 2012-05-09 12:22:58 +02:00
Matt Corallo 2ea78ec7fd Fix DEBUG_LOCKCONTENTION 2012-05-09 01:41:07 -04:00
Wladimir J. van der Laan 3ee5f8aac3 remove duplicate definition of SecureString in util.h
SecureString was moved to allocators.h in commit 6cb6d62347
2012-05-01 18:49:50 +02:00
Jeff Garzik c2e8c8acd8 Merge pull request #1140 from jgarzik/sign-compare
Address many more sign comparison warnings
2012-04-23 21:33:29 -07:00
Jeff Garzik 735a60698c Change signed->unsigned at 3 code sites
This resolves signed/unsigned comparison warnings.
2012-04-23 14:14:36 -04:00
Pieter Wuille f4203de302 Make GetDataDir return absolute paths 2012-04-22 17:38:47 +02:00
Wladimir J. van der Laan 88dc2d6c6a Integrate @JoelKatz's optimized ToHex (#562) into current HexStr function 2012-04-21 20:37:50 +02:00
Pieter Wuille 6b6aaa1698 Further reduce header dependencies
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.
2012-04-17 20:03:42 +02:00
Pieter Wuille ed6d0b5f85 Remove headers.h 2012-04-17 20:00:55 +02:00
Jeff Garzik 460b66b14b Remove obsolete Win32 AffinityBugWorkaround()
Reference miner exists for testnet-in-a-box type situations, and as a
reference.  We don't care enough about highly optimized internal
mining to keep workarounds like this.
2012-04-12 13:24:00 -04:00
Pieter Wuille ee12c3d60c Use filesystem::path instead of manual string tinkering
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.
2012-04-11 22:30:23 +02:00
Pieter Wuille f342dac1cb Do not report spurious deadlocks caused by TRY_LOCK 2012-04-09 01:59:57 +02:00
Pieter Wuille f8dcd5ca6f Use scoped locks instead of CRITICAL_BLOCK 2012-04-09 01:59:46 +02:00
Pieter Wuille 712fd182b7 Locking system overhaul, add condition variables
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.
2012-04-04 16:21:08 +02:00
Wladimir J. van der Laan 5d7cebdadc move translation function _ to qtui.h/noui.h instead of util.h 2012-04-04 09:35:01 +02:00
Wladimir J. van der Laan 6cb6d62347 remove dependency on serialize.h and util.h for SecureString 2012-04-04 09:35:01 +02:00
Wladimir J. van der Laan 52d3a48128 VC2010 compile fixes 2012-04-03 20:22:41 +02:00
Pieter Wuille 6b8de05d0a Begin doxygen-compatible comments 2012-03-26 16:48:23 +02:00
Wladimir J. van der Laan a6aee96c7e remove unused functions from util.h/util.cpp 2012-03-25 12:33:30 +02:00
Gregory Maxwell 82a10c8170 Resolves issue #922 - "wallet passphrase timeout of several years doesn't work"
2^31 milliseconds is only about 25 days. Also clamps Sleep() to 10 years,
because it currently sleeps for 0 seconds when the sleep time would cross
2^31 seconds since the epoch. Hopefully boost will be fixed by 2028.
2012-03-10 17:38:37 -05:00
Gavin Andresen 3f8cb2c565 Reworked QT settings 2012-02-26 23:38:28 +01:00
Pieter Wuille 88bc5f9485 Macros for manual critical sections 2012-02-11 21:59:33 +01:00
Gavin Andresen 882164196e Update all copyrights to 2012 2012-02-07 11:28:30 -05:00
Gavin Andresen 3ae0735553 Unit tests for the GetArg() methods 2012-02-07 09:14:31 -05:00
Gavin Andresen 7bf8b7c25c -bip16 option (default: 1) to support / not support BIP 16. And bumped default BIP16 switchover date from Feb 15 to Mar 1 2012-02-06 16:27:05 -05:00
Lars Rasmusson b985efaac1 Replace tabs with four spaces to comply with coding standard in doc/coding.txt 2012-01-14 12:14:36 +01:00
Gavin Andresen 922e8e2929 Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16). 2012-01-13 10:22:23 -05:00
Pieter Wuille 67a42f929b Network stack refactor
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.
2012-01-06 18:55:37 +01:00
Gavin Andresen 0fcf91ea1e Fix issue #659, and cleanup wallet/command-line argument handling a bit 2012-01-03 10:17:28 -05:00
Wladimir J. van der Laan bde280b9a4 Revert "Use standard C99 (and Qt) types for 64-bit integers"
This reverts commit 21d9f36781.
2011-12-21 22:33:19 +01:00
Luke Dashjr 21d9f36781 Use standard C99 (and Qt) types for 64-bit integers 2011-12-20 16:52:59 -05:00
Gavin Andresen 387c8e3c5b Merge pull request #673 from mndrix/less-time-data
Store fewer time samples
2011-12-20 08:55:55 -08:00
Gavin Andresen 26ce92b352 Use std::numeric_limits<> for typesafe INT_MAX/etc 2011-12-19 19:10:34 -05:00
Gavin Andresen bd846c0e56 Cleanup: removed dead code, and use C99 typedefs for int64 (supported by all modern c++ compilers) 2011-12-19 19:10:34 -05:00
Gavin Andresen 1f3bc1c239 Merge pull request #707 from gavinandresen/BIP14
Implement BIP 14 : separate protocol version from client version
2011-12-19 07:25:16 -08:00
Gavin Andresen f8ded588a2 Implement BIP 14 : separate protocol version from client version 2011-12-19 10:24:23 -05:00
Gavin Andresen 6e39e7c9b3 Move more newlines out of strings, and fix translations. 2011-12-16 17:13:45 -05:00
Michael Hendricks 1c4aab926e Retain only the most recent time samples
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.
2011-12-01 17:28:14 -07:00
Dylan Noblesmith 94f778bdeb Implement an mlock()'d string class for storing passphrases
SecureString is identical to std::string except with secure_allocator
substituting for std::allocator. This makes casting between them
impossible, so converting between the two at API boundaries requires
calling ::c_str() for now.
2011-11-26 06:02:04 +00:00
Clark Gaebel 3083cf100a Cleaned up the critical section macros. 2011-11-02 04:33:55 -04:00
Gavin Andresen 6853e627f1 Fix build on windows and mac
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.
2011-10-07 11:02:21 -04:00
Victor Leschuk b95e6376d0 Fix for 64bit build 2011-10-06 19:53:42 +04:00
Nils Schneider 452506fc41 simpler ByteReverse 2011-09-30 20:00:30 +02:00
Nils Schneider 6ccff2cbde remove cryptopp dependency, add simple unittest for SHA256Transform() 2011-09-30 20:00:22 +02:00