Commit Graph

409 Commits

Author SHA1 Message Date
Jon Layton 2a63c34936 Merge remote-tracking branch 'btc/master' into upstream-merge 2018-10-16 22:27:53 -05:00
Chun Kuan Lee 380c843217 utils: Convert Windows args to utf-8 string 2018-09-30 15:08:16 +08:00
Chun Kuan Lee 2c3eade704 Make fs::path::string() always return utf-8 string 2018-09-23 03:43:25 +08:00
Arvid Norberg 3ccfa34b32 convert C-style (void) parameter lists to C++ style () 2018-09-13 10:36:41 -07:00
Wladimir J. van der Laan 37b836ad09
Merge #13888: Call unicode API on Windows
d38bf9105d Call unicode API on Windows (Chun Kuan Lee)

Pull request description:

  Call Unicode API on Windows

Tree-SHA512: 93c290ee79c9d911fdada8ba45e184fc4f14d3cb56f33f39223286213878b08e8c4dd296a80099c57797d3b8589870e6cff622b22e76123d7452659d49dd8309
2018-09-13 12:11:44 +02:00
Wladimir J. van der Laan d0b1cee1fe doc: `-help-debug` implies `-help`
I don't understand why `-help-debug` would be useful without requesting
the help, and I've made this particular mistake one time too many.

