2010-07-14 15:54:31 +00:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2022-12-24 23:49:50 +00:00
|
|
|
// Copyright (c) 2009-2022 The Bitcoin Core developers
|
2014-12-01 09:39:44 +08:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2012-05-18 22:02:28 +08:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2013-04-13 00:13:08 -05:00
|
|
|
|
2011-05-15 09:11:04 +02:00
|
|
|
#ifndef BITCOIN_INIT_H
|
|
|
|
#define BITCOIN_INIT_H
|
2010-07-14 15:54:31 +00:00
|
|
|
|
2020-12-01 00:36:36 +01:00
|
|
|
#include <any>
|
2018-02-21 11:38:53 -05:00
|
|
|
#include <memory>
|
2013-10-19 18:42:14 +02:00
|
|
|
#include <string>
|
|
|
|
|
2021-01-25 22:45:54 +01:00
|
|
|
//! Default value for -daemon option
|
|
|
|
static constexpr bool DEFAULT_DAEMON = false;
|
|
|
|
//! Default value for -daemonwait option
|
|
|
|
static constexpr bool DEFAULT_DAEMONWAIT = false;
|
|
|
|
|
2020-08-21 20:13:40 +02:00
|
|
|
class ArgsManager;
|
2020-05-19 15:13:50 +02:00
|
|
|
namespace interfaces {
|
|
|
|
struct BlockAndHeaderTipInfo;
|
|
|
|
}
|
2022-05-25 14:31:54 -04:00
|
|
|
namespace kernel {
|
|
|
|
struct Context;
|
|
|
|
}
|
2021-11-12 10:06:00 -05:00
|
|
|
namespace node {
|
|
|
|
struct NodeContext;
|
|
|
|
} // namespace node
|
2013-04-13 00:13:08 -05: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 */
|
2021-11-12 10:06:00 -05:00
|
|
|
void Interrupt(node::NodeContext& node);
|
|
|
|
void Shutdown(node::NodeContext& node);
|
2015-11-26 14:03:27 +01:00
|
|
|
//!Initialize the logging infrastructure
|
2020-08-21 20:13:40 +02:00
|
|
|
void InitLogging(const ArgsManager& args);
|
2015-10-08 09:58:31 +02:00
|
|
|
//!Parameter interaction: change current parameters depending on various rules
|
2020-08-21 20:13:40 +02:00
|
|
|
void InitParameterInteraction(ArgsManager& args);
|
2016-10-25 11:34:27 +02:00
|
|
|
|
|
|
|
/** Initialize bitcoin core: Basic context setup.
|
2017-07-15 10:46:06 +02:00
|
|
|
* @note This can be done before daemonization. Do not call Shutdown() if this function fails.
|
2016-10-25 11:34:27 +02:00
|
|
|
* @pre Parameters should be parsed and config file should be read.
|
|
|
|
*/
|
2020-12-06 00:14:17 +00:00
|
|
|
bool AppInitBasicSetup(const ArgsManager& args);
|
2016-10-25 11:34:27 +02:00
|
|
|
/**
|
|
|
|
* Initialization: parameter interaction.
|
2017-07-15 10:46:06 +02:00
|
|
|
* @note This can be done before daemonization. Do not call Shutdown() if this function fails.
|
2016-10-25 11:34:27 +02:00
|
|
|
* @pre Parameters should be parsed and config file should be read, AppInitBasicSetup should have been called.
|
|
|
|
*/
|
2022-04-04 14:38:56 +02:00
|
|
|
bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandbox = true);
|
2016-10-25 11:34:27 +02:00
|
|
|
/**
|
compat: remove glibcxx sanity checks
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 functions we use.
There has also been some discussion about the 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 check 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.
2022-05-27 15:54:21 +01:00
|
|
|
* Initialization sanity checks.
|
2017-07-15 10:46:06 +02:00
|
|
|
* @note This can be done before daemonization. Do not call Shutdown() if this function fails.
|
2016-10-25 11:34:27 +02:00
|
|
|
* @pre Parameters should be parsed and config file should be read, AppInitParameterInteraction should have been called.
|
|
|
|
*/
|
2022-05-27 16:47:05 -04:00
|
|
|
bool AppInitSanityChecks(const kernel::Context& kernel);
|
2016-10-25 11:34:27 +02:00
|
|
|
/**
|
2017-07-15 10:46:06 +02:00
|
|
|
* Lock bitcoin core data directory.
|
|
|
|
* @note This should only be done after daemonization. Do not call Shutdown() if this function fails.
|
2016-10-25 11:34:27 +02:00
|
|
|
* @pre Parameters should be parsed and config file should be read, AppInitSanityChecks should have been called.
|
|
|
|
*/
|
2017-07-15 10:46:06 +02:00
|
|
|
bool AppInitLockDataDirectory();
|
2020-05-29 00:07:18 -04:00
|
|
|
/**
|
|
|
|
* Initialize node and wallet interface pointers. Has no prerequisites or side effects besides allocating memory.
|
|
|
|
*/
|
2021-11-12 10:06:00 -05:00
|
|
|
bool AppInitInterfaces(node::NodeContext& node);
|
2017-07-15 10:46:06 +02:00
|
|
|
/**
|
|
|
|
* Bitcoin core main initialization.
|
|
|
|
* @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-11-12 10:06:00 -05:00
|
|
|
bool AppInitMain(node::NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
|
2013-10-11 23:09:59 +02:00
|
|
|
|
2018-04-28 16:54:58 -04:00
|
|
|
/**
|
2020-04-08 19:47:56 -04:00
|
|
|
* Register all arguments with the ArgsManager
|
2018-04-28 16:54:58 -04:00
|
|
|
*/
|
2017-12-05 15:57:12 -05:00
|
|
|
void SetupServerArgs(ArgsManager& argsman);
|
2013-10-11 23:09:59 +02:00
|
|
|
|
2014-08-28 22:21:03 +02:00
|
|
|
#endif // BITCOIN_INIT_H
|