Commit Graph

1121 Commits

Author SHA1 Message Date
Suhas Daftuar ac7b37cd2b Connect to an extra outbound peer if our tip is stale
If our tip hasn't updated in a while, that may be because our peers are
not relaying blocks to us that we would consider valid. Allow connection
to an additional outbound peer in that circumstance.

Also, periodically check to see if we are exceeding our target number of
outbound peers, and disconnect the one which has least recently
announced a new block to us (choosing the newest such peer in the case
of tie).
2017-11-02 12:39:14 -04:00
Wladimir J. van der Laan 50d72b3570
Merge #11495: [trivial] Make namespace explicit for is_regular_file
f4c4e38 [trivial] Make namespace explicit for is_regular_file (John Newbery)

Pull request description:

  is_regular_file resolves using argument dependent lookup. Make the
  namespace explicit so it's obvious where the function is defined.

  For those not familiar with argument dependent lookups:

  - http://en.cppreference.com/w/cpp/language/adl
  - https://en.wikipedia.org/wiki/Argument-dependent_name_lookup

  Thanks to C++ guru @ryanofsky for pointing this out to me.

Tree-SHA512: 919f1818081a8f90c5751181f87e13b06d90f8aec0ab873100434e55c85cca6e0e288ecc7f135e19e9b5dba7952e96b6393864b7840e20b69dd40e92a157928b
2017-10-18 16:35:19 +02:00
Pieter Wuille 326a5652e0
Merge #11456: Replace relevant services logic with a function suite.
15f5d3b17 Switch DNSSeed-needed metric to any-automatic-nodes, not services (Matt Corallo)
5ee88b4bd Clarify docs for requirements/handling of addnode/connect nodes (Matt Corallo)
57edc0b0c Rename fAddnode to a more-descriptive "manual_connection" (Matt Corallo)
44407100f Replace relevant services logic with a function suite. (Matt Corallo)