(ok, so apparently the original reason that -help-debug is an option is
to show debug options in the GUI option overview? that seems very
unlikely to ever be used, if someone wants to add a way to show debug
options in the GUI it'd be better to have a check box)
2018-09-13 07:57:13 +02:00
Wladimir J. van der Laan 1c12cf6073
Merge #13886: utils: run commands using utf-8 string on Windows
23db9546c1 utils: run commands using utf-8 string on Windows (Chun Kuan Lee)

Pull request description:

  Use unicode string to call commans

Tree-SHA512: 72f84e7b56cd947ad05176f10b5ddd5610f4641ba5e93ffd67777dea8f9734ec06e6ed3a63f67ae5e766767122c0dd2c441d0bad5572bdb9fb78758f02531feb
2018-09-12 11:21:04 +02:00
Chun Kuan Lee d38bf9105d Call unicode API on Windows 2018-09-11 21:09:46 +08:00
Wladimir J. van der Laan 362518791a
Merge #13734: gui: Drop boost::scoped_array and use wchar_t API explicitly on Windows
bb6ca65f98 gui: get special folder in unicode (Chun Kuan Lee)
1c5d225853 Drop boost::scoped_array (Chun Kuan Lee)

Pull request description:

  Drop boost::scoped_array and simplify the code.

  `TCHAR` should be defined as `wchar_t` if `UNICODE` is defined. So we can use `.toStdWString().c_str()` to get wchar_t C-style string.

  Fix #13819

Tree-SHA512: 3fd4aa784129c9d1576b01e6ee27faa42d793e152d132f2dde504d917dad3a8e95e065fcbc54a3895d74fb6b2a9ed4f5ec67d893395552f585e225486a84a454
2018-09-11 10:58:10 +02:00
Wladimir J. van der Laan a6aca8dc2f
Merge #14105: util: Report parse errors in configuration file
ed2332aeff test: Add test for config file parsing errors (MarcoFalke)
a66c0f78a9 util: Report parse errors in configuration file (Wladimir J. van der Laan)

Pull request description:

  Report errors while parsing the configuration file, instead of silently ignoring them.

      $ src/bitcoind -regtest
      Error reading configuration file: parse error on line 22: nodebuglogfile, if you intended to specify a negated option, use nodebuglogfile=1 instead
      $ src/bitcoind -regtest
      Error reading configuration file: parse error on line 22: sdafsdfafs
      $ src/bitcoind -regtest
      Error reading configuration file: parse error on line 24: -nodebuglogfile=1, options in the configuration file must be specified without leading -

  (inspired by https://github.com/bitcoin/bitcoin/pull/14100#issuecomment-417264823)

Tree-SHA512: d516342b65db2969edf200390994bbbda23654c648f85dcc99f9f2d217d3d59a72e0f58227be7b4746529dcfa54ba26d8188ba9f14a57c9ab00015d7283fade2
2018-09-06 12:56:10 +02:00
Wladimir J. van der Laan a66c0f78a9 util: Report parse errors in configuration file
Report errors while parsing the configuration file, instead of silently
ignoring them.

    $ src/bitcoind -regtest
    Error reading configuration file: parse error on line 22: nodebuglogfile, if you intended to specify a negated option, use nodebuglogfile=1 instead
    $ src/bitcoind -regtest
    Error reading configuration file: parse error on line 22: sdafsdfafs
    $ src/bitcoind -regtest
    Error reading configuration file: parse error on line 24: -nodebuglogfile=1, options in the configuration file must be specified without leading -
2018-08-30 14:41:33 +02:00
practicalswift 1e29379d69 Fix potential deadlock 2018-08-30 10:02:49 +02:00
practicalswift d58dc9f943 Add lock annotations (cs_args) 2018-08-29 22:33:33 +02:00
practicalswift db5e9d3c88 Add missing locks (cs_args) 2018-08-29 20:57:41 +02:00
Chun Kuan Lee 1661a472b8 add unicode compatible file_lock for Windows
boost::interprocess::file_lock cannot open the files that contain characters which cannot be parsed by the user's code page on Windows.
This commit add a new class to handle those specific file for Windows.
2018-08-28 00:55:13 +08:00
Chun Kuan Lee 23db9546c1 utils: run commands using utf-8 string on Windows 2018-08-27 03:24:34 +08:00
MarcoFalke ddddce0e46
util: Replace boost::signals2 with std::function 2018-08-24 08:34:38 -04:00
Wladimir J. van der Laan 78dae8cacc
Merge #13780: 0.17: Pre-branch maintenance
3fc20632a3 qt: Set BLOCK_CHAIN_SIZE = 220 (DrahtBot)
2b6a2f4a28 Regenerate manpages (DrahtBot)
eb7daf4d60 Update copyright headers to 2018 (DrahtBot)

Pull request description:

  Some trivial maintenance to avoid having to do it again after the 0.17 branch off.

  (The scripts to do this are in `./contrib/`)

Tree-SHA512: 16b2af45e0351b1c691c5311d48025dc6828079e98c2aa2e600dc5910ee8aa01858ca6c356538150dc46fe14c8819ed8ec8e4ec9a0f682b9950dd41bc50518fa
2018-08-08 13:55:27 +02:00
Chun Kuan Lee bb6ca65f98 gui: get special folder in unicode 2018-08-04 02:47:58 +08:00
Pieter Wuille 04ce0d88ca Report when unknown config file options are ignored 2018-07-30 00:35:44 -07:00
DrahtBot eb7daf4d60 Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
fanquake 3828a79711
scripted-diff: prefer MAC_OSX over __APPLE__
-BEGIN VERIFY SCRIPT-
sed -i 's/__APPLE__/MAC_OSX/g' src/compat/byteswap.h src/util.cpp
-END VERIFY SCRIPT-
2018-07-25 07:30:28 +08:00
AtsukiTak 9544a3f3fc tiny refactor for ArgsManager
This commit contains 2 refactors.

1. mark "const" on ArgsManager::GetHelpMessage and IsArgKnown.
2. remove unused "error" argument from ArgsManager::IsArgKnown.

Firstly, I mark "const" on where it is possible to. It is mentioned
before (e.g. https://github.com/bitcoin/bitcoin/pull/13190#pullrequestreview-118823133).

And about 2nd change, ArgsManager::IsArgKnown was added at commit #4f8704d which was
merged at PR #13112. But from its beggining, "error" argument never be used.
I think it should be refactored.
2018-07-22 03:16:53 +09:00
Chun Kuan Lee 11588c639e Replace boost program_options 2018-07-18 02:48:25 +00:00
Jon Layton 31fe6ee585 [fixup] Remove TryCreateDirectory for MacOS ZcashParams, as it is no longer used in bitcoin 2018-07-16 13:39:56 -05:00
Andrew Chow c2dfbb4a97 Add unavailable options to hidden options category
Options that are not available (but known in the source code) will
cause an error if they are specified.
Make these options "available" by adding them to the hidden options
category to prevent conf files from failing when shared between binaries
that have different options available.
2018-06-12 14:33:35 -07:00
jc 9559fafe9c [chainparams] Update params for BTCP chain 2018-06-04 07:21:52 -04:00
jc 27a9fcf14c [primitives] Add Joinsplit primitives 2018-06-03 15:27:02 -04:00
MarcoFalke fa4760fbb3
qa: Increase includeconf test coverage 2018-06-01 13:24:50 -04:00
Andrew Chow 4f8704d57f Give an error and exit if there are unknown parameters
If an unknown option is given via either the command line args or
the conf file, throw an error and exit

Update tests for ArgsManager knowing args

Ignore unknown options in the config file for bitcoin-cli

Fix tests and bitcoin-cli to match actual options used
2018-05-30 11:27:50 -04:00
Andrew Chow 174f7c8080 Use a struct for arguments and nested map for categories
Instead of a single map with the category and name as the key,
make m_available_args contain maps. The key will be the category and
the value is a map which actually contains the arguments for that
category. The nested map's key is the argument name, while the value
is a struct that contains the help text and whether the argument is
a debug only argument.
2018-05-30 11:09:15 -04:00
Wladimir J. van der Laan 3d4fa83587 Stop translating command line options
Many options are extremely technical, and refer internals, making it
difficult to translate usefully. This came up in discussion of e.g.
 #10949. If a message is not understood by translators (which are
typically end-users, not developers) they'll either translate it
literally, making it harder to understand instead of easier, with the
added drawback of the user no longer being able to google it.

Also the translation was only working for bitcoin-qt as with
the console programs, there is no translation backend. So it was
injecting never-used translation messages for bitcoin-cli, -tx.

For these reasons, stop translating options help completely. This should
not affect the output **in any way** except for bitcoin-qt when a
non-English language is configured in the locale.

This implements #10962.
2018-05-30 14:23:35 +02:00
Karl-Johan Alm c5bcc7dbe9
util: warn about recursive -includeconf arguments in configuration files
Since -includeconf cannot be used recursively, the user would not see feedback that an -includeconf
in an -includeconf'd file was silently ignored.
2018-05-10 11:02:20 +09:00
Andrew Chow 4d4185a4f0 Make gArgs aware of the arguments
gArgs knows what the available arguments are and their help. Getting
the help message is moved to gArgs and HelpMessage() is removed
2018-05-09 12:21:05 -04:00
Wladimir J. van der Laan 7b966d9e6e
Merge #10267: New -includeconf argument for including external configuration files
25b7ab9 doc: Add release notes for -includeconf (Karl-Johan Alm)
0f0badd test: Test includeconf parameter. (Karl-Johan Alm)
629ff8c -includeconf=<path> support in config handler, for including external configuration files (Karl-Johan Alm)

Pull request description:

  Fixes: #10071.

  Done:
  - adds `-includeconf=<path>`, where `<path>` is relative to `datadir` or to the path of the file being read, if in a file
  - protects against circular includes
  - updates help docs

  ~~~Thoughts:~~~
  - ~~~I am not sure how to test this in a neat manner. Feedback on this would be nice. Will dig/think though.~~~

Tree-SHA512: cb31f1b2f69fbc0890d264948eb2e501ac05cf12f5e06a5942f9c1539eb15ea8dc3cae817f4073aecb2fcc21d0386747f14f89d990772003a76e2a6d25642553
2018-05-09 06:36:54 +02:00
practicalswift 29c9bdcc14 Handle unsuccessful fseek(...):s 2018-05-02 12:12:55 +02:00
Karl-Johan Alm 629ff8c358
-includeconf=<path> support in config handler, for including external configuration files 2018-04-26 12:46:28 +09:00
Wladimir J. van der Laan cf0277928f Add logging and error handling for file syncing
Add logging and error handling inside, and outside of FileCommit.
Functions such as fsync, fdatasync will return error in case of hardware
I/O errors, and ignoring this means it can silently continue through
data corruption.  (c.f.
https://lwn.net/SubscriberLink/752063/12b232ab5039efbe/)
2018-04-23 14:25:28 +02:00
Jim Posen b77b6e2345 MOVEONLY: Move logging code from util.{h,cpp} to new files. 2018-04-18 10:05:05 -07:00
Evan Klitzke 6a3b0d3d1a Print to console by default when not run with -daemon
Printing to the debug log file can be disabled with -nodebulogfile
2018-04-17 09:58:05 +02:00
Anthony Towns 005ad26649 ArgsManager: special handling for -regtest and -testnet 2018-04-11 23:15:28 +10:00
Anthony Towns 68797e20f4 ArgsManager: Warn when ignoring network-specific config setting
When network-specific options such as -addnode, -connect, etc are
specified in the default section of the config file, but that setting is
ignored due to testnet or regtest being in use, and it is not overridden
by either a command line option or a setting in the [regtest] or [test]
section of the config file, a warning is added to the log, eg:

  Warning: Config setting for -connect only applied on regtest network when in [regtest] section.
2018-04-11 23:15:28 +10:00
Anthony Towns d1fc4d95af ArgsManager: limit some options to only apply on mainnet when in default section
When specified in bitcoin.conf without using the [regtest] or [test]
section header, or a "regtest." or "test." prefix, the "addnode",
"connect", "port", "bind", "rpcport", "rpcbind", and "wallet" settings
will only be applied when running on mainnet.
2018-04-11 23:15:28 +10:00
Anthony Towns 95eb66d584 ArgsManager: support config file sections 2018-04-11 23:15:28 +10:00
Anthony Towns 4d34fcc713 ArgsManager: drop m_negated_args
When a -nofoo option is seen, instead of adding it to a separate
set of negated args, set the arg as being an empty vector of strings.

This changes the behaviour in some ways:
 - -nofoo=0 still sets foo=1 but no longer treats it as a negated arg
 - -nofoo=1 -foo=2 has GetArgs() return [2] rather than [2,0]
 - "foo=2 \n -nofoo=1" in a config file no longer returns [2,0], just [0]
 - GetArgs returns an empty vector for negated args
2018-04-11 23:15:28 +10:00
Anthony Towns 3673ca36ef ArgsManager: keep command line and config file arguments separate 2018-04-11 18:13:54 +10:00
Wladimir J. van der Laan b86730a4d7 util: Remove designator initializer from ScheduleBatchPriority
Although no compiler appears to complain about it, these are
not valid for c++11.
(http://en.cppreference.com/w/cpp/language/aggregate_initialization says they're c++20)

The structure is defined as:

   struct sched_param {
       int sched_priority;
   };

So passing 0 for the first field has the same effect.
2018-04-09 17:02:19 +02:00
Wladimir J. van der Laan cff66e6a29 util: Pass pthread_self() to pthread_setschedparam instead of 0
Nowhere in the man page of `pthread_setschedparam` it is mentioned that
`0` is a valid value. The example uses `pthread_self()`, so should we.

(noticed by Anthony Towns)
2018-04-09 15:44:46 +02:00
Jonas Schnelli 25c56cdbe7
Merge #12878: [refactor] Config handling refactoring in preparation for network-specific sections
77a733a99 [tests] Add additional unit tests for -nofoo edge cases (Anthony Towns)
af173c2be [tests] Check GetChainName works with config entries (Anthony Towns)
fa27f1c23 [tests] Add unit tests for ReadConfigStream (Anthony Towns)
087c5d204 ReadConfigStream: assume the stream is good (Anthony Towns)
6d5815aad Separate out ReadConfigStream from ReadConfigFile (Anthony Towns)
834d30341 [tests] Add unit tests for GetChainName (Anthony Towns)
11b6b5b86 Move ChainNameFromCommandLine into ArgsManager and rename to GetChainName (Anthony Towns)

Pull request description:

  This does a bit of refactoring of the configuration handling code in order to add additional tests to make adding support for [test]/[regtest] sections in the config file in #11862 easier. Should not cause any behaviour changes.

Tree-SHA512: 8d2ce1449fc180de03414e7e569d1a21ba1e9f6564e13d3faf3961f710adc725fa0d4ab49b89ebd2baa11ea36ac5018377f693a84037d386a8b8697c9d6db3e9
2018-04-08 16:24:30 +02:00
Wladimir J. van der Laan becd8dd2ec
Merge #12618: Set SCHED_BATCH priority on the loadblk thread.
d54874d Set SCHED_BATCH priority on the loadblk thread. (Evan Klitzke)

Pull request description:

  Today I came across #10271, and while reading the discussion #6358 was linked to. Linux systems have a `SCHED_BATCH` scheduler priority that is useful for threads like loadblk. You can find the full details at [sched(7)](http://man7.org/linux/man-pages/man7/sched.7.html), but I'll quote the relevant part of the man page below:

  > ...this policy will cause the scheduler to always assume that the thread is
  CPU-intensive. Consequently, the scheduler will apply a small scheduling penalty
  with respect to wakeup behavior, so that this thread is mildly disfavored in
  scheduling decisions.
  >
  > This policy is useful for workloads that are noninteractive, but do not want to
  lower their nice value, and for workloads that want a deterministic scheduling
  policy without interactivity causing extra preemptions (between the workload's
  tasks).

  I think this change is useful independently of #10271 and irrespective of whether that change is merged. Under normal operation the loadblk thread will just import `mempool.dat`. However, if Bitcoin is started with `-reindex` or `-reindex-chainstate` this thread will use a great deal of CPU while it rebuilds the chainstate database (and the block database in the case of `-reindex`). By setting `SCHED_BATCH` this thread is less likely to interfere with interactive tasks (e.g. the user's web browser, text editor, etc.).

  I'm leaving the nice value unchanged (which also affects scheduling decisions) because I think that's better set by the user. Likewise I'm not using [ioprio_set(2)](http://man7.org/linux/man-pages/man2/ioprio_set.2.html) because it can cause the thread to become completely I/O starved (and knowledgeable users can use `ionice(1)` anyway).

Tree-SHA512: ea8f7d3921ed5708948809da771345cdc33efd7ba3323e9dfec07a25bc21e8612e2676f9c178e2710c7bc437e8c9cafc5e0463613688fea5699b6e8e2fec6cff
2018-04-07 19:48:39 +02:00