aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
AgeCommit message (Collapse)Author
2018-03-27Merge #10742: scripted-diff: Use scoped enumerations (C++11, "enum class")Wladimir J. van der Laan
1f45e21 scripted-diff: Convert 11 enums into scoped enums (C++11) (practicalswift) Pull request description: Rationale (from Bjarne Stroustrup's ["C++11 FAQ"](http://www.stroustrup.com/C++11FAQ.html#enum)): > > The enum classes ("new enums", "strong enums") address three problems with traditional C++ enumerations: > > * conventional enums implicitly convert to int, causing errors when someone does not want an enumeration to act as an integer. > * conventional enums export their enumerators to the surrounding scope, causing name clashes. > * the underlying type of an enum cannot be specified, causing confusion, compatibility problems, and makes forward declaration impossible. > > The new enums are "enum class" because they combine aspects of traditional enumerations (names values) with aspects of classes (scoped members and absence of conversions). Tree-SHA512: 9656e1cf4c3cabd4378c7a38d0c2eaf79e4a54d204a3c5762330840e55ee7e141e188a3efb2b4daf0ef3110bbaff80d8b9253abf2a9b015cdc4d60b49ac2b914
2018-03-26Set SCHED_BATCH priority on the loadblk thread.Evan Klitzke
While reading another PR I saw a mention of #6358. The use case for SCHED_BATCH is to hint to the kernel that the thread is running a non-interactive workload that consumes a lot of CPU time. This is helpful on desktop machines where the loadblk thread can interfere with interactive applications. More details can be found in the sched(7) man page.
2018-03-26init: Fix help message for checkblockindexMarcoFalke
2018-03-26[wallet] Move wallet init functions into WalletInit class.John Newbery
2018-03-26Merge #12756: [config] Remove blockmaxsize optionWladimir J. van der Laan
4757c04 [config] Remove blockmaxsize option (John Newbery) Pull request description: The blockmaxsize option was marked as deprecated in V0.15.1, and code was added to convert provided blockmaxsize into blockmaxweight. However, this code was incorrectly implemented, and blockmaxsize was silently ignored. No users have complained about blockmaxsize being ignored, so just remove it in V0.17. Fixes #12640 cc @ajtowns Tree-SHA512: 968d71d37bf175c5a02539ddec289a12586f886e1dfe64c1d9aa5e39db48d06d21665153824fac3b11503a55f0812d2f1115a2d726aafd37b76ed629ec0aa671
2018-03-22[config] Remove blockmaxsize optionJohn Newbery
The blockmaxsize option was marked as deprecated in V0.15.1, and code was added to convert provided blockmaxsize into blockmaxweight. However, this code was incorrectly implemented, and blockmaxsize was silently ignored. No users have complained about blockmaxsize being ignored, so just remove it in V0.17.
2018-03-22Merge #12630: Provide useful error message if datadir is not writable.Wladimir J. van der Laan
8674e74 Provide relevant error message if datadir is not writable. (murrayn) Pull request description: If the --datadir exists, but is not writable, the current error message on startup is 'Cannot obtain a lock on data directory foo. Bitcoin Core is probably already running.' This is misleading. I believe this PR addresses #11668, although the issue is not Windows-specific. Tree-SHA512: 10cbbaea433072aee4fb3e8938a72073c7a5c841f7a7685c9e12549c322b2925c7d34bac254ac33021b23132bfc352c058712bc9542298cf86f8fd9757f528b2
2018-03-14Provide relevant error message if datadir is not writable.murrayn
2018-03-13Merge #11041: Add LookupBlockIndexWladimir J. van der Laan
92fabcd44 Add LookupBlockIndex function (João Barbosa) 43a32b739 Add missing cs_lock in CreateWalletFromFile (João Barbosa) f814a3e8f Fix cs_main lock in LoadExternalBlockFile (João Barbosa) c651df8b3 Lock cs_main while loading block index in AppInitMain (João Barbosa) 02de6a6bc Assert cs_main is held when accessing mapBlockIndex (João Barbosa) Pull request description: Replace all `mapBlockIndex` lookups with the new `LookupBlockIndex()`. In some cases it avoids a second lookup. Tree-SHA512: ca31118f028a19721f2191d86f2dd398144d04df345694575a64aeb293be2f85785201480c3c578a0ec99690516205708558c0fd4168b09313378fd4e60a8412
2018-03-11Allow to optional specify the directory for the blocks storageJonas Schnelli
2018-03-09scripted-diff: Convert 11 enums into scoped enums (C++11)practicalswift
-BEGIN VERIFY SCRIPT- sed -i 's/enum DBErrors/enum class DBErrors/g' src/wallet/walletdb.h git grep -l DB_ | xargs sed -i 's/DB_\(LOAD_OK\|CORRUPT\|NONCRITICAL_ERROR\|TOO_NEW\|LOAD_FAIL\|NEED_REWRITE\)/DBErrors::\1/g' sed -i 's/^ DBErrors::/ /g' src/wallet/walletdb.h sed -i 's/enum VerifyResult/enum class VerifyResult/g' src/wallet/db.h sed -i 's/\(VERIFY_OK\|RECOVER_OK\|RECOVER_FAIL\)/VerifyResult::\1/g' src/wallet/db.cpp sed -i 's/enum ThresholdState/enum class ThresholdState/g' src/versionbits.h git grep -l THRESHOLD_ | xargs sed -i 's/THRESHOLD_\(DEFINED\|STARTED\|LOCKED_IN\|ACTIVE\|FAILED\)/ThresholdState::\1/g' sed -i 's/^ ThresholdState::/ /g' src/versionbits.h sed -i 's/enum SigVersion/enum class SigVersion/g' src/script/interpreter.h git grep -l SIGVERSION_ | xargs sed -i 's/SIGVERSION_\(BASE\|WITNESS_V0\)/SigVersion::\1/g' sed -i 's/^ SigVersion::/ /g' src/script/interpreter.h sed -i 's/enum RetFormat {/enum class RetFormat {/g' src/rest.cpp sed -i 's/RF_\(UNDEF\|BINARY\|HEX\|JSON\)/RetFormat::\1/g' src/rest.cpp sed -i 's/^ RetFormat::/ /g' src/rest.cpp sed -i 's/enum HelpMessageMode {/enum class HelpMessageMode {/g' src/init.h git grep -l HMM_ | xargs sed -i 's/HMM_BITCOIN/HelpMessageMode::BITCOIN/g' sed -i 's/^ HelpMessageMode::/ /g' src/init.h sed -i 's/enum FeeEstimateHorizon/enum class FeeEstimateHorizon/g' src/policy/fees.h sed -i 's/enum RBFTransactionState/enum class RBFTransactionState/g' src/policy/rbf.h git grep -l RBF_ | xargs sed -i 's/RBF_TRANSACTIONSTATE_\(UNKNOWN\|REPLACEABLE_BIP125\|FINAL\)/RBFTransactionState::\1/g' sed -i 's/^ RBFTransactionState::/ /g' src/policy/rbf.h sed -i 's/enum BlockSource {/enum class BlockSource {/g' src/qt/clientmodel.h git grep -l BLOCK_SOURCE_ | xargs sed -i 's/BLOCK_SOURCE_\(NONE\|REINDEX\|DISK\|NETWORK\)/BlockSource::\1/g' sed -i 's/^ BlockSource::/ /g' src/qt/clientmodel.h sed -i 's/enum FlushStateMode {/enum class FlushStateMode {/g' src/validation.cpp sed -i 's/FLUSH_STATE_\(NONE\|IF_NEEDED\|PERIODIC\|ALWAYS\)/FlushStateMode::\1/g' src/validation.cpp sed -i 's/^ FlushStateMode::/ /g' src/validation.cpp sed -i 's/enum WitnessMode {/enum class WitnessMode {/g' src/test/script_tests.cpp sed -i 's/WITNESS_\(NONE\|PKH\|SH\)/WitnessMode::\1/g' src/test/script_tests.cpp sed -i 's/^ WitnessMode::/ /g' src/test/script_tests.cpp -END VERIFY SCRIPT-
2018-03-09Format timestamps using ISO 8601 formatting (e.g. "2018-02-28T12:34:56Z")practicalswift
* Z is the zone designator for the zero UTC offset. * T is the delimiter used to separate date and time. This makes it clear for the end-user that the date/time logged is specified in UTC and not in the local time zone.
2018-03-07Merge #9598: Improve readability by removing redundant casts to same type ↵Wladimir J. van der Laan
(on all platforms) 06edc23f7 Improve readability by removing redundant casts to same type (on all platforms) (practicalswift) Pull request description: Same binaries check under Linux: ``` $ ../bitcoin-maintainer-tools/build-for-compare.py 874f13821f4193bd037cd37d005ee76b5a849398 82274c02ed2d82537dc55f008a29edb1bc09bbc4 --executables "src/bitcoind,src/bitcoin-cli,src/bitcoin-tx" $ sha256sum /tmp/compare/*.stripped 1fe1a8827474f7f24475ce3dc851e7ac658d4ed0ae38d11e67f5a810671eaa15 /tmp/compare/bitcoin-cli.82274c02ed2d82537dc55f008a29edb1bc09bbc4.stripped 1fe1a8827474f7f24475ce3dc851e7ac658d4ed0ae38d11e67f5a810671eaa15 /tmp/compare/bitcoin-cli.874f13821f4193bd037cd37d005ee76b5a849398.stripped 342c2ed0e60b60990a58cbf5845b256a4f9e3baff9db074baba5e34a620a60ea /tmp/compare/bitcoind.82274c02ed2d82537dc55f008a29edb1bc09bbc4.stripped 342c2ed0e60b60990a58cbf5845b256a4f9e3baff9db074baba5e34a620a60ea /tmp/compare/bitcoind.874f13821f4193bd037cd37d005ee76b5a849398.stripped e4b2a80b2361d5cefd67a47eeb9298b8b712c26c7779d979348be8b2c7e3ec93 /tmp/compare/bitcoin-tx.82274c02ed2d82537dc55f008a29edb1bc09bbc4.stripped e4b2a80b2361d5cefd67a47eeb9298b8b712c26c7779d979348be8b2c7e3ec93 /tmp/compare/bitcoin-tx.874f13821f4193bd037cd37d005ee76b5a849398.stripped $ git diff -W --word-diff /tmp/compare/874f13821f4193bd037cd37d005ee76b5a849398 /tmp/compare/82274c02ed2d82537dc55f008a29edb1bc09bbc4 $ ``` Tree-SHA512: 13ca5862fbb03771682b04a7523e581a7fe62e73620fa0e141cf1bc0a3b3f4e2e66bf14b46d1228e2b11b4960153545e7476f3295713a69b5cf5a28a7c2b358d
2018-03-06Add LookupBlockIndex functionJoão Barbosa
2018-03-06Lock cs_main while loading block index in AppInitMainJoão Barbosa
2018-03-05Merge #12568: Allow dustrelayfee to be set to zeroWladimir J. van der Laan
874e81808 Allow dustrelayfee to be set to zero (Luke Dashjr) Pull request description: I don't see and can't think of any rationale for forbidding this configuration. Tree-SHA512: df09441f4aec63e79bea94838b7f8e336cebaeb0a22b5e58d27937bbeb1377f229921aeae43674e0b63fc40a39ae51a264d48aa1cdb4cbd0e3339d32856698bf
2018-03-01Merge #10387: Eventually connect to NODE_NETWORK_LIMITED peersWladimir J. van der Laan
eb91835 Add setter for g_initial_block_download_completed (Jonas Schnelli) 3f56df5 [QA] add NODE_NETWORK_LIMITED address relay and sync test (Jonas Schnelli) 158e1a6 [QA] fix mininode CAddress ser/deser (Jonas Schnelli) fa999af [QA] Allow addrman loopback tests (add debug option -addrmantest) (Jonas Schnelli) 6fe57bd Connect to peers signaling NODE_NETWORK_LIMITED when out-of-IBD (Jonas Schnelli) 31c45a9 Accept addresses with NODE_NETWORK_LIMITED flag (Jonas Schnelli) Pull request description: Eventually connect to peers signalling NODE_NETWORK_LIMITED if we are out of IBD. Accept and relay NODE_NETWORK_LIMITED peers in addrman. Tree-SHA512: 8a238fc97f767f81cae1866d6cc061390f23a72af4a711d2f7158c77f876017986abb371d213d1c84019eef7be4ca951e8e6f83fda36769c4e1a1d763f787037
2018-02-28Allow dustrelayfee to be set to zeroLuke Dashjr
2018-02-20init: Remove translation for `-blockmaxsize` option helpWladimir J. van der Laan
Move `-blockmaxsize`, a deprecated option which is replaced by `-blockmaxweight`, to debug options and remove the translation. This message is absolutely terrible for translators (esp the `* 4` part).
2018-02-16fixes #12465 added missing terminating newline character in log messageJosh Hartshorn
2018-02-12Interrupt loading thread after shutdown requestJoão Barbosa
2018-02-12Merge #12381: Remove more boost threadsWladimir J. van der Laan
004f999 boost: drop boost threads for [alert|block|wallet]notify (Cory Fields) 0827267 boost: drop boost threads from torcontrol (Cory Fields) ba91724 boost: remove useless threadGroup parameter from Discover (Cory Fields) f26866b boost: drop boost threads for upnp (Cory Fields) Pull request description: This doesn't completely get rid of boost::thread, but this batch should be easy to review, and leaves us with only threadGroup (scheduler + scriptcheck) remaining. Note to reviewers: The upnp diff changes a bunch of whitespace, it's much more clear with 'git diff -w' Tree-SHA512: 5a356798d0785f93ed143d1f0afafe890bc82f0d470bc969473da2d2aa78bcb9b096f7ba11b92564d546fb447d4bd0d347e7842994ea0170aafd53fda7e0a66e
2018-02-11Reset pblocktree before deleting LevelDB fileSjors Provoost
2018-02-09[QA] Allow addrman loopback tests (add debug option -addrmantest)Jonas Schnelli
2018-02-08Merge #12225: Mempool cleanupsWladimir J. van der Laan
669c943 Avoid leaking prioritization information when relaying transactions (Suhas Daftuar) e868b22 fee estimator: avoid sorting mempool on shutdown (Suhas Daftuar) 0975406 Correct mempool mapTx comment (Suhas Daftuar) Pull request description: Following up on #12127 and #12118, this cleans up a comment that was left incorrect in txmempool.h, and addresses a couple of the observations @TheBlueMatt made about an unnecessary use of `queryHashes()` and a small information leak when prioritizing transactions. Left undone is nuking queryHashes altogether; that would require changing the behavior of the `getrawmempool` rpc call, which I think I might be in favor of doing, but wanted to save for its own PR. Tree-SHA512: c97d10b96dcd6520459287a4a2eda92774173757695100fcfe61e526aef86f394507c331d17f9e0c14b496c33ec46198a0f165a847762ca50f7c6780b993f162
2018-02-08boost: drop boost threads for [alert|block|wallet]notifyCory Fields
2018-02-08boost: drop boost threads from torcontrolCory Fields
2018-02-08boost: remove useless threadGroup parameter from DiscoverCory Fields
2018-02-08boost: drop boost threads for upnpCory Fields
2018-02-06Fix fast-shutdown hang on ThreadImport+GenesisWaitMatt Corallo
If the user somehow manages to get into ShutdownRequested before ThreadImport gets to ActivateBestChain() we may hang waiting on condvar_GenesisWait forever. A simple wait_for and ShutdownRequested resolves this case.
2018-02-05Clarify help messages for path args to mention datadir prefixJames O'Beirne
Change `-conf`'s and others' help messages to indicate that relative path values will be prefixed by the datadir path. This behavior is confusing when attempting to specify a configuration file in the current directory with `-conf=bitcoin.conf`, but loading the `bitcoin.conf` file in ~/.bitcoin datadir.
2018-02-01Properly alphabetize output of CLI --help option.murrayn
2018-01-30Merge #12266: Move scheduler/threadGroup into common-init instead of per-appWladimir J. van der Laan
082a61c Move scheduler/threadGroup into common-init instead of per-app (Matt Corallo) Pull request description: This resolves #12229 which pointed out a shutdown deadlock due to scheduler/checkqueue having been shut down while network message processing is still running. Tree-SHA512: 0c0a76113996b164b0610d3b8c40b396f3e384d165bf098768e31fe3701b00763d0d810ef24702387e2e936fefb9fb900a6225f7417bb0175b585f365d542660
2018-01-29Merge #12197: Log debug build status and warn when running benchmarksWladimir J. van der Laan
34328b4 Use PACKAGE_NAME instead of hardcoding application name in log message (Wladimir J. van der Laan) 0c74e2e Log debug build status and warn when running benchmarks (Wladimir J. van der Laan) Pull request description: Log whether the starting instance of bitcoin core is a debug or release build (--enable-debug). Also warn when running the benchmarks with a debug build, to prevent mistakes comparing debug to non-debug results. Tree-SHA512: f612dcb7d0a8435016cff0df8aef4942144dfb88be8a00df45cc8830d2aba4b167f6d397b83f8f57d57685888babd04ba88d4dac5a202d3dbd91bcbea3708ef0
2018-01-25fee estimator: avoid sorting mempool on shutdownSuhas Daftuar
2018-01-25Move scheduler/threadGroup into common-init instead of per-appMatt Corallo
This resolves #12229 which pointed out a shutdown deadlock due to scheduler/checkqueue having been shut down while network message processing is still running.
2018-01-19Use PACKAGE_NAME instead of hardcoding application name in log messageWladimir J. van der Laan
2018-01-18Don't allow relative -walletdir pathsRussell Yanofsky
Also warn if bitcoind is configured to use a relative -datadir path. Specifying paths relative to the current working directory in a daemon process can be dangerous, because files can fail to be located even if the configuration doesn't change, but the daemon is started up differently. Specifying a relative -datadir now adds a warning to the debug log. It would not be backwards-compatible to forbid relative -datadir paths entirely, and it could also be also inconvenient for command line testing. Specifying a relative -walletdir now results in a startup error. But since the -walletdir option is new in 0.16.0, there should be no compatibility issues. Another reason not to use working directory paths for -walletdir specifically is that the default -walletdir is a "wallets" subdirectory inside the datadir, so it could be surprising that setting -walletdir manually would choose a directory rooted in a completely different location.
2018-01-16Log debug build status and warn when running benchmarksWladimir J. van der Laan
Log whether the starting instance of bitcoin core is a debug or release build (--enable-debug). Also warn when running the benchmarks with a debug build, to prevent mistakes comparing debug to non-debug results.
2018-01-16Abstract directory locking into util.cppMeshCollider
2018-01-03Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa
2017-12-21Improve readability by removing redundant casts to same type (on all platforms)practicalswift
2017-12-12Merge #11831: Always return true if AppInitMain got to the endWladimir J. van der Laan
07c4838 Always return true if AppInitMain got to the end (Matt Corallo) Pull request description: This should fix a rare zapwallettxes failure on travis, but also avoids having init operations (re-adding wallet transactions to mempool) running after RPC is free'd. I believe this was the failure at https://travis-ci.org/bitcoin/bitcoin/jobs/311747844 (from #11605). Tree-SHA512: f0fea8c1b9265e2eeda57043d541380a3e58e4d9388fa24628a52fd56324257fcd7df0ca02e8f77f66fadd68d951893bab0f610ed9fd0a89b2ccd6bad1efa351
2017-12-05Always set NODE_NETWORK_LIMITED bitJonas Schnelli
The current pruning implementation does ensure to always conform to BIP159
2017-12-05Always return true if AppInitMain got to the endMatt Corallo
This should fix a very rare travis failure in zapwallettxes, but is also more correct, as you can currently race ReacceptWalletTransactions with stop RPC calls to get bitcoind to (IMO) eroneously return a non-0 exit code.
2017-11-30Add `-debuglogfile` optionWladimir J. van der Laan
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-30Merge #11783: Fix shutdown in case of errors during initializationWladimir J. van der Laan
d31e5c1 Fix shutdown in case of errors during initialization (Wladimir J. van der Laan) Pull request description: PR #10286 introduced a few steps which are not robust to early shutdown in initialization. Stumbled upon this with #11781, not sure if there are other scenarios that can trigger it, but it's good to harden against this in any case. E.g. ``` $ src/bitcoind -debuglogfile=/dfdf Error: Could not open debug log file /dfdf Program received signal SIGSEGV, Segmentation fault. UnregisterValidationInterface (pwalletIn=0x0) at /.../bitcoin/src/validationinterface.cpp:82 82 g_signals.m_internals->BlockChecked.disconnect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2)); (gdb) bt #0 UnregisterValidationInterface (pwalletIn=0x0) at /.../bitcoin/src/validationinterface.cpp:82 #1 0x00005555555a11fc in Shutdown () at /.../bitcoin/src/init.cpp:196 #2 0x00005555555961cc in AppInit (argc=<optimized out>, argv=<optimized out>) at /.../bitcoin/src/bitcoind.cpp:183 #3 0x0000555555596249 in main (argc=0, argv=0x555555ecf200) at /.../bitcoin/src/bitcoind.cpp:19 ``` Tree-SHA512: 7dd9570a9803514a17781bfadf1edde47e96df4e852cce2f423cab422e005fb94d44e777af1a6ea5167b04a4d889e848ae7a61a7e0e94232247ddea32ee70fc8
2017-11-30Merge #11191: RPC: Improve help text and behavior of RPC-logging.Wladimir J. van der Laan
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-28Fix shutdown in case of errors during initializationWladimir J. van der Laan
PR #10286 introduced a few steps which are not robust to early shutdown in initialization. Stumbled upon this with #11781, not sure if there are other scenarios that can trigger it, but it's harden against this in any case.
2017-11-23Merge #11603: Move RPC registration out of AppInitParameterInteractionWladimir J. van der Laan
abbd230 Move RPC registration out of AppInitParameterInteraction (Russell Yanofsky) Pull request description: Move to AppInitServers. This doesn't have any effects on bitcoin behavior. It was just strange to have this unrelated code in the middle of parameter interaction. Tree-SHA512: 373e18f2ef8d21999ad36295d69326128a3086044acfc8ed537abd5497c8d3620b9832f7f6aa87c0c0939bb5e0d92be8a3c006b5997e9e6fa20334f5610c89bc