From 31835f2a863316367cbbd7a6525db5974cf7ae4b Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Thu, 29 Jun 2023 12:10:09 -0700 Subject: [PATCH] Prepare access to untrim headers --- src/chain.cpp | 5 +++++ src/chain.h | 6 ++++++ src/init.cpp | 1 + src/node/blockstorage.h | 1 + 4 files changed, 13 insertions(+) diff --git a/src/chain.cpp b/src/chain.cpp index dd5510bfec..6c37bda0bb 100644 --- a/src/chain.cpp +++ b/src/chain.cpp @@ -5,6 +5,11 @@ #include #include +#include +#include + + +node::NodeContext *CBlockIndex::m_pcontext; std::string CBlockFileInfo::ToString() const { diff --git a/src/chain.h b/src/chain.h index 76ba3b1880..0daa00edb7 100644 --- a/src/chain.h +++ b/src/chain.h @@ -16,6 +16,9 @@ #include +namespace node { +struct NodeContext; +} /** * Maximum amount of time that a block timestamp is allowed to exceed the * current network-adjusted time before the block will be accepted. @@ -218,7 +221,10 @@ protected: friend class CBlockTreeDB; + static node::NodeContext *m_pcontext; + public: + static void SetNodeContext(node::NodeContext *context) {m_pcontext = context;}; // Irrevocably remove blocksigning and dynafed-related stuff from this // in-memory copy of the block header. diff --git a/src/init.cpp b/src/init.cpp index 2459964d95..ee19aed4f1 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1243,6 +1243,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) const ArgsManager& args = *Assert(node.args); const CChainParams& chainparams = Params(); + CBlockIndex::SetNodeContext(&node); auto opt_max_upload = ParseByteUnits(args.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET), ByteUnit::M); if (!opt_max_upload) { return InitError(strprintf(_("Unable to parse -maxuploadtarget: '%s'"), args.GetArg("-maxuploadtarget", ""))); diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h index c6621cde78..1276a3f003 100644 --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -76,6 +76,7 @@ class BlockManager { friend CChainState; friend ChainstateManager; + friend CBlockIndex; private: void FlushBlockFile(bool fFinalize = false, bool finalize_undo = false);