Commit Graph

341 Commits

Author SHA1 Message Date
James O'Beirne 54604600c3 Add AbsPathForConfigVal to consolidate datadir prefixing for path args
Most commandline/config args are interpreted as relative to datadir if
not passed absolute. Consolidate the logic for this normalization.
2018-02-05 17:48:59 -05:00
MeshCollider 2f3bd47d44 Abstract directory locking into util.cpp 2018-01-16 19:05:46 +13:00
Akira Takizawa 595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
Wladimir J. van der Laan 5d132e8b97
Merge #10574: Remove includes in .cpp files for things the corresponding .h file already included
a720b92 Remove includes in .cpp files for things the corresponding .h file already included (practicalswift)

Pull request description:

  Remove includes in .cpp files for things the corresponding .h file already included.

  Example case:
  * `addrdb.cpp` includes `addrdb.h` and `fs.h`
  * `addrdb.h` includes `fs.h`

  Then remove the direct inclusion of `fs.h` in `addrman.cpp` and rely on the indirect inclusion of `fs.h` via the included `addrdb.h`.

  In line with the header include guideline (see #10575).

Tree-SHA512: 8704b9de3011a4c234db336a39f7d2c139e741cf0f7aef08a5d3e05197e1e18286b863fdab25ae9638af4ff86b3d52e5cab9eed66bfa2476063aa5c79f9b0346
2017-12-12 14:56:25 +01:00
MeshCollider 529b866759 Test datadir in conf file exists 2017-12-06 00:24:06 +13:00
Wladimir J. van der Laan cf5f432c69 Add `-debuglogfile` option
This patch adds an option to configure the name and/or directory of the
debug log.

The user can specify either a relative path, in which case the path
is relative to the data directory. They can also specify an absolute
path to put the log anywhere else in the file system.
2017-11-30 11:16:02 +01:00
Wladimir J. van der Laan ef14f2e3ff
Merge #11191: RPC: Improve help text and behavior of RPC-logging.
c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura)

