2010-07-14 17:54:31 +02:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2023-08-16 19:27:31 +02:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2014-12-01 02:39:44 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2012-05-18 16:02:28 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2013-04-13 07:13:08 +02:00
|
|
|
|
2011-05-15 09:11:04 +02:00
|
|
|
#ifndef BITCOIN_INIT_H
|
|
|
|
#define BITCOIN_INIT_H
|
2010-07-14 17:54:31 +02:00
|
|
|
|
2022-10-22 19:18:03 +02:00
|
|
|
#include <context.h>
|
|
|
|
|
2020-04-18 11:59:40 +02:00
|
|
|
#include <memory>
|
2013-10-19 18:42:14 +02:00
|
|
|
#include <string>
|
|
|
|
|
2021-03-11 15:23:24 +01:00
|
|
|
//! Default value for -daemon option
|
|
|
|
static constexpr bool DEFAULT_DAEMON = false;
|
|
|
|
//! Default value for -daemonwait option
|
|
|
|
static constexpr bool DEFAULT_DAEMONWAIT = false;
|
|
|
|
|
2022-05-21 11:30:27 +02:00
|
|
|
class ArgsManager;
|
2022-04-05 11:09:41 +02:00
|
|
|
struct NodeContext;
|
2022-04-16 08:24:42 +02:00
|
|
|
namespace interfaces {
|
|
|
|
struct BlockAndHeaderTipInfo;
|
|
|
|
} // namespace interfaces
|
2013-04-13 07:13:08 +02:00
|
|
|
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
/** Interrupt threads */
|
2022-04-05 11:09:41 +02:00
|
|
|
void Interrupt(NodeContext& node);
|
|
|
|
void Shutdown(NodeContext& node);
|
2015-11-26 14:03:27 +01:00
|
|
|
//!Initialize the logging infrastructure
|
2022-05-21 11:30:27 +02:00
|
|
|
void InitLogging(const ArgsManager& args);
|
2015-10-08 09:58:31 +02:00
|
|
|
//!Parameter interaction: change current parameters depending on various rules
|
2022-05-21 11:30:27 +02:00
|
|
|
void InitParameterInteraction(ArgsManager& args);
|
2016-12-01 01:07:21 +01:00
|
|
|
|
2020-06-11 10:39:04 +02:00
|
|
|
/** Initialize Dash Core: Basic context setup.
|
2017-07-17 17:12:00 +02:00
|
|
|
* @note This can be done before daemonization. Do not call Shutdown() if this function fails.
|
2016-12-01 01:07:21 +01:00
|
|
|
* @pre Parameters should be parsed and config file should be read.
|
|
|
|
*/
|
2020-12-06 01:14:17 +01:00
|
|
|
bool AppInitBasicSetup(const ArgsManager& args);
|
2016-12-01 01:07:21 +01:00
|
|
|
/**
|
|
|
|
* Initialization: parameter interaction.
|
2017-07-17 17:12:00 +02:00
|
|
|
* @note This can be done before daemonization. Do not call Shutdown() if this function fails.
|
2016-12-01 01:07:21 +01:00
|
|
|
* @pre Parameters should be parsed and config file should be read, AppInitBasicSetup should have been called.
|
|
|
|
*/
|
2022-05-21 11:30:27 +02:00
|
|
|
bool AppInitParameterInteraction(const ArgsManager& args);
|
2016-12-01 01:07:21 +01:00
|
|
|
/**
|
partial Merge bitcoin/bitcoin#25233: compat: remove glibcxx sanity checks
It's partial due to this missing changes:
```
https://github.com/bitcoin/bitcoin/pull/25233/files#diff-4cb884d03ebb901069e4ee5de5d02538c40dd9b39919c615d8eaa9d364bbbd77L632
```
cc61bc2e19b1c8cb32778ef42746d32b02cc2671 compat: remove glibcxx sanity checks (fanquake)
Pull request description:
These checks were added in #4339, (see also #4081), to test
our back-compat stubs, however, those stubs no-longer exist (#22930),
meaning that these checks are now just testing some specific standard
library behaviour, without a particular rationale, or reason, compared
to any other standard library functionlity we use.
There has also been some discussion about our sanity checks in the
context of the libbitcoinkernel refactoring, see https://github.com/bitcoin/bitcoin/pull/25065#discussion_r880668218.
Removing the checks removes the need to worry about atleast the
glibcxx checks.
Also remove the list of checks from the doc in `init.h`, because it is
incomplete, and anyone who wants to know what checks are included can
look at the function.
Guix Build (arm64):
```bash
e18a81e25b4707cbe113fb4d3ba2459013c1178e7cecfe446e4f14ee5ecd2ce8 guix-build-cc61bc2e19b1/output/arm-linux-gnueabihf/SHA256SUMS.part
9928cc38b79f827018cba0bdde98666b31806afcc79dd95a00acb8e153c36eec guix-build-cc61bc2e19b1/output/arm-linux-gnueabihf/bitcoin-cc61bc2e19b1-arm-linux-gnueabihf-debug.tar.gz
ebf4635ba4688899ae62e4bb17ebb2afb25c538c4a8068ef515920fd4e43754e guix-build-cc61bc2e19b1/output/arm-linux-gnueabihf/bitcoin-cc61bc2e19b1-arm-linux-gnueabihf.tar.gz
74c7e35b47c6d101fda7205f144d37150329b4c360db09d37b8c1437f3390898 guix-build-cc61bc2e19b1/output/arm64-apple-darwin/SHA256SUMS.part
6e12643b17be9326f1d873dfe51a52c082671540792877af624b42ca9f6e1791 guix-build-cc61bc2e19b1/output/arm64-apple-darwin/bitcoin-cc61bc2e19b1-arm64-apple-darwin-unsigned.dmg
1d86d0416c7a50afd7bd8d850f416b7c7277464ccc95e4dae53b5b59415fc83d guix-build-cc61bc2e19b1/output/arm64-apple-darwin/bitcoin-cc61bc2e19b1-arm64-apple-darwin-unsigned.tar.gz
84070843f23839e7191ad3a667eb63c45f668eb95afbfb3fcdfb8363320f67d4 guix-build-cc61bc2e19b1/output/arm64-apple-darwin/bitcoin-cc61bc2e19b1-arm64-apple-darwin.tar.gz
bf6ccd7b8c40476b1dc52b491757313ea3e96c43a01c8aabaf39f94dc1837329 guix-build-cc61bc2e19b1/output/dist-archive/bitcoin-cc61bc2e19b1.tar.gz
25e7e1ff7d8de38632abf9926343c8ba556209f3d03109c92864ffe72813a05f guix-build-cc61bc2e19b1/output/powerpc64-linux-gnu/SHA256SUMS.part
d0398de83841607b1bf921d4553b30ad5e2d70d0570e96a2eaaf2762e1103c79 guix-build-cc61bc2e19b1/output/powerpc64-linux-gnu/bitcoin-cc61bc2e19b1-powerpc64-linux-gnu-debug.tar.gz
f09cdc2ac2a2bb644f4749f3d74b5210ddb531594c33d127a907f0223e7793e5 guix-build-cc61bc2e19b1/output/powerpc64-linux-gnu/bitcoin-cc61bc2e19b1-powerpc64-linux-gnu.tar.gz
ef36a68ef4e5ee9b311df40062cd2296f897e7b1550e39e0643601cd7d469010 guix-build-cc61bc2e19b1/output/powerpc64le-linux-gnu/SHA256SUMS.part
937b600a2b86304ccc5b6c71a7eaf8aa5e2020592724cef6a933a1955995480b guix-build-cc61bc2e19b1/output/powerpc64le-linux-gnu/bitcoin-cc61bc2e19b1-powerpc64le-linux-gnu-debug.tar.gz
eca4eec41e71fdf7a7b0fa4065afa49c47d3b9541ed2cb4d083ad4a0de102e37 guix-build-cc61bc2e19b1/output/powerpc64le-linux-gnu/bitcoin-cc61bc2e19b1-powerpc64le-linux-gnu.tar.gz
981c0968c19905925a599cff357ec259c1e806bdb7691c7b52039be450bdad7c guix-build-cc61bc2e19b1/output/riscv64-linux-gnu/SHA256SUMS.part
89c709967f9a157256281fbf682aad246f2eaad9c2f1797c2787253cbabe12f8 guix-build-cc61bc2e19b1/output/riscv64-linux-gnu/bitcoin-cc61bc2e19b1-riscv64-linux-gnu-debug.tar.gz
454cd830dd382e176f5a23041fc33f93937668245481b0dd29fc04882d9528eb guix-build-cc61bc2e19b1/output/riscv64-linux-gnu/bitcoin-cc61bc2e19b1-riscv64-linux-gnu.tar.gz
e0812c2dc492e5c5f06e3685d19da8fb29ed38d3b32821d293ef01cb4fefbd79 guix-build-cc61bc2e19b1/output/x86_64-apple-darwin/SHA256SUMS.part
0e7d4241d8ac882a8091fa00a7813db87a3e5afec59627e45b6c910cfdd4a7b0 guix-build-cc61bc2e19b1/output/x86_64-apple-darwin/bitcoin-cc61bc2e19b1-x86_64-apple-darwin-unsigned.dmg
3faaca046cbb2642445a7dd1f389ed7bf94a65de8372441c36d5cb79c030ce31 guix-build-cc61bc2e19b1/output/x86_64-apple-darwin/bitcoin-cc61bc2e19b1-x86_64-apple-darwin-unsigned.tar.gz
73080f032a42db679baf0d09619671ac5b9d85be84a68bdd6b6709eb0e6465bd guix-build-cc61bc2e19b1/output/x86_64-apple-darwin/bitcoin-cc61bc2e19b1-x86_64-apple-darwin.tar.gz
07b6e1b6291404bca1044df4a45b6958b882ffb88c143ba98f1959960a394897 guix-build-cc61bc2e19b1/output/x86_64-linux-gnu/SHA256SUMS.part
16b455f62398f4aa0d3821abb1cceb8151e31c2664e3f974a764a5b8702b50f3 guix-build-cc61bc2e19b1/output/x86_64-linux-gnu/bitcoin-cc61bc2e19b1-x86_64-linux-gnu-debug.tar.gz
3c1a3a6a343f17b83f3b3d47e9426eccd2d0bcc7f824cd958fcf2cf06cdc3276 guix-build-cc61bc2e19b1/output/x86_64-linux-gnu/bitcoin-cc61bc2e19b1-x86_64-linux-gnu.tar.gz
f05afa688ea7211b0049555385fb2acc26986e24d8d00893389160e07037e693 guix-build-cc61bc2e19b1/output/x86_64-w64-mingw32/SHA256SUMS.part
8bcbae67dd0746c42e1e7c7db67725a69289b08e9aa97b873d443d0aa355615d guix-build-cc61bc2e19b1/output/x86_64-w64-mingw32/bitcoin-cc61bc2e19b1-win64-debug.zip
efa45e3b76e5ae08a8392d58e741325df572d92c7dd69b65d876cdcda541d2fc guix-build-cc61bc2e19b1/output/x86_64-w64-mingw32/bitcoin-cc61bc2e19b1-win64-setup-unsigned.exe
3a8c2461ca826138c3017d06279a79b4c6bee2a507ad362aa6e424f76678596c guix-build-cc61bc2e19b1/output/x86_64-w64-mingw32/bitcoin-cc61bc2e19b1-win64-unsigned.tar.gz
e56ae4f609d4e6a3ca5917a4bb763c91012ece2d236d6b62a666358791e43525 guix-build-cc61bc2e19b1/output/x86_64-w64-mingw32/bitcoin-cc61bc2e19b1-win64.zip
```
ACKs for top commit:
MarcoFalke:
lgtm ACK cc61bc2e19b1c8cb32778ef42746d32b02cc2671
laanwj:
Concept and code review ACK cc61bc2e19b1c8cb32778ef42746d32b02cc2671
Tree-SHA512: 3da6aba44eef3f864fcbe897db1faa964923756e68c6a713e444b5d01c6d3542c3d7ca26678760e81a7a9e3cd40bd90622d0a7b697c27166817ba4f1023661ef
2022-05-30 10:39:41 +02:00
|
|
|
* Initialization sanity checks.
|
2017-07-17 17:12:00 +02:00
|
|
|
* @note This can be done before daemonization. Do not call Shutdown() if this function fails.
|
2016-12-01 01:07:21 +01:00
|
|
|
* @pre Parameters should be parsed and config file should be read, AppInitParameterInteraction should have been called.
|
|
|
|
*/
|
|
|
|
bool AppInitSanityChecks();
|
|
|
|
/**
|
2020-06-11 10:39:04 +02:00
|
|
|
* Lock Dash Core data directory.
|
2017-07-17 17:12:00 +02:00
|
|
|
* @note This should only be done after daemonization. Do not call Shutdown() if this function fails.
|
2016-12-01 01:07:21 +01:00
|
|
|
* @pre Parameters should be parsed and config file should be read, AppInitSanityChecks should have been called.
|
|
|
|
*/
|
2017-07-17 17:12:00 +02:00
|
|
|
bool AppInitLockDataDirectory();
|
2020-08-31 10:10:52 +02:00
|
|
|
/**
|
|
|
|
* Initialize node and wallet interface pointers. Has no prerequisites or side effects besides allocating memory.
|
|
|
|
*/
|
|
|
|
bool AppInitInterfaces(NodeContext& node);
|
2017-07-17 17:12:00 +02:00
|
|
|
/**
|
2020-06-11 10:39:04 +02:00
|
|
|
* Dash Core main initialization.
|
2017-07-17 17:12:00 +02:00
|
|
|
* @note This should only be done after daemonization. Call Shutdown() if this function fails.
|
|
|
|
* @pre Parameters should be parsed and config file should be read, AppInitLockDataDirectory should have been called.
|
|
|
|
*/
|
2021-04-08 09:07:57 +02:00
|
|
|
bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
|
2022-04-05 11:09:41 +02:00
|
|
|
void PrepareShutdown(NodeContext& node);
|
2013-10-11 23:09:59 +02:00
|
|
|
|
2021-03-19 16:00:24 +01:00
|
|
|
/**
|
2022-05-29 21:49:04 +02:00
|
|
|
* Register all arguments with the ArgsManager
|
2021-03-19 16:00:24 +01:00
|
|
|
*/
|
2021-06-11 09:18:28 +02:00
|
|
|
void SetupServerArgs(ArgsManager& argsman);
|
2013-10-11 23:09:59 +02:00
|
|
|
|
2014-06-10 16:02:46 +02:00
|
|
|
/** Returns licensing information (for -version) */
|
|
|
|
std::string LicenseInfo();
|
2011-05-15 09:11:04 +02:00
|
|
|
|
2014-08-28 22:21:03 +02:00
|
|
|
#endif // BITCOIN_INIT_H
|