aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
Commit message (Collapse)AuthorAgeFilesLines
* scripted-diff: Move util files to separate directory.Jim Posen2018-11-041-1299/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- mkdir -p src/util git mv src/util.h src/util/system.h git mv src/util.cpp src/util/system.cpp git mv src/utilmemory.h src/util/memory.h git mv src/utilmoneystr.h src/util/moneystr.h git mv src/utilmoneystr.cpp src/util/moneystr.cpp git mv src/utilstrencodings.h src/util/strencodings.h git mv src/utilstrencodings.cpp src/util/strencodings.cpp git mv src/utiltime.h src/util/time.h git mv src/utiltime.cpp src/util/time.cpp sed -i 's/<util\.h>/<util\/system\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilmemory\.h>/<util\/memory\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilmoneystr\.h>/<util\/moneystr\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilstrencodings\.h>/<util\/strencodings\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utiltime\.h>/<util\/time\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/BITCOIN_UTIL_H/BITCOIN_UTIL_SYSTEM_H/g' src/util/system.h sed -i 's/BITCOIN_UTILMEMORY_H/BITCOIN_UTIL_MEMORY_H/g' src/util/memory.h sed -i 's/BITCOIN_UTILMONEYSTR_H/BITCOIN_UTIL_MONEYSTR_H/g' src/util/moneystr.h sed -i 's/BITCOIN_UTILSTRENCODINGS_H/BITCOIN_UTIL_STRENCODINGS_H/g' src/util/strencodings.h sed -i 's/BITCOIN_UTILTIME_H/BITCOIN_UTIL_TIME_H/g' src/util/time.h sed -i 's/ util\.\(h\|cpp\)/ util\/system\.\1/g' src/Makefile.am sed -i 's/utilmemory\.\(h\|cpp\)/util\/memory\.\1/g' src/Makefile.am sed -i 's/utilmoneystr\.\(h\|cpp\)/util\/moneystr\.\1/g' src/Makefile.am sed -i 's/utilstrencodings\.\(h\|cpp\)/util\/strencodings\.\1/g' src/Makefile.am sed -i 's/utiltime\.\(h\|cpp\)/util\/time\.\1/g' src/Makefile.am sed -i 's/-> util ->/-> util\/system ->/' test/lint/lint-circular-dependencies.sh sed -i 's/src\/util\.cpp/src\/util\/system\.cpp/g' test/lint/lint-format-strings.py test/lint/lint-locale-dependence.sh sed -i 's/src\/utilmoneystr\.cpp/src\/util\/moneystr\.cpp/g' test/lint/lint-locale-dependence.sh sed -i 's/src\/utilstrencodings\.\(h\|cpp\)/src\/util\/strencodings\.\1/g' test/lint/lint-locale-dependence.sh sed -i 's/src\\utilstrencodings\.cpp/src\\util\\strencodings\.cpp/' build_msvc/libbitcoinconsensus/libbitcoinconsensus.vcxproj -END VERIFY SCRIPT-
* Merge #13878: utils: Add fstream wrapper to allow to pass unicode filename ↵Wladimir J. van der Laan2018-10-181-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | on Windows 43c7fbb1e79a4a2219306bf3da1a2dfdf9213f2c Make MSVC compiler read the source code using utf-8 (Chun Kuan Lee) f86a571edb9627c126b9ccd7da68bd7d1657b8f8 tests: Add test case for std::ios_base::ate (Chun Kuan Lee) a554cc901a32f41162089d6b20ad39d5aeff0583 Move boost/std fstream to fsbridge (Chun Kuan Lee) 86eb3b3f1ab594142b6baa9576717ff121f3b745 utils: Add fsbridge fstream function wrapper (Chun Kuan Lee) Pull request description: If compiled with mingw, use glibc++ extension `stdio_filebuf` to open the file by `FILE*` instead of filename. In other condition, we can use boost::fstream. Tree-SHA512: b5dbd83e347fb9b2a0c8b1c2c7bd71a272e839ec0617883b2a0ec12506ae9e825373cf6e95b9bcc91d7edc85bf51580a7716b56a9ecaad776bc3ae61638cb3da
| * Move boost/std fstream to fsbridgeChun Kuan Lee2018-09-261-2/+2
| |
* | utils: Convert Windows args to utf-8 stringChun Kuan Lee2018-09-301-0/+32
|/
* Make fs::path::string() always return utf-8 stringChun Kuan Lee2018-09-231-0/+4
|
* convert C-style (void) parameter lists to C++ style ()Arvid Norberg2018-09-131-1/+1
|
* Merge #13888: Call unicode API on WindowsWladimir J. van der Laan2018-09-131-1/+1
|\ | | | | | | | | | | | | | | | | | | d38bf9105d33147c899117a4c20ba7872733186f Call unicode API on Windows (Chun Kuan Lee) Pull request description: Call Unicode API on Windows Tree-SHA512: 93c290ee79c9d911fdada8ba45e184fc4f14d3cb56f33f39223286213878b08e8c4dd296a80099c57797d3b8589870e6cff622b22e76123d7452659d49dd8309
| * Call unicode API on WindowsChun Kuan Lee2018-09-111-1/+1
| |
* | doc: `-help-debug` implies `-help`Wladimir J. van der Laan2018-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | 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)
* | Merge #13886: utils: run commands using utf-8 string on WindowsWladimir J. van der Laan2018-09-121-0/+5
|\ \ | |/ |/| | | | | | | | | | | | | | | 23db9546c16c2be264cfc4f695f5738a2f5beeeb utils: run commands using utf-8 string on Windows (Chun Kuan Lee) Pull request description: Use unicode string to call commans Tree-SHA512: 72f84e7b56cd947ad05176f10b5ddd5610f4641ba5e93ffd67777dea8f9734ec06e6ed3a63f67ae5e766767122c0dd2c441d0bad5572bdb9fb78758f02531feb
| * utils: run commands using utf-8 string on WindowsChun Kuan Lee2018-08-271-0/+5
| |
* | Merge #13734: gui: Drop boost::scoped_array and use wchar_t API explicitly ↵Wladimir J. van der Laan2018-09-111-3/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | on Windows bb6ca65f9890e8280ace32de5a37774e14705859 gui: get special folder in unicode (Chun Kuan Lee) 1c5d22585384c8bb05a27a04eab5c57b31d623fb 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
| * | gui: get special folder in unicodeChun Kuan Lee2018-08-041-3/+3
| | |
* | | Merge #14105: util: Report parse errors in configuration fileWladimir J. van der Laan2018-09-061-5/+18
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ed2332aeffb071a3404be9cff8f9fb8a81a9fbfb test: Add test for config file parsing errors (MarcoFalke) a66c0f78a941968340f030911765a84219908c4d 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
| * | | util: Report parse errors in configuration fileWladimir J. van der Laan2018-08-301-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 -
* | | | Fix potential deadlockpracticalswift2018-08-301-5/+15
| | | |
* | | | Add lock annotations (cs_args)practicalswift2018-08-291-2/+2
| | | |
* | | | Add missing locks (cs_args)practicalswift2018-08-291-9/+11
|/ / /
* | / add unicode compatible file_lock for WindowsChun Kuan Lee2018-08-281-14/+8
| |/ |/| | | | | | | 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.
* | util: Replace boost::signals2 with std::functionMarcoFalke2018-08-241-2/+0
| |
* | Merge #13780: 0.17: Pre-branch maintenanceWladimir J. van der Laan2018-08-081-1/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3fc20632a3ad30809356a58d2cf0ea4a4ad4cec3 qt: Set BLOCK_CHAIN_SIZE = 220 (DrahtBot) 2b6a2f4a28792f2fe9dc1be843b1ff1ecae35e8a Regenerate manpages (DrahtBot) eb7daf4d600eeb631427c018a984a77a34aca66e 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
| * | Update copyright headers to 2018DrahtBot2018-07-271-1/+1
| |/
* / Report when unknown config file options are ignoredPieter Wuille2018-07-301-3/+7
|/
* scripted-diff: prefer MAC_OSX over __APPLE__fanquake2018-07-251-1/+1
| | | | | | -BEGIN VERIFY SCRIPT- sed -i 's/__APPLE__/MAC_OSX/g' src/compat/byteswap.h src/util.cpp -END VERIFY SCRIPT-
* tiny refactor for ArgsManagerAtsukiTak2018-07-221-4/+4
| | | | | | | | | | | | | | 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.
* Replace boost program_optionsChun Kuan Lee2018-07-181-9/+38
|
* Add unavailable options to hidden options categoryAndrew Chow2018-06-121-0/+7
| | | | | | | | 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.
* qa: Increase includeconf test coverageMarcoFalke2018-06-011-6/+14
|
* Give an error and exit if there are unknown parametersAndrew Chow2018-05-301-6/+45
| | | | | | | | | | | 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
* Use a struct for arguments and nested map for categoriesAndrew Chow2018-05-301-24/+56
| | | | | | | | | 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.
* Stop translating command line optionsWladimir J. van der Laan2018-05-301-13/+13
| | | | | | | | | | | | | | | | | | | 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.
* util: warn about recursive -includeconf arguments in configuration filesKarl-Johan Alm2018-05-101-0/+18
| | | | | Since -includeconf cannot be used recursively, the user would not see feedback that an -includeconf in an -includeconf'd file was silently ignored.
* Make gArgs aware of the argumentsAndrew Chow2018-05-091-0/+49
| | | | | gArgs knows what the available arguments are and their help. Getting the help message is moved to gArgs and HelpMessage() is removed
* Merge #10267: New -includeconf argument for including external configuration ↵Wladimir J. van der Laan2018-05-091-1/+34
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * -includeconf=<path> support in config handler, for including external ↵Karl-Johan Alm2018-04-261-1/+34
| | | | | | | | configuration files
* | Handle unsuccessful fseek(...):spracticalswift2018-05-021-1/+3
|/
* Add logging and error handling for file syncingWladimir J. van der Laan2018-04-231-6/+22
| | | | | | | | 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/)
* MOVEONLY: Move logging code from util.{h,cpp} to new files.Jim Posen2018-04-181-270/+0
|
* Print to console by default when not run with -daemonEvan Klitzke2018-04-171-5/+10
| | | | Printing to the debug log file can be disabled with -nodebulogfile
* ArgsManager: special handling for -regtest and -testnetAnthony Towns2018-04-111-2/+18
|
* ArgsManager: Warn when ignoring network-specific config settingAnthony Towns2018-04-111-0/+28
| | | | | | | | | | 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.
* ArgsManager: limit some options to only apply on mainnet when in default sectionAnthony Towns2018-04-111-4/+34
| | | | | | | 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.
* ArgsManager: support config file sectionsAnthony Towns2018-04-111-2/+37
|
* ArgsManager: drop m_negated_argsAnthony Towns2018-04-111-19/+44
| | | | | | | | | | | 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
* ArgsManager: keep command line and config file arguments separateAnthony Towns2018-04-111-23/+82
|
* util: Remove designator initializer from ScheduleBatchPriorityWladimir J. van der Laan2018-04-091-1/+1
| | | | | | | | | | | | | | 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.
* util: Pass pthread_self() to pthread_setschedparam instead of 0Wladimir J. van der Laan2018-04-091-1/+1
| | | | | | | 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)
* Merge #12878: [refactor] Config handling refactoring in preparation for ↵Jonas Schnelli2018-04-081-17/+37
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * ReadConfigStream: assume the stream is goodAnthony Towns2018-04-061-17/+17
| |
| * Separate out ReadConfigStream from ReadConfigFileAnthony Towns2018-04-061-4/+10
| |