Commit Graph

209 Commits

Author SHA1 Message Date
Gavin Andresen 17faf56262 Refactor: pull alert string sanitization into util 2013-11-11 10:22:45 +10:00
Brandon Dahler 51ed9ec971 Cleanup code using forward declarations.
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-10 09:36:28 -06:00
Philip Kaufmann 3b570559f8 re-work -debug switch handling
- 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-30 16:02:09 +01:00
super3 db0e8ccd90 Bump Year Number to 2013 2013-10-20 15:25:06 -04:00
Philip Kaufmann 917ac1dcc1 make fCommandLine a local variable in AppInit() 2013-10-08 10:52:42 +02:00
Gavin Andresen 881a85a22d Replace printf with LogPrintf / LogPrint 2013-09-18 20:39:25 +10:00
Gavin Andresen e51321fb75 Refactor: OutputDebugStringF -> LogPrint(category, ...) 2013-09-18 20:39:24 +10:00
Philip Kaufmann d78900cc1b fix some cosmetic glitches in the codebase
- rename URL into URI in paymentserver where correct
- add some missing Qt-coding-stuff in paymentserver
- change QSpinBox to QLineEdit as base for BitcoinAmountField in .ui files
  (as this is the result when converting the BAF back into base)
- remove some c_str() and replace with QString::fromStdString()
- remove several new-lines
- remove unneeded spaces
- indentation fixes
2013-09-09 12:36:04 +02:00
Cory Fields 35b8af9226 autotools: switch to autotools buildsystem 2013-09-05 21:31:03 -04:00
Jeff Garzik 3d86e7cd48 Merge pull request #2618 from fcicq/solaris-support
Partial solaris support
2013-08-24 20:19:24 -07:00
Gavin Andresen 42656ea2e5 Make RPC password resistant to timing attacks
Fixes issue#2838; this is a tweaked version of pull#2845 that
should not leak the length of the password and is more generic,
in case we run into other situations where we need
timing-attack-resistant comparisons.
2013-08-08 19:58:57 +10:00
Gavin Andresen e622f3f195 Merge pull request #2855 from Diapolo/guard_CreatePidFile
exclude CreatePidFile() function on WIN32 as it is unused
2013-08-05 01:05:59 -07:00
Gavin Andresen 050d2e953f Remove #define loop from util.h
Replace the loop macro with while (true). The #define caused
problems for Qt.
2013-07-31 14:06:44 +10:00
Philip Kaufmann a034c7ebb6 exclude CreatePidFile() function on WIN32 as it is unused 2013-07-24 09:30:09 +02:00
fcicq 9371403993 Add missing constant for solaris 2013-07-17 16:50:51 +08:00
Pieter Wuille c43da3f183 Dump addresses every 15 minutes instead of 10 seconds 2013-06-24 11:48:14 +02:00
Mike Hearn 0e4b317555 Introduce a CChainParameters singleton class and regtest mode.
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-19 16:28:52 +02:00
theuni e2654c8d28 fixed: don't use thread::sleep_for where it's known to be broken
Fixes #2690.
2013-06-14 00:01:57 -04:00
theuni f2763d6d60 fixed: include boost header as necessary
Without this include, sometimes BOOST_VERSION was defined and sometimes
it was not, depending on which includes came before it. The result was a
random mix of sleep or sleep_for for boost versions >= 1.50.
2013-06-13 23:40:59 -04:00
Philip Kaufmann 53e71135de changes to thread code (directly use boost::thread)
- 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-10 19:49:54 +02:00
Philip Kaufmann 3260b4c090 remove GetBoolArg() fDefault parameter defaulting to false
- 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-06-01 12:53:57 +02:00
Jeff Garzik 3fbd87e0dc Merge pull request #2552 from Diapolo/win-typedef
remove obsolete and unused typedef for Windows
2013-05-30 09:42:47 -07:00
Pieter Wuille 5d891489ab Make CPubKey statically allocated 2013-05-30 05:18:42 +02:00
Robert Backhaus 65ec9eab2b Explicitly #include stdarg.h, for access to va_list 2013-05-24 23:45:08 +10:00
Pieter Wuille ba29a5590b Try to increase file descriptor rlimit if necessary
As the default can be too low, especially on OSX.
2013-04-29 01:46:24 +02:00
Philip Kaufmann 61032f8942 remove obsolete and unused typedef for Windows 2013-04-23 09:54:29 +02:00
Philip Kaufmann b001c87126 small indentation, space, formatting fixes (no code changes) 2013-04-06 02:29:33 +02:00
Gavin Andresen b31499ec72 Clean up shutdown process 2013-04-03 19:57:53 -04:00
Gavin Andresen 72f14d26ec LoopForever and ThreadTrace helpers 2013-04-03 19:57:13 -04:00
Gavin Andresen 1b43bf0d3a Rename util.h Sleep --> MilliSleep
Two reasons for this change:
1. Need to always use boost::thread's sleep, even on Windows, so the
sleeps can be interrupted (prior code used Windows' built-in Sleep).

2. I always forgot what units the old Sleep took.
2013-04-03 14:04:21 -04:00
Gavin Andresen c8c2fbe07f Shutdown cleanup prep-work
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-04-03 14:04:21 -04:00
Gavin Andresen b8f4e42e1b Merge pull request #2229 from sipa/prealloc
Native versions for AllocateFileRange()
2013-02-22 09:00:13 -08:00
Gavin Andresen aaeb443791 Merge pull request #2312 from gmaxwell/random_random
ApproximateBestSubset internal RNG to prevent degenerate behavior.
2013-02-22 08:57:38 -08:00
Gavin Andresen 802a3dfdcc Merge pull request #2160 from petertodd/add-adjustedtime-to-rpc-getinfo
Add adjustedtime to getinfo RPC call
2013-02-22 08:47:45 -08:00
Gregory Maxwell 907a2aa4c7 Internal RNG for approximateBestSubset to prevent degenerate behavior.
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-02-18 14:13:39 -08:00
Pieter Wuille 1eb578796c Drop padding in blk* when finalizing file 2013-01-30 04:55:38 +01:00
Peter Todd 8686f6467c Add timeoffset to getinfo RPC call
Provides a method to get the difference between network adjusted time
and local time from the RPC interface.
2013-01-11 06:11:34 -05:00
Gavin Andresen ee3374234c OutputDebugStringF code cleanup
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.
2013-01-01 17:12:30 -05:00
Pieter Wuille 0fb9073edd Split off hash.h from util.h 2012-12-18 21:39:29 +01:00
Gavin Andresen 043a8fb98d Merge pull request #2059 from sipa/benchmark
Add -benchmark for reporting block processing times
2012-12-12 09:14:52 -08:00
Pieter Wuille 3fb9b99cca Allow lengthy block reconnections to be interrupted
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-12-06 22:04:59 +01:00
Pieter Wuille 0ae0712b1c Add GetTimeMicros() for ore accurate benchmarking 2012-12-05 23:06:01 +01:00
Pieter Wuille 597fa4cd63 Add GetTempPath() to util 2012-11-29 01:00:35 +01:00
Pieter Wuille bba89aa82a Pre-allocate block and undo files in chunks
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-20 23:08:57 +02:00
Wladimir J. van der Laan bcc292b22d Extend printf warnings to error() 2012-10-01 19:45:41 +02:00
Philip Kaufmann 9c8dc7caf1 harmonize printf format characters
- remove the "%" character from format characters for (s)size_t and
  ptrdiff_t and harmonize them with the ones for int64 and uint64
2012-09-30 11:57:25 +02:00
Pieter Wuille 2e3ffb2d82 Remove stack randomization 2012-09-28 21:53:28 +02:00
Wladimir J. van der Laan 5a1a362215 Merge pull request #1807 from laanwj/2012_09_printf_warnings
Add printf-style warnings to strprintf() and OutputDebugStringF()
2012-09-25 22:56:29 -07:00
Jeff Garzik ea0796bde3 Trim trailing whitespace for src/*.{h,cpp} 2012-09-18 15:07:58 -04:00
Wladimir J. van der Laan 3b3d999618 Add format characters for (s)size_t and ptrdiff_t 2012-09-10 04:25:26 +02:00
Wladimir J. van der Laan ac4e7f6269 HexStr: don't build a vector<char> first
Also const correctness for lookup tables in hex functions throughout the code.
2012-09-10 04:24:57 +02:00
Wladimir J. van der Laan 963af6449f Cleanup some unused macros from util.h
Encapsulate _snprintf/sprintf difference in implementation not header
2012-09-09 15:47:29 +02:00
Wladimir J. van der Laan b0a90fbb0c Add printf-style warnings to strprintf() and OutputDebugStringF()
This finds about ~150 potential problems with format characters on a 64 bit build.
2012-09-09 14:47:31 +02:00
Wladimir J. van der Laan 4d1d94c56c Rename CreateThread to NewThread
Prevent clash with win32 API symbol
2012-08-29 20:25:37 +02:00
Wladimir J. van der Laan 61d8507140 implement CreateThread with boost::thread
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-29 20:02:07 +02:00
Philip Kaufmann efdcf94174 fix further spelling errors / remove a tab in the source 2012-08-02 10:09:29 +02:00
Luke Dashjr 814efd6f1f Bugfix: Fix a variety of misspellings 2012-08-01 17:49:51 +00:00
Giel van Schijndel 96931d6f78 Give threads a recognisable name to aid in debugging
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-07-17 01:50:35 +02:00
Pieter Wuille 6ece1d747e CHashWriter that does SHA256 in-place during serialization 2012-07-07 23:09:14 +02:00
Gregory Maxwell 817ee0d826 Merge pull request #1174 from sipa/torhs
Tor hidden service support
2012-06-23 19:21:13 -07:00
Jeff Garzik d62a1947be Merge pull request #1458 from jgarzik/tracenet
Introduce -tracenet option, thereby quieting some redundant debug messages
2012-06-22 10:13:31 -07:00
Jeff Garzik d07eaba195 Introduce -debugnet option, thereby quieting some redundant debug messages
Prior to this change, each TX typically generated 3+ debug messages,

	askfor tx 8644cc97480ba1537214   0
	sending getdata: tx 8644cc97480ba1537214
	askfor tx 8644cc97480ba1537214   1339640761000000
	askfor tx 8644cc97480ba1537214   1339640881000000
	CTxMemPool::accept() : accepted 8644cc9748 (poolsz 6857)

After this change, there is only one message for each valid TX received

	CTxMemPool::accept() : accepted 22a73c5d8c (poolsz 42)

and two messages for each orphan tx received

	ERROR: FetchInputs() : 673dc195aa mempool Tx prev not found 1e439346fc
	stored orphan tx 673dc195aa (mapsz 19)

The -debugnet option, or its superset -debug, will restore the full debug
output.
2012-06-22 13:11:57 -04:00
Pieter Wuille c4c99ade65 Base32 encoding/decoding 2012-06-22 17:19:28 +02:00
Gavin Andresen 550c73f4c8 Merge branch 'signbugs' of https://github.com/wizeman/bitcoin
Resolved minor conflict in main.cpp
2012-06-18 10:48:40 -04:00
Ricardo M. Correia 31ac53fbdc Move NOINLINE definition to test where it's used. 2012-06-07 20:22:18 +02:00
Ricardo M. Correia 43346904e1 Don't overflow integer on 32-bit machines.
This was causing test_bitcoin to abort on a 32-bit system likely due to -ftrapv.
2012-06-07 20:22:10 +02:00
Ricardo M. Correia 78e851f94f Fix noinline definition so that it works for more compilers. 2012-05-31 20:33:14 +02:00
Jeff Garzik 429039d45d Refactor: move runCommand() to util.cpp 2012-05-23 23:10:59 -04:00
Gavin Andresen d0e4051cd8 Merge branch 'optimize' 2012-05-22 11:13:00 -04:00
Pieter Wuille 63407fd6e2 Merge pull request #917 from mndrix/reopen-log-file
Reopen log file on SIGHUP
2012-05-21 10:04:26 -07:00
Pieter Wuille 46784d0826 Merge pull request #1354 from fanquake/master
Update Header Licenses
2012-05-20 12:27:50 -07:00
Wladimir J. van der Laan 01ecb074a7 Merge pull request #1302 from laanwj/2012_05_utilstrings
Get rid of snprintf (except one) with fixed buffers, shorten code
2012-05-20 01:30:18 -07:00
Michael Hendricks 9af080c351 Reopen debug.log on SIGHUP
The best log rotation method formerly available was to configure
logrotate with the copytruncate option.  As described in the logrotate
documentation, "there is a very small time slice between copying the
file and truncating it, so some logging data might be lost".

By sending SIGHUP to the server process, one can now reopen the debug
log file without losing any data.
2012-05-18 16:20:03 -06:00
Fordy 3a25a2b9b0 Update License in File Headers
I originally created a pull to replace the "COPYING" in crypter.cpp and
crypter.h, but it turned out that COPYING was actually the correct
file.
2012-05-18 22:02:28 +08:00
Gavin Andresen f718aedd9f Refactor: GetRandHash() method for util 2012-05-17 16:33:27 -04:00
Jeff Garzik 768e5d52fb Add new utility functions FileCommit(), RenameOver() 2012-05-16 19:25:25 -04:00
Wladimir J. van der Laan 29b79e4c0e Get rid of snprintf (except one) with fixed buffers, shorten code
- Use strprintf or vstrprintf instead of snprintf
2012-05-14 20:01:26 +02: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