node: move index ownership to NodeContext #35474

pull w0xlt wants to merge 6 commits into bitcoin:master from w0xlt:global-state-index-nodecontext changing 30 files +207 −201
  1. w0xlt commented at 6:01 PM on June 6, 2026: contributor

    This removes the remaining process-global index ownership and stores node-owned indexes in NodeContext instead.

    Indexes moved:

    • g_txindex
    • g_txospenderindex
    • g_coin_stats_index
    • g_filter_indexes

    NodeContext now owns these index instances, while node.indexes remains a non-owning list used for common index startup, shutdown, and getindexinfo handling.

    Behavior should be unchanged, apart from the key order in getindexinfo output. Indexes are still created from the same startup options, started in the same init step, stopped before destruction, and destroyed while validation_signals is still alive so they can unregister safely.

    The block filter index registry is moved to node/indexes.{h,cpp} so index/ code does not depend on NodeContext. PeerManager receives a small lookup callback instead of reaching into global state.

    Review notes:

    • The first four commits are small and mostly mechanical: move txindex, txospenderindex, and coinstatsindex ownership to NodeContext, then make getindexinfo use node.indexes. The first commit also adds custom deleters in node/indexes.cpp, so node/context.cpp does not include index headers, which would create circular dependencies.
    • The fifth commit adds a block filter index lookup callback to PeerManager::Options, still backed by the global registry.
    • The last commit is the main one to review carefully. It moves block filter index ownership to NodeContext, moves the block filter registry to node/indexes.{h,cpp}, and points the PeerManager lookup at NodeContext instead of global state.
  2. DrahtBot commented at 6:01 PM on June 6, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK fjahr, maflcko, andrewtoth
    Concept ACK sedited, arejula27

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36920 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36920.svg"></sub> (p2p: Relay stale tip announcements (BIP 332) by pseudoramdom)
    • #36919 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36919.svg"></sub> (p2p: Track recent stale tips (BIP 332) by pseudoramdom)
    • #36813 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36813.svg"></sub> (refactor: more prereqs for #36743 by fanquake)
    • #36808 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36808.svg"></sub> (iwyu: Fix warnings in src/test/fuzz and treat them as errors by hebasto)
    • #36743 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36743.svg"></sub> ([RFC] build: build with -Wmissing-declarations/prototypes by fanquake)
    • #36629 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36629.svg"></sub> (Add output script index and corresponding script history RPC by andrewtoth)
    • #36598 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36598.svg"></sub> ([Demo] validation: remove AssumeUTXO by l0rinc)
    • #36480 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36480.svg"></sub> (txospenderindex: hash keys and pack positions to reduce disk usage by arejula27)
    • #36167 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36167.svg"></sub> (build: Enable -Wunused by fanquake)
    • #36002 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36002.svg"></sub> (txindex: allow running in pruned mode by andrewtoth)
    • #35901 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35901.svg"></sub> (wallet: Fix ScanForWalletTransactions missing tx when look-ahead pool expands mid-block by pablomartin4btc)
    • #34400 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34400.svg"></sub> (wallet: parallel fast rescan by Eunovo)
    • #34132 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34132.svg"></sub> (coins,dbwrapper: make point-read and txindex lookup failures fatal by l0rinc)
    • #31260 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/31260.svg"></sub> (scripted-diff: Type-safe settings retrieval by ryanofsky)
    • #30437 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/30437.svg"></sub> (ipc: add bitcoin-mine test program by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. sedited commented at 7:48 PM on June 6, 2026: contributor

    Concept ACK

  4. sedited requested review from fjahr on Jun 9, 2026
  5. Sjors commented at 8:22 AM on June 17, 2026: member

    How does this interact with #24230?

  6. w0xlt commented at 5:01 PM on June 17, 2026: contributor

    #24230 still keeps process-global index ownership.

    So this PR is mostly orthogonal to it: #24230 changes how indexes sync with the chain and removes index dependencies on node internals, while this PR moves index ownership into NodeContext.

    There is no conceptual conflict. In terms of code there will be rebase conflicts after one or the other lands, since both touch the index/init/RPC/REST paths.

    Removing process-global index ownership seems aligned with the multiprocess direction anyway.

  7. fjahr commented at 2:41 PM on June 21, 2026: contributor

    Concept ACK

  8. willcl-ark added the label Refactoring on Jul 9, 2026
  9. willcl-ark added the label UTXO Db and Indexes on Jul 9, 2026
  10. DrahtBot added the label Needs rebase on Jul 14, 2026
  11. sedited commented at 9:38 AM on August 17, 2026: contributor

    Ping for rebase @w0xlt

  12. w0xlt force-pushed on Aug 18, 2026
  13. w0xlt commented at 10:00 PM on August 18, 2026: contributor

    Rebased. Thanks @sedited

  14. DrahtBot removed the label Needs rebase on Aug 18, 2026
  15. DrahtBot added the label Needs rebase on Aug 21, 2026
  16. w0xlt force-pushed on Sep 15, 2026
  17. w0xlt commented at 11:03 PM on September 15, 2026: contributor

    Reabsed

  18. DrahtBot removed the label Needs rebase on Sep 16, 2026
  19. in src/node/context.h:53 in 3c05b4eb83
      49 | @@ -49,6 +50,20 @@ namespace node {
      50 |  class KernelNotifications;
      51 |  class Warnings;
      52 |  
      53 | +// Keep NodeContext from depending on index modules while still owning indexes.
    


    fjahr commented at 11:09 PM on September 26, 2026:

    Are the custom deleters really needed? NodeContext already handles this for its other unique_ptr members via the destructor here: https://github.com/bitcoin/bitcoin/blob/ed7dd7cf4e1561a97edf72eba29a67b14e28c717/src/node/context.h#L95 Since node/context.cpp and index/*.cpp are both in bitcoin_node, I think you could just add the index includes there and use plain std::unique_ptr<TxIndex> etc.


    w0xlt commented at 8:28 PM on September 30, 2026:

    Thanks! Plain unique_ptrs would compile, but index/base.cpp includes node/context.h, so including the index headers in node/context.cpp introduces new circular dependencies:

    index/base -> node/context -> index/blockfilterindex -> index/base
    index/base -> node/context -> index/coinstatsindex -> index/base
    index/base -> node/context -> index/txindex -> index/base
    index/base -> node/context -> index/txospenderindex -> index/base
    

    The deleters are defined in node/indexes.cpp to avoid that.

    They can be dropped in a follow-up once index/base.cpp no longer needs node/context.h. #24230 already removes most of that dependency, leaving only the AbortNode() call in FatalErrorf(). Replacing that with a Chain method would allow plain unique_ptrs here and also remove the existing index/base -> node/context -> net_processing -> ... lint exception.

    If you'd rather add these to EXPECTED_CIRCULAR_DEPENDENCIES for now, I'm happy to switch to plain unique_ptrs.

    I've updated the code comment and commit message to make the reason clearer.


    fjahr commented at 12:40 PM on November 17, 2026:

    Ok, it seems fine for me to keep the deleters then.

  20. w0xlt force-pushed on Sep 30, 2026
  21. w0xlt commented at 8:33 PM on September 30, 2026: contributor

    PR description updated.

  22. DrahtBot added the label Needs rebase on Oct 7, 2026
  23. sedited commented at 10:14 AM on November 12, 2026: contributor

    Ping for rebase @w0xlt. I'm still interested in the change.

  24. w0xlt force-pushed on Nov 13, 2026
  25. w0xlt commented at 10:11 PM on November 13, 2026: contributor

    Rebased on master. Thanks @sedited for the ping.

  26. DrahtBot removed the label Needs rebase on Nov 13, 2026
  27. in src/rpc/node.cpp:415 in 4b97f3c534 outdated
     408 | -
     409 | -    if (node.txospenderindex) {
     410 | -        result.pushKVs(SummaryToJSON(node.txospenderindex->GetSummary(), index_name));
     411 | -    }
     412 | -
     413 | -    ForEachBlockFilterIndex([&result, &index_name](const BlockFilterIndex& index) {
    


    fjahr commented at 12:43 PM on November 17, 2026:

    This was to only caller of ForEachBlockFilterIndex aside from a test. So the function can be removed here as well.


    w0xlt commented at 1:43 AM on November 18, 2026:

    Done. Thanks

  28. in src/node/indexes.h:28 in 8dae231004
      23 | +/**
      24 | + * Get a block filter index by type. Returns nullptr if index has not been initialized or was
      25 | + * already destroyed.
      26 | + */
      27 | +BlockFilterIndex* GetBlockFilterIndex(NodeContext& node, BlockFilterType filter_type);
      28 | +const BlockFilterIndex* GetBlockFilterIndex(const NodeContext& node, BlockFilterType filter_type);
    


    fjahr commented at 12:46 PM on November 17, 2026:

    Not sure what this const version of the function is useful for, it seems it can be dropped?


    w0xlt commented at 1:43 AM on November 18, 2026:

    Done. Thanks

  29. in src/init.cpp:62 in 8dae231004 outdated
      58 | @@ -59,6 +59,7 @@
      59 |  #include <node/chainstatemanager_args.h>
      60 |  #include <node/context.h>
      61 |  #include <node/interface_ui.h>
      62 | +#include <node/indexes.h>
    


    fjahr commented at 12:48 PM on November 17, 2026:

    nit: ordering (same in the node/interfaces.cpp file)


    w0xlt commented at 1:42 AM on November 18, 2026:

    Done. Thanks

  30. in src/rpc/blockchain.cpp:1018 in fc334648c9 outdated
    1014 | @@ -1015,18 +1015,19 @@ CoinStatsHashType ParseHashType(std::string_view hash_type_input)
    1015 |   * @param[in] index_requested Signals if the coinstatsindex should be used (when available).
    1016 |   */
    1017 |  static std::optional<kernel::CCoinsStats> GetUTXOStats(const CCoinsViewDB& view, node::BlockManager& blockman,
    1018 | +                                                       const CoinStatsIndex* coin_stats_index,
    


    fjahr commented at 1:31 PM on November 17, 2026:

    Now that the index is passed in as a nullable pointer, index_requested is redundant. GetUTXOStats only reads it as coin_stats_index && index_requested, so gettxoutsetinfo can pass nullptr when use_index is false and the bool parameter can go.

    <details> <summary>Suggested diff</summary>

    diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
    index ab061346c9..92c8cfdf57 100644
    --- a/src/rpc/blockchain.cpp
    +++ b/src/rpc/blockchain.cpp
    @@ -1012,17 +1012,16 @@ CoinStatsHashType ParseHashType(std::string_view hash_type_input)
     /**
      * Calculate statistics about the unspent transaction output set
      *
    - * [@param](/bitcoin-bitcoin/contributor/param/)[in] index_requested Signals if the coinstatsindex should be used (when available).
    + * [@param](/bitcoin-bitcoin/contributor/param/)[in] coin_stats_index The coinstatsindex to use, or nullptr to compute the statistics from the view.
      */
     static std::optional<kernel::CCoinsStats> GetUTXOStats(const CCoinsViewDB& view, node::BlockManager& blockman,
                                                            const CoinStatsIndex* coin_stats_index,
                                                            kernel::CoinStatsHashType hash_type,
                                                            const std::function<void()>& interruption_point = {},
    -                                                       const CBlockIndex* pindex = nullptr,
    -                                                       bool index_requested = true)
    +                                                       const CBlockIndex* pindex = nullptr)
     {
    -    // Use CoinStatsIndex if it is requested and available and a hash_type of Muhash or None was requested
    -    if ((hash_type == kernel::CoinStatsHashType::MUHASH || hash_type == kernel::CoinStatsHashType::NONE) && coin_stats_index && index_requested) {
    +    // Use CoinStatsIndex if it is provided and a hash_type of Muhash or None was requested
    +    if ((hash_type == kernel::CoinStatsHashType::MUHASH || hash_type == kernel::CoinStatsHashType::NONE) && coin_stats_index) {
             if (pindex) {
                 return coin_stats_index->LookUpStats(*pindex);
             } else {
    @@ -1102,6 +1101,7 @@ static RPCMethod gettxoutsetinfo()
         const bool index_requested{self.Arg<bool>("use_index")};
    
         NodeContext& node = EnsureAnyNodeContext(request.context);
    +    const CoinStatsIndex* const coin_stats_index{index_requested ? node.coin_stats_index.get() : nullptr};
         ChainstateManager& chainman = EnsureChainman(node);
         Chainstate& active_chainstate = chainman.ActiveChainstate();
         active_chainstate.ForceFlushStateToDisk(/*wipe_cache=*/false);
    @@ -1125,9 +1125,9 @@ static RPCMethod gettxoutsetinfo()
             pindex = ParseHashOrHeight(request.params[1], chainman);
         }
    
    -    if (index_requested && node.coin_stats_index) {
    -        if (!node.coin_stats_index->BlockUntilSyncedToCurrentChain()) {
    -            const IndexSummary summary{node.coin_stats_index->GetSummary()};
    +    if (coin_stats_index) {
    +        if (!coin_stats_index->BlockUntilSyncedToCurrentChain()) {
    +            const IndexSummary summary{coin_stats_index->GetSummary()};
    
                 // If a specific block was requested and the index has already synced past that height, we can return the
                 // data already even though the index is not fully synced yet.
    @@ -1137,7 +1137,7 @@ static RPCMethod gettxoutsetinfo()
             }
         }
    
    -    const std::optional<CCoinsStats> maybe_stats = GetUTXOStats(coins_view, blockman, node.coin_stats_index.get(), hash_type, node.rpc_interruption_point, pindex, index_requested);
    +    const std::optional<CCoinsStats> maybe_stats = GetUTXOStats(coins_view, blockman, coin_stats_index, hash_type, node.rpc_interruption_point, pindex);
         if (maybe_stats.has_value()) {
             const CCoinsStats& stats = maybe_stats.value();
             ret.pushKV("height", stats.nHeight);
    @@ -1159,7 +1159,7 @@ static RPCMethod gettxoutsetinfo()
                 CCoinsStats prev_stats{};
                 if (stats.nHeight > 0) {
                     const CBlockIndex& block_index = *CHECK_NONFATAL(WITH_LOCK(::cs_main, return blockman.LookupBlockIndex(stats.hashBlock)));
    -                const std::optional<CCoinsStats> maybe_prev_stats = GetUTXOStats(coins_view, blockman, node.coin_stats_index.get(), hash_type, node.rpc_interruption_point, block_index.pprev, index_requested);
    +                const std::optional<CCoinsStats> maybe_prev_stats = GetUTXOStats(coins_view, blockman, coin_stats_index, hash_type, node.rpc_interruption_point, block_index.pprev);
                     if (!maybe_prev_stats) {
                         throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set");
                     }
    

    </details>


    w0xlt commented at 1:42 AM on November 18, 2026:

    Done. Thanks

  31. in src/node/indexes.cpp:58 in 8dae231004
      53 | +            node.block_filter_indexes.erase(it);
      54 | +            return true;
      55 | +        }
      56 | +    }
      57 | +    return false;
      58 | +}
    


    fjahr commented at 1:43 PM on November 17, 2026:

    I think it's actually not needed to move all this code over here, given that the vector of blockfilter indexes is a public member now anyway. We could just do things directly using that and remove almost 100 LOC compared to the current version here: https://github.com/fjahr/bitcoin/commit/7e6b7f84277a7b5915aac12659c7bbef25bc654b and I see no real downside to this.


    w0xlt commented at 1:42 AM on November 18, 2026:

    Done. Thanks. Added you as co-author.

  32. fjahr commented at 1:57 PM on November 17, 2026: contributor

    Looks in pretty good shape but I think there may be more lines of code that can be saved from the last commit :)

  33. w0xlt force-pushed on Nov 18, 2026
  34. in src/node/indexes.h:1 in 560faa4310
       0 | @@ -0,0 +1,23 @@
       1 | +// Copyright (c) 2026-present The Bitcoin Core developers
    


    fjahr commented at 10:00 PM on November 18, 2026:

    nit

    // Copyright (c) The Bitcoin Core developers
    

    w0xlt commented at 12:07 AM on November 19, 2026:

    Done. Thanks.

  35. in src/wallet/test/rescan_tests.cpp:260 in 560faa4310
     256 | @@ -258,7 +257,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions_reorged_block, TestChain100
     257 |      }
     258 |  
     259 |      StopIndex(filter_index, m_node);
     260 | -    BOOST_REQUIRE(DestroyBlockFilterIndex(BlockFilterType::BASIC));
     261 | +    m_node.block_filter_indexes.clear();
    


    fjahr commented at 10:05 PM on November 18, 2026:

    nit: The clear() calls (here and one more below) seem to be redundant since the unit test framework does it for us: https://github.com/bitcoin/bitcoin/blob/d55f55eda79a98ddaad7f7bec9faca8beb097b99/src/test/util/setup_common.cpp#L349 I suspect the idea behind doing it explicitly here was to check the return value but I think I would rather suggest removing those lines.


    w0xlt commented at 12:07 AM on November 19, 2026:

    Done. Thanks.

  36. in src/node/context.h:54 in 560faa4310
      47 | @@ -44,6 +48,22 @@ class BlockTemplateManager;
      48 |  class KernelNotifications;
      49 |  class Warnings;
      50 |  
      51 | +// Custom deleters let NodeContext own indexes without node/context.cpp
      52 | +// including index headers. Index code includes node/context.h, so including
      53 | +// index headers there would create a circular dependency.
      54 | +struct BlockFilterIndexDeleter {
    


    fjahr commented at 10:09 PM on November 18, 2026:

    nit: The four deleter structs could be one struct with four overloads to save a few extra lines. unique_ptr picks the matching overload by pointer type, and that works with the forward declarations here.

    <details> <summary>Suggested diff</summary>

    diff --git a/src/node/context.h b/src/node/context.h
    index ed9e3297e76..ef7916c5350 100644
    --- a/src/node/context.h
    +++ b/src/node/context.h
    @@ -48,19 +48,13 @@ class BlockTemplateManager;
     class KernelNotifications;
     class Warnings;
    
    -// Custom deleters let NodeContext own indexes without node/context.cpp
    +// A custom deleter lets NodeContext own indexes without node/context.cpp
     // including index headers. Index code includes node/context.h, so including
     // index headers there would create a circular dependency.
    -struct BlockFilterIndexDeleter {
    +struct IndexDeleter {
         void operator()(BlockFilterIndex* index) const noexcept;
    -};
    -struct CoinStatsIndexDeleter {
         void operator()(CoinStatsIndex* index) const noexcept;
    -};
    -struct TxIndexDeleter {
         void operator()(TxIndex* index) const noexcept;
    -};
    -struct TxoSpenderIndexDeleter {
         void operator()(TxoSpenderIndex* index) const noexcept;
     };
    
    @@ -108,10 +102,10 @@ struct NodeContext {
         //! Issues calls about blocks and transactions
         std::unique_ptr<ValidationSignals> validation_signals;
         //! Declared after validation_signals so index destructors can unregister safely.
    -    std::vector<std::unique_ptr<BlockFilterIndex, BlockFilterIndexDeleter>> block_filter_indexes;
    -    std::unique_ptr<TxIndex, TxIndexDeleter> txindex;
    -    std::unique_ptr<TxoSpenderIndex, TxoSpenderIndexDeleter> txospenderindex;
    -    std::unique_ptr<CoinStatsIndex, CoinStatsIndexDeleter> coin_stats_index;
    +    std::vector<std::unique_ptr<BlockFilterIndex, IndexDeleter>> block_filter_indexes;
    +    std::unique_ptr<TxIndex, IndexDeleter> txindex;
    +    std::unique_ptr<TxoSpenderIndex, IndexDeleter> txospenderindex;
    +    std::unique_ptr<CoinStatsIndex, IndexDeleter> coin_stats_index;
         std::atomic<int> exit_status{EXIT_SUCCESS};
         //! Manages all the node warnings
         std::unique_ptr<node::Warnings> warnings;
    diff --git a/src/node/indexes.cpp b/src/node/indexes.cpp
    index f9fd1851006..8fccb3feb2b 100644
    --- a/src/node/indexes.cpp
    +++ b/src/node/indexes.cpp
    @@ -12,10 +12,10 @@
    
     namespace node {
    
    -void BlockFilterIndexDeleter::operator()(BlockFilterIndex* index) const noexcept { delete index; }
    -void CoinStatsIndexDeleter::operator()(CoinStatsIndex* index) const noexcept { delete index; }
    -void TxIndexDeleter::operator()(TxIndex* index) const noexcept { delete index; }
    -void TxoSpenderIndexDeleter::operator()(TxoSpenderIndex* index) const noexcept { delete index; }
    +void IndexDeleter::operator()(BlockFilterIndex* index) const noexcept { delete index; }
    +void IndexDeleter::operator()(CoinStatsIndex* index) const noexcept { delete index; }
    +void IndexDeleter::operator()(TxIndex* index) const noexcept { delete index; }
    +void IndexDeleter::operator()(TxoSpenderIndex* index) const noexcept { delete index; }
    
     BlockFilterIndex* GetBlockFilterIndex(const NodeContext& node, BlockFilterType filter_type)
     {
    

    </details>


    w0xlt commented at 12:07 AM on November 19, 2026:

    Done. Thanks.

  37. in src/node/context.h:110 in 560faa4310
     106 | @@ -87,6 +107,11 @@ struct NodeContext {
     107 |      std::unique_ptr<BlockTemplateManager> block_template_manager;
     108 |      //! Issues calls about blocks and transactions
     109 |      std::unique_ptr<ValidationSignals> validation_signals;
     110 | +    //! Declared after validation_signals so index destructors can unregister safely.
    


    fjahr commented at 10:15 PM on November 18, 2026:

    nit: I think it should also be below warnings because there is a call in BaseIndex::FatalErrorf. It seems to be a non-issue because the shutdown handles the indexes explicitly but it might be nicer to not rely on that.


    w0xlt commented at 12:07 AM on November 19, 2026:

    Done. Thanks.

  38. in src/node/context.h:97 in 560faa4310
      93 | @@ -74,7 +94,7 @@ struct NodeContext {
      94 |      std::unique_ptr<ChainstateManager> chainman;
      95 |      std::unique_ptr<BanMan> banman;
      96 |      ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
      97 | -    std::vector<BaseIndex*> indexes; // raw pointers because memory is not managed by this struct
      98 | +    std::vector<BaseIndex*> indexes; // raw pointers because memory is managed by index owner members below or elsewhere
    


    fjahr commented at 10:16 PM on November 18, 2026:

    nit: I don't think there is any other place?

        std::vector<BaseIndex*> indexes; // raw pointers because memory is managed by index owner members below
    

    w0xlt commented at 12:08 AM on November 19, 2026:

    Done. Thanks.

  39. in src/init.cpp:2026 in 560faa4310
    2027 |      }
    2028 |  
    2029 |      for (const auto& filter_type : g_enabled_filter_types) {
    2030 | -        InitBlockFilterIndex([&]{ return interfaces::MakeChain(node); }, filter_type, index_cache_sizes.filter_index, false, do_reindex);
    2031 | -        node.indexes.emplace_back(GetBlockFilterIndex(filter_type));
    2032 | +        auto& index{node.block_filter_indexes.emplace_back(new BlockFilterIndex(interfaces::MakeChain(node), filter_type, index_cache_sizes.filter_index, /*f_memory=*/false, do_reindex))};
    


    fjahr commented at 10:24 PM on November 18, 2026:

    nit: The usage of new isn't really our preferred style afaik but there seems to be no hard rule about it and the way the deleters are used this seems to be unavoidable. I guess there may be ways to avoid it but not sure if that is worth it. Just noting that this is a bit of an unusual sight here.


    w0xlt commented at 12:08 AM on November 19, 2026:

    Done. Thanks.

  40. fjahr commented at 10:29 PM on November 18, 2026: contributor

    Code review ACK 560faa4310a30e85a568d4f5866364afdeec97e7

    Thank you for taking my suggestions! I found a few more nits that you may address when you have to retouch but this already looks good to me as is.

  41. DrahtBot requested review from sedited on Nov 18, 2026
  42. node: move txindex ownership to NodeContext
    Replace the g_txindex global with NodeContext::txindex and pass the
    index to GetTransaction() explicitly instead of reading the global.
    
    IndexDeleter destroys indexes in node/indexes.cpp because including
    index headers in node/context.cpp would create circular dependencies
    (index/base.cpp includes node/context.h). The index pointers can use
    default deleters once index code no longer depends on NodeContext.
    
    Co-authored-by: Fabian Jahr <fjahr@protonmail.com>
    530cf35c17
  43. node: move txospenderindex ownership to NodeContext
    Co-authored-by: Fabian Jahr <fjahr@protonmail.com>
    2d1dc8f18a
  44. node: move coinstatsindex ownership to NodeContext
    Co-authored-by: Fabian Jahr <fjahr@protonmail.com>
    fafedc683a
  45. rpc: get index info from NodeContext indexes
    getindexinfo now iterates NodeContext::indexes instead of querying each
    index type separately. The set of reported indexes is unchanged, but
    when several indexes are enabled the keys in the result follow the
    order in which the indexes are registered at startup.
    e5b76bbdbb
  46. net_processing: get block filter index via PeerManager::Options
    Add a get_block_filter_index callback to PeerManager::Options and use it
    instead of calling the global GetBlockFilterIndex() directly. Callers
    still pass the global lookup, so behavior is unchanged.
    
    This lets the next commit move block filter index ownership without
    net_processing depending on NodeContext.
    66892cdd56
  47. node: move block filter index ownership to NodeContext
    Co-authored-by: Fabian Jahr <fjahr@protonmail.com>
    bb357fcd2f
  48. w0xlt force-pushed on Nov 19, 2026
  49. in src/node/indexes.cpp:1 in 530cf35c17
       0 | @@ -0,0 +1,12 @@
       1 | +// Copyright (c) 2026-present The Bitcoin Core developers
    


    maflcko commented at 7:48 AM on November 19, 2026:

    nit in the first commit: Remove 2026-present to stay in symmetry with the header?

  50. in src/rpc/txoutproof.cpp:101 in 530cf35c17
      98 | @@ -96,12 +99,12 @@ static RPCMethod gettxoutproof()
      99 |  
     100 |  
     101 |              // Allow txindex to catch up if we need to query it and before we acquire cs_main.
    


    maflcko commented at 7:52 AM on November 19, 2026:

    unrelated nit in the first commit: After commit d7f61e7d5909da7227c9e34be06ce9eb872ba074, the comment here can be removed:

    • txindex->BlockUntilSyncedToCurrentChain(); should be self-explanatory what it does, and
    • the cs_main reference is confusing, because it is only taken for the block index lookup, and it is unclear why txindex syncing has anything to do with a block index lookup.

    Recall the same call is in getrawtransaction, but there is also no comment.

  51. fjahr commented at 9:14 AM on November 19, 2026: contributor

    ACK bb357fcd2fc55807905868e3c394579306ec4b44

  52. maflcko approved
  53. maflcko commented at 9:46 AM on November 19, 2026: member

    review ACK bb357fcd2fc55807905868e3c394579306ec4b44 💬

    <details><summary>Show signature</summary>

    Signature:

    untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
    RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    trusted comment: review ACK bb357fcd2fc55807905868e3c394579306ec4b44 💬
    AElXbC1q9pomR1mLDG2pqxpPSZy34YKQTMX1Odyj1X52obAmxMT83TCMIBUbCS0Cibon200MhdxJj21PBt8TCA==
    

    </details>

  54. arejula27 commented at 3:55 PM on November 21, 2026: contributor

    Concept ACK

    I had been thinking about how to do this without knowing this PR already existed. I think moving index ownership out of globals and into NodeContext is a good idea

  55. in src/rpc/node.cpp:400 in bb357fcd2f
     393 | @@ -398,23 +394,12 @@ static RPCMethod getindexinfo()
     394 |  {
     395 |      UniValue result(UniValue::VOBJ);
     396 |      const std::string index_name{self.MaybeArg<std::string_view>("index_name").value_or("")};
     397 | +    const NodeContext& node{EnsureAnyNodeContext(request.context)};
     398 |  
     399 | -    if (g_txindex) {
     400 | -        result.pushKVs(SummaryToJSON(g_txindex->GetSummary(), index_name));
     401 | +    for (const auto* index : node.indexes) {
     402 | +        result.pushKVs(SummaryToJSON(index->GetSummary(), index_name));
    


    andrewtoth commented at 4:05 AM on November 23, 2026:

    nit: We could inline SummaryToJSON now.


    678537201w-art commented at 4:25 AM on November 23, 2026:

    SummaryToJSON


    dunlapjschool-gif commented at 4:37 AM on November 23, 2026:

    huh

  56. andrewtoth approved
  57. andrewtoth commented at 4:09 AM on November 23, 2026: contributor

    ACK bb357fcd2fc55807905868e3c394579306ec4b44

  58. bitcoin deleted a comment on Nov 23, 2026
  59. fanquake merged this on Nov 23, 2026
  60. fanquake closed this on Nov 23, 2026


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-27 03:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me