Pull request description:

  1. It is allowed `libevent` logging to be updated during runtime,
    but still described that restriction in the help text.
    So we delete these text.
  2. Add a descrption about the evaluation order of `<include>` and
    `<exclude>` to clarify how debug loggig categories to be set.
  3. Add a description about the available logging category `"all"`
    which is not explained.
  4. Add `"optional"` to the help text of `<include>` and `<exclude>`.
  5. Add missing new lines before `"Argument:"`.
  6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`.
    `"0"` is **ignored** and `"1"` is treated **same as** `"all"`.
    It is confusing, so forbid them.
  7. It always returns all logging categories with status.
    Fix the help text to match this behavior.

Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415
2017-11-30 10:12:19 +01:00
Akio Nakamura c60c49b679 Improve help text and behavior of RPC-logging
A) The changes in behavior are as follows:
1. Introduce logging category "none" as alias of "0" for
   both RPC-logging and bitcoind "-debug" parameter.
2. Same as "0" is given to argument of "-debug",
   if "none" or "0" is given to <include>, all other given logging
   categories are ignored. The same is true for <exclude>.
   (Before this PR, "0" was accepted but just be ignored itself.)

B) The changes in the help text are as follows:
1. Add a descrption about the evaluation order of <include> and
   <exclude> to clarify how debug loggig categories to be set.
2. Delete text that describe restriction about libevent because
   it's already allowed libevent logging to be updated during runtime.
3. Add a description for category "all", "1", "none" and "0".
4. Add "optional" to the help text of <include> and <exclude>.
5. Add missing new lines before "Argument:".
6. This RPC always returns all logging categories with status.
   Fix the help text to match this behavior.
2017-11-20 17:48:39 +09:00
MeshCollider 8263f6a5ac Create walletdir if datadir doesn't exist and fix tests 2017-11-18 00:50:59 +13:00
practicalswift a720b928c8 Remove includes in .cpp files for things the corresponding .h file already included 2017-11-16 22:26:34 +01:00
MeshCollider 1a445343f6 scripted-diff: Replace #include "" with #include <> (ryanofsky)
-BEGIN VERIFY SCRIPT-
for f in \
  src/*.cpp \
  src/*.h \
  src/bench/*.cpp \
  src/bench/*.h \
  src/compat/*.cpp \
  src/compat/*.h \
  src/consensus/*.cpp \
  src/consensus/*.h \
  src/crypto/*.cpp \
  src/crypto/*.h \
  src/crypto/ctaes/*.h \
  src/policy/*.cpp \
  src/policy/*.h \
  src/primitives/*.cpp \
  src/primitives/*.h \
  src/qt/*.cpp \
  src/qt/*.h \
  src/qt/test/*.cpp \
  src/qt/test/*.h \
  src/rpc/*.cpp \
  src/rpc/*.h \
  src/script/*.cpp \
  src/script/*.h \
  src/support/*.cpp \
  src/support/*.h \
  src/support/allocators/*.h \
  src/test/*.cpp \
  src/test/*.h \
  src/wallet/*.cpp \
  src/wallet/*.h \
  src/wallet/test/*.cpp \
  src/wallet/test/*.h \
  src/zmq/*.cpp \
  src/zmq/*.h
do
  base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-
2017-11-16 08:23:01 +13:00
Wladimir J. van der Laan a1f7f18709
Merge #10939: [init] Check non-emptiness of -blocknotify command prior to executing
cffe85f Skip sys::system(...) call in case of empty command (practicalswift)
6fb8f5f Check that -blocknotify command is non-empty before executing (practicalswift)

Pull request description:

  Check that `-blocknotify` command is non-empty before executing.

  To make the `BlockNotifyCallback(...)` (`-blocknotify`) behaviour consistent with that of:
  * `AlertNotify(...)` (`-alertnotify`)
  * `AddToWallet(...)` (`-walletnotify`)

Tree-SHA512: 18272166793a5a8b9cc2a727bfbcea53d38c329a55bc975c02db601329d608a61c20e026ce4b616193ecd3810dca4d3e2cb3bf773898a51872008a8dba96763e
2017-10-04 14:54:09 +02:00
MarcoFalke 22e301a3d5
Merge #10901: Fix constness of ArgsManager methods
a622a1768 Fix constness of ArgsManager methods (João Barbosa)

Pull request description:

  Make `cs_args` mutex mutable so that const methods can acquire it.

  There's also tiny performance improvement by avoiding two map lookups when retrieving an argument value.

Tree-SHA512: ece58469745f2743b4b643242b51889a3d9c5b76492ed70bb74d4e5b378fff59da79fc129e499da779bf9f488c9435dda17ad1f3a804c1c30f56af422389e8bd
2017-08-16 16:09:27 +02:00
practicalswift cffe85f975 Skip sys::system(...) call in case of empty command 2017-08-14 17:50:31 +02:00
Marko Bencun fcbde9091e remove unused gArgs wrappers 2017-08-14 17:02:36 +02:00
practicalswift 90d4d89230 scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
-BEGIN VERIFY SCRIPT-
sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h
sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp
sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp
sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp
sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp
sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp
-END VERIFY SCRIPT-
2017-08-07 07:36:37 +02:00
João Barbosa a622a17683 Fix constness of ArgsManager methods 2017-07-24 23:56:50 +01:00
Wladimir J. van der Laan ac52492cd2
Merge #10118: Util: Remove redundant calls to argsGlobal.IsArgSet()
ed866ab Indentation after 'Remove redundant calls to gArgs.IsArgSet()' (Jorge Timón)
506b700 Util: Remove redundant calls to gArgs.IsArgSet() (Jorge Timón)

Tree-SHA512: 4f97a0bf2a76c0f351a6343db62898cf057d745c848de00fa09465e870a120f28e0d836cafd6a047f4ec0da7ab671aebee43fa7410c9f0e66382edd1bb2009ba
2017-06-27 16:29:11 +02:00
Jorge Timón 506b700dcb
Util: Remove redundant calls to gArgs.IsArgSet()
Return empty std::vector<std::string> with ArgsManager::GetArgs if
nothing is set for that string
2017-06-27 02:54:19 +02:00
Ricardo Velhote c07475294a
[RPC] Add an uptime command that displays the amount of time that bitcoind has been running 2017-06-25 20:25:45 +01:00
Wladimir J. van der Laan 228c319a94
Merge #9895: Turn TryCreateDirectory() into TryCreateDirectories()
1d1ea9f Turn TryCreateDirectory() into TryCreateDirectories() (Marko Bencun)

Tree-SHA512: 49a524167bcf66e351a964c88d09cb3bcee12769a32da83410e3ba649fa4bcdbf0478d41e4d09bb55adb9b3f122e742271db6feb30bbafe2a7973542b5f10f79
2017-06-14 16:12:14 +02:00
Marko Bencun 1d1ea9f096 Turn TryCreateDirectory() into TryCreateDirectories()
Use case: TryCreateDirectory(GetDataDir() / "blocks" / "index") would
fail if the blocks directory was not explicitly created before.

The line that did so was in a weird location and could be removed as a
result.
2017-06-14 00:04:13 +02:00
Wladimir J. van der Laan 177433ad22
Merge #8694: Basic multiwallet support
c237bd7 wallet: Update formatting (Luke Dashjr)
9cbe8c8 wallet: Forbid -salvagewallet, -zapwallettxes, and -upgradewallet with multiple wallets (Luke Dashjr)
a2a5f3f wallet: Base backup filenames on original wallet filename (Luke Dashjr)
b823a4c wallet: Include actual backup filename in recovery warning message (Luke Dashjr)
84dcb45 Bugfix: wallet: Fix warningStr, errorStr argument order (Luke Dashjr)
008c360 Wallet: Move multiwallet sanity checks to CWallet::Verify, and do other checks on all wallets (Luke Dashjr)
0f08575 Wallet: Support loading multiple wallets if -wallet used more than once (Luke Dashjr)
b124cf0 Wallet: Replace pwalletMain with a vector of wallet pointers (Luke Dashjr)
19b3648 CWalletDB: Store the update counter per wallet (Luke Dashjr)
74e8738 Bugfix: ForceSetArg should replace entr(ies) in mapMultiArgs, not append (Luke Dashjr)
23fb9ad wallet: Move nAccountingEntryNumber from static/global to CWallet (Luke Dashjr)
9d15d55 Bugfix: wallet: Increment "update counter" when modifying account stuff (Luke Dashjr)
f28eb80 Bugfix: wallet: Increment "update counter" only after actually making the applicable db changes to avoid potential races (Luke Dashjr)

Tree-SHA512: 23f5dda58477307bc07997010740f1dc729164cdddefd2f9a2c9c7a877111eb1516d3e2ad4f9b104621f0b7f17369c69fcef13d28b85cb6c01d35f09a8845f23
2017-06-12 13:27:17 +02:00
practicalswift 49de096c2a Remove unused Boost includes 2017-06-09 10:25:26 +02:00
Luke Dashjr 74e8738961 Bugfix: ForceSetArg should replace entr(ies) in mapMultiArgs, not append 2017-06-05 21:04:42 +00:00
Wladimir J. van der Laan d0c37ee789
Merge #10383: [logging] log system time and mock time
761392d [logging] log system time and mock time (John Newbery)

Tree-SHA512: 0a4b3ad74bcac201be490fe12e4b45adeabc39030ac46f40e1aeb2a20b2f3963e4468e65798d8aaeca1818759cab55ff2b2aa214500aa11571492c3301dd31c1
2017-05-16 08:10:05 +02:00
John Newbery 761392db3a [logging] log system time and mock time 2017-05-10 15:49:00 -04:00
Jorge Timón 52922456b8
Util: Put mapMultiArgs inside ArgsManager
- Set ArgsManager::mapMultiArgs in ArgsManager::SoftSetArg, ForceSetArg, SoftSetBoolArg
2017-05-09 21:37:29 +02:00
Jorge Timón f2957ce6cd
Util: Create ArgsManager class...
- Introduce ArgsManager::GetArgs()
- Adapt util_tests.cpp to ArgsManager
2017-05-09 21:29:02 +02:00
fanquake 93dbb15954
Remove Clang workaround for Boost 1.46 2017-04-25 09:16:57 +08:00
John Newbery 7fd50c3b70 allow libevent logging to be updated during runtime 2017-04-10 17:05:59 -04:00
John Newbery 5255aca3f4 [rpc] Add logging RPC
Adds an RPC to get and set currently active logging categories.
2017-04-10 17:05:59 -04:00
Wladimir J. van der Laan f110272dc9 Remove `namespace fs=fs`
Having these inside functions is silly and redundant now.
2017-04-03 12:33:14 +02:00
Wladimir J. van der Laan 2a5f574762 Use fsbridge for fopen and freopen
Abstracts away how a path is opened to a `FILE*`.

Reduces the number of places where path is converted to a string
for anything else but printing.
2017-04-03 12:32:32 +02:00
Wladimir J. van der Laan bac5c9cf64 Replace uses of boost::filesystem with fs
Step two in abstracting away boost::filesystem.

To repeat this, simply run:
```
git ls-files \*.cpp \*.h | xargs sed -i 's/boost::filesystem/fs/g'
```
2017-04-03 12:32:32 +02:00
Wladimir J. van der Laan 7d5172d354 Replace includes of boost/filesystem.h with fs.h
This is step one in abstracting the use of boost::filesystem.
2017-04-03 12:32:32 +02:00
Wladimir J. van der Laan a2cd0b0eec
Merge #10058: No need to use OpenSSL malloc/free
6d5dd60 No need to use OpenSSL malloc/free (Thomas Snider)

Tree-SHA512: 29f790067ffd5a10a8e1a621318a0ba445691f57c804aa3b7c8ca372c8408d8c7fe703c42b48018e400fc32e3feff5ab401d97433910ce2c50e69da0b8a6662e
2017-04-03 12:06:02 +02:00
Gregory Maxwell 6b3bb3d9ba Change LogAcceptCategory to use uint32_t rather than sets of strings.
This changes the logging categories to boolean flags instead of strings.

This simplifies the acceptance testing by avoiding accessing a scoped
 static thread local pointer to a thread local set of strings.  It
 eliminates the only use of boost::thread_specific_ptr outside of
 lockorder debugging.

This change allows log entries to be directed to multiple categories
 and makes it easy to change the logging flags at runtime (e.g. via
 an RPC, though that isn't done by this commit.)

It also eliminates the fDebug global.

Configuration of unknown logging categories now produces a warning.
2017-04-01 18:53:29 +00:00
Wladimir J. van der Laan 625488ace5 util: Work around (virtual) memory exhaustion on 32-bit w/ glibc
glibc-specific: On 32-bit systems set the number of arenas to 1. By
default, since glibc 2.10, the C library will create up to two heap
arenas per core. This is known to cause excessive virtual address space
usage in our usage. Work around it by setting the maximum number of
arenas to 1.
2017-03-30 09:45:41 +02:00
Thomas Snider 6d5dd60c88 No need to use OpenSSL malloc/free 2017-03-28 17:36:31 -07:00
practicalswift 53a2ba351a [util] Remove redundant call to get() on smart pointer (thread_specific_ptr) 2017-03-09 10:22:35 +01:00
Karl-Johan Alm a57845c20e
Refactor: Remove using namespace <xxx> from util* 2017-03-08 08:47:02 -08:00
kirit93 40f11f8872 Fix for issue #9775. Added check for open() returning a NULL pointer. 2017-02-20 23:53:18 +05:30
Alex Morcos 29fb311858 Increase minimum debug.log size to 10MB after shrink. 2017-01-24 20:28:00 -05:00
isle2983 27765b6403 Increment MIT Licence copyright header year on files modified in 2016
Edited via:

$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Matt Corallo c2f61bebb1 Add a ForceSetArg method for testing 2016-12-27 13:52:07 +01:00
Matt Corallo 4e048142a5 Lock mapArgs/mapMultiArgs access in util 2016-12-24 11:29:33 -05:00
Matt Corallo 4cd373aea8 Un-expose mapArgs from utils.h 2016-12-24 11:29:33 -05:00
Matt Corallo 0cf86a6678 Introduce (and use) an IsArgSet accessor method 2016-12-23 21:30:16 -05:00
Matt Corallo 2b5f085ad1 Fix non-const mapMultiArgs[] access after init.
Swap mapMultiArgs for a const-reference to a _mapMultiArgs which is
only accessed in util.cpp
2016-12-23 21:30:15 -05:00