Pull request description:

  This was mostly written as a way to clean things up so that the NETWORK_LIMITED PR (#10387) can be simplified a ton, but its also a nice standalone cleanup that will also require a bit of review because it tweaks a lot of stuff across net. The new functions are fine in protocol.h right now since they're straight-forward, but after NETWORK_LIMITED will really want to move elsewhere after @theuni moves the nServices-based selection to addrman from connman.

  Adds HasAllRelevantServices and GetRelevantServices, which check
  for NETWORK|WITNESS.

  This changes the following:
   * Removes nRelevantServices from CConnman, disconnecting it a bit
     more from protocol-level logic.
   * Replaces our sometimes-connect-to-!WITNESS-nodes logic with
     simply always requiring WITNESS|NETWORK for outbound non-feeler
     connections (feelers still only require NETWORK).
   * This has the added benefit of removing nServicesExpected from
     CNode - instead letting net_processing's VERSION message
     handling simply check HasAllRelevantServices.
   * This implies we believe WITNESS nodes to continue to be a
     significant majority of nodes on the network, but also because
     we cannot sync properly from !WITNESS nodes, it is strange to
     continue using our valuable outbound slots on them.
   * In order to prevent this change from preventing connection to
     -connect= nodes which have !WITNESS, -connect nodes are now
     given the "addnode" flag. This also allows outbound connections
     to !NODE_NETWORK nodes for -connect nodes (which was already true
     of addnodes).
   * Has the (somewhat unintended) consequence of changing one of the
     eviction metrics from the same
     sometimes-connect-to-!WITNESS-nodes metric to requiring
     HasRelevantServices.

  This should make NODE_NETWORK_LIMITED much simpler to implement.

Tree-SHA512: 90606896c86cc5da14c77843b16674a6a012065e7b583d76d1c47a18215358abefcbab44ff4fab3fadcd39aa9a42d4740c6dc8874a58033bdfc8ad3fb5c649fc
2017-10-13 15:31:19 -07:00
John Newbery f4c4e38884 [trivial] Make namespace explicit for is_regular_file
is_regular_file resolves using argument dependent lookup. Make the
namespace explicit so it's obvious where the function is defined.
2017-10-13 17:23:52 -04:00
Matt Corallo 5ee88b4bde Clarify docs for requirements/handling of addnode/connect nodes 2017-10-13 13:29:25 -04:00
Matt Corallo 44407100ff Replace relevant services logic with a function suite.
Adds HasAllRelevantServices and GetRelevantServices, which check
for NETWORK|WITNESS.

This changes the following:
 * Removes nRelevantServices from CConnman, disconnecting it a bit
   more from protocol-level logic.
 * Replaces our sometimes-connect-to-!WITNESS-nodes logic with
   simply always requiring WITNESS|NETWORK for outbound non-feeler
   connections (feelers still only require NETWORK).
 * This has the added benefit of removing nServicesExpected from
   CNode - instead letting net_processing's VERSION message
   handling simply check HasAllRelevantServices.
 * This implies we believe WITNESS nodes to continue to be a
   significant majority of nodes on the network, but also because
   we cannot sync properly from !WITNESS nodes, it is strange to
   continue using our valuable outbound slots on them.
 * In order to prevent this change from preventing connection to
   -connect= nodes which have !WITNESS, -connect nodes are now
   given the "addnode" flag. This also allows outbound connections
   to !NODE_NETWORK nodes for -connect nodes (which was already true
   of addnodes).
 * Has the (somewhat unintended) consequence of changing one of the
   eviction metrics from the same
   sometimes-connect-to-!WITNESS-nodes metric to requiring
   HasRelevantServices.

This should make NODE_NETWORK_LIMITED much simpler to implement.
2017-10-13 13:25:57 -04:00
MarcoFalke e93fff1463
Merge #11107: Fix races in AppInitMain and others with lock and atomic bools
c626dcb50 Make fUseCrypto atomic (MeshCollider)
731065b11 Consistent parameter names in txdb.h (MeshCollider)
35aeabec6 Make fReindex atomic to avoid race (MeshCollider)
58d91af59 Fix race for mapBlockIndex in AppInitMain (MeshCollider)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/11106

  Also makes fReindex atomic as suggested in @TheBlueMatt comment below, and makes fUseCrypto atomic as suggested in 10916

  d291e7635b just renames the parameters in the txdb header file to make them consistent with those used in the cpp file, noticed it when looking for uses of fReindex

Tree-SHA512: b378aa7289fd505b76565cd4d48dcdc04ac5540283ea1c80442170b0f13cb6df771b1a94dd54b7fec3478a7b4668c224ec9d795f16937782724c5d020edd3a42
2017-10-05 15:03:36 +02: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 ef8340d25f
Merge #11031: [rpc] deprecate estimatefee
048e0c3e2 [rpc] [tests] Add deprecated RPC test (Cristian Mircea Messel)
d4cdbd6fb [rpc] Deprecate estimatefee RPC (John Newbery)

Pull request description:

  Deprecates estimatefee in v0.16, for final removal in v0.17.

  This commit introduces a phased removal of RPC methods. RPC method is
  disabled by default in version x, but can be enabled by using the
  `-deprecatedrpc=<methodname>` argument. RPC method is removed entirely in version
  (x+1).

  This gives users fair warning that an RPC is to be removed, and time to change client software if necessary. Deprecation warnings in RPC return values or release notes are easily ignored.

  This is a more generic version of the approach I tried to use in #10841, which too late to make it into v0.15.

Tree-SHA512: 9695a600e84b812974387333e4a6805d18972da30befb754e9e4da77cd9815d00c5cc2ee0b0350bdbbdb5fdc6ba47789f8b2c6f5b15c8cd5a1deefcc4832da30
2017-09-27 14:38:13 +02:00
John Newbery d4cdbd6fb6 [rpc] Deprecate estimatefee RPC
Deprecate estimatefee in v0.16, for final removal in v0.17.

This commit introduces a phased removal of RPC methods. RPC method is
disabled by default in version x, but can be enabled by using the
`-deprecatedrpc=<method>` argument. RPC method is removed entirely in
version (x+1).
2017-09-26 12:17:19 -04:00
Pieter Wuille 8776787108
Merge #11301: add m_added_nodes to connman options
35e5c2269 remove unused IsArgSet check (Marko Bencun)
605918272 add m_added_nodes to connman options (Marko Bencun)

Pull request description:

Tree-SHA512: ca4527a964dcda816b32d335e7fe4d0d8a668a83fbc5e4707ee452d00a7089fa59a88c9f2b1ecdf50e673f2a63fc364b23979e0153f91136525eceec10c2ede2
2017-09-22 16:05:50 -07:00
MeshCollider 77939f27f7 Fix uninitialized g_connman crash in Shutdown() 2017-09-14 16:47:10 +12:00
MarcoFalke ce829855cf
Merge #10691: Trivial: Properly comment about shutdown process in init.cpp file.
581c41157 Properly comment about shutdown process in init.cpp file (Kyuntae Ethan Kim)

Pull request description:

Tree-SHA512: 8aaf739ca5eb2cf6f777b69a0d65f391ba311a33d2e23abc4d3008f90c6ef9da79d0683845abfc08978309f43409f0a7021663f8c564e157224c1dbe15138158
2017-09-12 21:08:06 +02:00
Matt Corallo ba206d2c63 Deprecate confusing blockmaxsize, fix getmininginfo output
* This removes block-size-limiting code in favor of GBT clients
  doing the limiting themselves (if at all).
* -blockmaxsize is deprecated and only used to calculate an implied
  blockmaxweight, addressing confusion from multiple users.
* getmininginfo's currentblocksize return value was returning
  garbage values, and has been removed, also removing a
  GetSerializeSize call in some block generation inner loops and
  potentially addressing some performance edge cases.
2017-09-11 15:51:25 -04:00
Marko Bencun 35e5c2269c remove unused IsArgSet check
Forgotten in 506b700dcb
2017-09-11 16:17:47 +02:00
Marko Bencun 605918272c add m_added_nodes to connman options 2017-09-11 16:17:01 +02:00
MarcoFalke 791a0e6dda
Merge #10767: [wallet] Clarify wallet initialization / destruction interface
5d2a3995e [trivial] fixup comment for VerifyWallets() (John Newbery)
43b0e81d0 [wallet] Add StartWallets() function to wallet/init.cpp (John Newbery)
290f3c56d [wallet] Add RegisterWalletRPC() function to wallet/init.cpp (John Newbery)
062d63102 [wallet] Add CloseWallets() function to wallet/init.cpp (John Newbery)
77fe07c15 [wallet] Add StopWallets() function to wallet/init.cpp (John Newbery)
2da5eafa4 [wallet] Add FlushWallets() function to wallet/init.cpp (John Newbery)
1b9cee66e [wallet] Rename WalletVerify() to VerifyWallets() (John Newbery)
9c76ba18c [wallet] Rename InitLoadWallet() to OpenWallets() (John Newbery)

Pull request description:

  Apologies for the mostly code move only PR. This is a pre-req for both #10740 and #10762

  All wallet component initialization/destruction functions are now in their own `wallet/init.cpp` translation unit and are no longer static functions on the CWallet class. The bitcoin_server also no longer has any knowledge that there are multiple wallets in vpwallet.

  There should be no changes in behavior from this PR.

Tree-SHA512: 7c260eb094f2fa1a88d803769ba60935810968a7309f731135e4b17623b97f18c03bbcd293c942093d1efce62c6c978f9ff484d54dc9a60bc2fcb5af2d160fcd
2017-09-07 16:35:52 -07:00
John Newbery 43b0e81d0f [wallet] Add StartWallets() function to wallet/init.cpp 2017-09-07 16:21:26 -07:00
John Newbery 290f3c56d9 [wallet] Add RegisterWalletRPC() function to wallet/init.cpp 2017-09-07 16:21:26 -07:00
John Newbery 062d63102e [wallet] Add CloseWallets() function to wallet/init.cpp 2017-09-07 16:21:26 -07:00
John Newbery 77fe07c159 [wallet] Add StopWallets() function to wallet/init.cpp 2017-09-07 16:21:26 -07:00
John Newbery 2da5eafa47 [wallet] Add FlushWallets() function to wallet/init.cpp 2017-09-07 16:21:26 -07:00
John Newbery 1b9cee66e1 [wallet] Rename WalletVerify() to VerifyWallets()
This function can now verify multiple wallets.
2017-09-07 16:21:09 -07:00
John Newbery 9c76ba18cd [wallet] Rename InitLoadWallet() to OpenWallets()
Rationale:
- this init function can now open multiple wallets (hence
  Wallet->Wallets)
- This is named as the antonym to CloseWallets(), which carries out the
  opposite action.
2017-09-07 16:19:17 -07:00
Cory Fields 2525b972af net: stop both net/net_processing before destroying them
This should avoid either attempting to use an invalid reference/pointer to the
other.
2017-09-07 14:26:23 -04:00
MeshCollider 58d91af59e Fix race for mapBlockIndex in AppInitMain 2017-09-07 12:00:25 +12:00
Cory Fields 8ad663c1fa net: use an interface class rather than signals for message processing
Drop boost signals in favor of a stateful class. This will allow the message
processing loop to actually move to net_processing in a future step.
2017-09-06 19:32:04 -04:00
Wladimir J. van der Laan 815fe62421
Merge #10357: Allow setting nMinimumChainWork on command line
eac64bb7a [qa] Test nMinimumChainWork (Suhas Daftuar)
0311836f6 Allow setting nMinimumChainWork on command line (Suhas Daftuar)

Pull request description:

  As discussed briefly here: https://botbot.me/freenode/bitcoin-core-dev/2017-02-28/?msg=81712308&page=4

  This adds a hidden command line option for setting `nMinimumChainWork`, which allows us to test this parameter in our functional tests, as well as allowing for niche use cases like syncing nodes that are otherwise disconnected from the network.

  See also #10345, which proposes a new use of `nMinimumChainWork`.

Tree-SHA512: fe4d8f4f289697615c98d8760f1cc74c076110310ea0b5b875fcab78c127da9195b4eb84148aebacc7606c246e5773d3f13bd5d9559d0a8bffac20a3a28c62df
2017-09-06 19:00:57 +02:00
Wladimir J. van der Laan 6866b4912b
Merge #10596: Add vConnect to CConnman::Options
352d582ba Add vConnect to CConnman::Options (Marko Bencun)

Pull request description:

  Split the "-connect" argument parsing out of CConnman and put it into
  AppInitMain().

Tree-SHA512: f2d3efc4e2c5808ff98696ea20dd96df599bc472ed5afc9c3eea305d94c36a6ab50c632aa05396c7c34d1917d91b1e7ccd725656ff2631e2a36d9eac477455dc
2017-09-06 02:03:48 +02:00
Suhas Daftuar 0311836f69 Allow setting nMinimumChainWork on command line 2017-09-05 15:05:28 -04:00
Andrew Chow ec6902d0ea rpc: Push down safe mode checks
This contains most of the changes of 10563 "remove safe mode", but doesn't
remove the safe mode yet, but put an `ObserveSafeMode()` check in
individual calls with okSafeMode=false.

This cleans up the ugly "okSafeMode" flag from the dispatch tables,
which is not a concern for the RPC server.

Extra-author: Wladimir J. van der Laan <laanwj@gmail.com>
2017-08-29 10:09:41 +02:00
Wladimir J. van der Laan 07c92b98e2
Merge #10976: [MOVEONLY] Move some static functions out of wallet.h/cpp
f01103c MOVEONLY: Init functions wallet/wallet.cpp -> wallet/init.cpp (Russell Yanofsky)
e7fe320 MOVEONLY: Fee functions wallet/wallet.cpp -> wallet/fees.cpp (Russell Yanofsky)
d97fe20 Move some static functions out of wallet.h/cpp (Russell Yanofsky)

Pull request description:

  This just moves some static wallet fee and init functions out of `wallet/wallet.cpp` and into new `wallet/fees.cpp` and `wallet/init.cpp` source files. There is one commit updating declarations and callers, followed by two MOVEONLY commits actually moving the function bodies.

  This change is desirable because wallet.h/cpp are monolithic and hard to navigate, so pulling things out and grouping together pieces of related functionality should improve the organization.

  Another motivation is the wallet process separation work in https://github.com/bitcoin/bitcoin/pull/10973, where (at least initially) parameter parsing and fee estimation are still done in the main process rather than the wallet process, and having functions that run in different processes scrambled up throughout wallet.cpp is unnecessarily confusing.

Tree-SHA512: 6e6982ff82b2ab4e681c043907e2b1801ceb9513394730070f16c46ad338278a863f5b3759aa13db76a259b268b1c919c81f4e339f0796a3cfb990161e8c316d
2017-08-25 21:30:42 +02:00
MarcoFalke 77fc469fc7
Merge #11108: Changing -txindex requires -reindex, not -reindex-chainstate
cd0ea4874 Changing -txindex requires -reindex, not -reindex-chainstate (Matt Corallo)

Pull request description:

  If there's an 0.15.0rc3, this should go in it.

Tree-SHA512: 857e77f0af9c055a3d1d91f37474ee9e06d6bc8c5ed21b29201b6c386801e7041523949076cdf0daa4d357a5175ce49394d85a1bedfbf13f3e577bdb6da1d6ce
2017-08-24 17:31:05 -04:00
Matt Corallo cd0ea48742 Changing -txindex requires -reindex, not -reindex-chainstate 2017-08-22 13:36:12 -04:00
Wladimir J. van der Laan ea3ac5990d
Merge #11026: Bugfix: Use testnet RequireStandard for -acceptnonstdtxn default
4aa2508 Bugfix: Use testnet RequireStandard for -acceptnonstdtxn default (Luke Dashjr)

Pull request description:

  Fixes a bug introduced in #8855

  `-acceptnonstdtxn` is a valid option only for testnet/regtest (in Core), and the help message reflects that. Currently, however, it is buggy in two ways:

  1. It uses mainnet to get the default value, which doesn't make sense since the option is never available for mainnet, and the only time the option is available, is when the default is the opposite.
  2. It uses the value of "require standard" directly as the default for "accept non-standard transactions", but these concepts are opposites: a negation must be performed to transform one to the other.

  Note the combination of these bugs results in the correct boolean output, but the logic to get there is completely wrong.

Tree-SHA512: 06ce513f59ba31f7ab4b6422a08a17bb37a5652dea4c38a4bbefedd5e2752d17bfccc32a4b0508068fa4783e316bff00a821ef18a24b1a2bb02859995d188fdc
2017-08-22 08:56:33 +02:00
Wladimir J. van der Laan c559884cac
Merge #10809: optim: mark a few classes final
40a0f9f Enable devirtualization opportunities by using the final specifier (C++11) (practicalswift)
9a1675e optim: mark a few classes final (Cory Fields)

Pull request description:

  Using gcc's ```-Wsuggest-final-types``` and lto, I identified a few easy devirtualization wins:

  > wallet/wallet.h:651:7: warning: Declaring type 'struct CWallet' final would enable devirtualization of 26 calls [-Wsuggest-final-types]

  >coins.h:201:7: warning: Declaring type 'struct CCoinsViewCache' final would enable devirtualization of 13 calls [-Wsuggest-final-types]

  >txdb.h:67:7: warning: Declaring type 'struct CCoinsViewDB' final would enable devirtualization of 5 calls [-Wsuggest-final-types]

  >zmq/zmqnotificationinterface.h:16:7: warning: Declaring type 'struct CZMQNotificationInterface' final would enable devirtualization of 4 calls [-Wsuggest-final-types]

  >httpserver.cpp:42:7: warning: Declaring type 'struct HTTPWorkItem' final would enable devirtualization of 2 calls [-Wsuggest-final-types]

Tree-SHA512: 2a825fd27121ccabaacff5cde2fc8a50d1b4cc846374606caa2a71b0cd8fcb0d3c9b5b3fd342d944998610e2168048601278f8a3709cc515191a0bb2d98ba782
2017-08-21 18:25:48 +02:00
practicalswift 64fb0ac016 Declare single-argument (non-converting) constructors "explicit"
In order to avoid unintended implicit conversions.
2017-08-16 16:33:25 +02:00
Wladimir J. van der Laan 3841aaf059
Merge #11008: Enable disablesafemode by default.
f4c3d2c Enable disablesafemode by default. (Gregory Maxwell)

Pull request description:

  Safemode is almost useless as is-- it only triggers in limited
   cases most of which aren't even concerning. There have been
   several proposals to remove it. But as a simpler, safer, and
   more flexible first case, simply deactivate it by default.

  Anyone who wants it can re-enable and know what they've signed up for.

Tree-SHA512: f5409a3e81514c32db8eb27c7563ef85e25e56e5fc2a59eac2c30b10ec54087d982c1d3b702bedf9f3133c1f272f23805582a0f468350ba18d8b5a02bedd6401
2017-08-15 17:47:55 +02:00
practicalswift 6fb8f5f17c Check that -blocknotify command is non-empty before executing
To make BlockNotifyCallback(...) (-blocknotify) consistent with:
* AlertNotify(...) (-alertnotify)
* AddToWallet(...) (-walletnotify)
2017-08-14 17:50:31 +02:00
Russell Yanofsky d97fe2016c Move some static functions out of wallet.h/cpp
This commit just moves a few function declarations and updates callers.
Function bodies are moved in two followup MOVEONLY commits.

This change is desirable because wallet.h/cpp are monolithic and hard to
navigate, so pulling things out and grouping together pieces of related
functionality should improve the organization.

Another proximate motivation is the wallet process separation work in
https://github.com/bitcoin/bitcoin/pull/10973, where (at least initially)
parameter parsing and fee estimation are still done in the main process rather
than the wallet process, and having functions that run in different processes
scrambled up throughout wallet.cpp is unnecessarily confusing.
2017-08-14 11:19:38 -04:00
Marko Bencun bb81e17355 scripted-diff: stop using the gArgs wrappers
They were temporary additions to ease the transition.

-BEGIN VERIFY SCRIPT-
find src/ -name "*.cpp" ! -wholename "src/util.h" ! -wholename "src/util.cpp" | xargs perl -i -pe 's/(?<!\.)(ParseParameters|ReadConfigFile|IsArgSet|(Soft|Force)?(Get|Set)(|Bool|)Arg(s)?)\(/gArgs.\1(/g'
-END VERIFY SCRIPT-
2017-08-14 17:02:10 +02:00
Wladimir J. van der Laan ce74799a3c
Merge #10483: scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
90d4d89 scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL (practicalswift)

Pull request description:

  Since C++11 the macro `NULL` may be:
  * an integer literal with value zero, or
  * a prvalue of type `std::nullptr_t`

  By using the C++11 keyword `nullptr` we are guaranteed a prvalue of type `std::nullptr_t`.

  For a more thorough discussion, see "A name for the null pointer: nullptr" (Sutter &
  Stroustrup), http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf

  With this patch applied there are no `NULL` macro usages left in the repo:

  ```
  $ git grep NULL -- "*.cpp" "*.h" | egrep -v '(/univalue/|/secp256k1/|/leveldb/|_NULL|NULLDUMMY|torcontrol.*NULL|NULL cert)' | wc -l
  0
  ```

  The road towards `nullptr` (C++11) is split into two PRs:
  * `NULL` → `nullptr` is handled in PR #10483 (scripted, this PR)
  * `0` → `nullptr` is handled in PR #10645 (manual)

Tree-SHA512: 3c395d66f2ad724a8e6fed74b93634de8bfc0c0eafac94e64e5194c939499fefd6e68f047de3083ad0b4eff37df9a8a3a76349aa17d55eabbd8e0412f140a297
2017-08-14 16:30:59 +02:00
Luke Dashjr 4aa25089b4 Bugfix: Use testnet RequireStandard for -acceptnonstdtxn default 2017-08-10 21:35:43 +00:00
Gregory Maxwell f4c3d2c9da Enable disablesafemode by default.
Safemode is almost useless as is-- it only triggers in limited
 cases most of which aren't even concerning. There have been
 several proposals to remove it. But as a simpler, safer, and
 more flexible first case, simply deactivate it by default.

Anyone who wants it can re-enable and know what they've signed up for.
2017-08-08 20:14:25 +00: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
Matt Corallo e7539f8649 Fix some broken init-time prints/constants 2017-08-01 17:02:10 -04:00
Matt Corallo 13ab353829 Check for empty coinsview instead of just-reset coinsview in init
This fixes a few cases where we should be treating a restart-after-
coinsviewdb-reset identically to a just-reset-coinsviewdb.

Thanks to @morcos for identifying the bug.
2017-08-01 16:35:02 -04:00
Matt Corallo fce3f4f492 Fix resume-of-reindex-after-restart
This more clearly uses fReindex vs fReset to make sure we're not
clearing our coinsdb needlessly when restarting after a reindex.
It also makes it so that restarting after shutting down mid-reindex
isn't treates specially at all during txdb loading code, as it
shouldn't be.
2017-08-01 16:35:02 -04:00
Wladimir J. van der Laan bd924241e7
Merge #10758: Fix some chainstate-init-order bugs.
c0025d0 Fix segfault when shutting down before fully loading (Matt Corallo)
1385697 Order chainstate init more logically. (Matt Corallo)
ff3a219 Call RewindBlockIndex even if we're about to run -reindex-chainstate (Matt Corallo)
b0f3249 More user-friendly error message if UTXO DB runs ahead of block DB (Matt Corallo)
eda888e Fix some LoadChainTip-related init-order bugs. (Matt Corallo)

Pull request description:

  This does a number of things to clean up chainstate init order,
  fixing some issues as it goes:

  * Order chainstate init more logically - first all of the
    blocktree-related loading, then coinsdb, then
    pcoinsTip/chainActive. Only create objects as needed.

  * More clearly document exactly what is and isn't called in
    -reindex and -reindex-chainstate both with comments noting
    calls as no-ops and by adding if guards.

  * Move the writing of fTxIndex to LoadBlockIndex - this fixes a
    bug introduced in d6af06d68a where
    InitBlockIndex was writing to fTxIndex which had not yet been
    checked (because LoadChainTip hadn't yet initialized the
    chainActive, which would otherwise have resulted in
    InitBlockIndex being a NOP), allowing you to modify -txindex
    without reindex, potentially corrupting your chainstate!

  * Rename InitBlockIndex to LoadGenesisBlock, which is now a more
    natural name for it. Also check mapBlockIndex instead of
    chainActive, fixing a bug where we'd write the genesis block out
    on every start.

  * Move LoadGenesisBlock further down in init. This is a more logical
    location for it, as it is after all of the blockindex-related
    loading and checking, but before any of the UTXO-related loading
    and checking.

  * Give LoadChainTip a return value - allowing it to indicate that
    the UTXO DB ran ahead of the block DB. This just provides a nicer
    error message instead of the previous mysterious
    assert(!setBlockIndexCandidates.empty()) error.

  * Calls ActivateBestChain in case we just loaded the genesis
    block in LoadChainTip, avoiding relying on the ActivateBestChain
    in ThreadImport before continuing init process.

  * Move all of the VerifyDB()-related stuff into a -reindex +
    -reindex-chainstate if guard. It couldn't do anything useful
    as chainActive.Tip() would be null at this point anyway.

Tree-SHA512: 3c96ee7ed44f4130bee3479a40c5cd99a619fda5e309c26d60b54feab9f6ec60fabab8cf47a049c9cf15e88999b2edb7f16cbe6819e97273560b201a89d90762
2017-08-01 12:58:38 +02:00
Matt Corallo c0025d0a92 Fix segfault when shutting down before fully loading
This was introduced by 3192975f1d.
It can be triggered easily when canceling DB upgrade from
pre-per-utxo.
2017-07-27 15:03:05 -04:00