mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Merge bitcoin/bitcoin#25065: [kernel 2c/n] Introduce kernel::Context, encapsulate global init/teardown
d87784ac87kernel: SanityChecks: Return an error struct (Carl Dong)265d6393bfMove init::SanityCheck to kernel::SanityCheck (Carl Dong)fed085a1a4init: Initialize globals with kernel::Context's life (Carl Dong)7d03feef81kernel: Introduce empty and unused kernel::Context (Carl Dong)eeb4fc20c5test: Use Set/UnsetGlobals in BasicTestingSetup (Carl Dong) Pull request description: The full `init/common.cpp` is dependent on things like ArgsManager (which we wish to remove from libbitcoinkernel in the future) and sanity checks. These aren't necessary for libbitcoinkernel so we only extract the portion that is necessary (namely `init::{Set,Unset}Globals()`. ACKs for top commit: theuni: ACKd87784ac87vasild: ACKd87784ac87Tree-SHA512: cd6b4923ea1865001b5f0caed9a4ff99c198d22bf74154d935dc09a47fda22ebe585ec912398cea69f722454ed1dbb4898faab5a2d02fb4c5e719c5c8d71a3f9
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <addrman.h>
|
||||
#include <banman.h>
|
||||
#include <interfaces/chain.h>
|
||||
#include <kernel/context.h>
|
||||
#include <net.h>
|
||||
#include <net_processing.h>
|
||||
#include <netgroup.h>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef BITCOIN_NODE_CONTEXT_H
|
||||
#define BITCOIN_NODE_CONTEXT_H
|
||||
|
||||
#include <kernel/context.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@@ -39,6 +41,8 @@ namespace node {
|
||||
//! any member functions. It should just be a collection of references that can
|
||||
//! be used without pulling in unwanted dependencies or functionality.
|
||||
struct NodeContext {
|
||||
//! libbitcoin_kernel context
|
||||
std::unique_ptr<kernel::Context> kernel;
|
||||
//! Init interface for initializing current process and connecting to other processes.
|
||||
interfaces::Init* init{nullptr};
|
||||
std::unique_ptr<AddrMan> addrman;
|
||||
|
||||
@@ -90,8 +90,16 @@ public:
|
||||
uint32_t getLogCategories() override { return LogInstance().GetCategoryMask(); }
|
||||
bool baseInitialize() override
|
||||
{
|
||||
return AppInitBasicSetup(gArgs) && AppInitParameterInteraction(gArgs, /*use_syscall_sandbox=*/false) && AppInitSanityChecks() &&
|
||||
AppInitLockDataDirectory() && AppInitInterfaces(*m_context);
|
||||
if (!AppInitBasicSetup(gArgs)) return false;
|
||||
if (!AppInitParameterInteraction(gArgs, /*use_syscall_sandbox=*/false)) return false;
|
||||
|
||||
m_context->kernel = std::make_unique<kernel::Context>();
|
||||
if (!AppInitSanityChecks(*m_context->kernel)) return false;
|
||||
|
||||
if (!AppInitLockDataDirectory()) return false;
|
||||
if (!AppInitInterfaces(*m_context)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
bool appInitMain(interfaces::BlockAndHeaderTipInfo* tip_info) override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user