Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
751const auto compute_depth{[] (const NodeU32& node) -> size_t {752size_t depth{0};753for (const auto* n{&node}; !n->Subs().empty(); n = &n->Subs().front()) {754++depth;755}756return depth;757}};759constexpr auto ctx{miniscript::MiniscriptContext::TAPSCRIPT};760NodeU32 root{NoDupCheck{}, ctx, Fragment::JUST_1};761// Some CI jobs run with CI_LIMIT_STACK_SIZE which reduces the stack size762// via ulimit to 512 kbytes. When tested with ~Node()=default (stack-unsafe)763// implementations the test has been shown to fail for the below depth.764// The test may pass locally despite stack-unsafe implementations unless the765// stack is reduced in a similar way or the depth is temporarily increased.766constexpr size_t depth{200'000};767for (size_t i{0}; i < depth; ++i) {768root = NodeU32{NoDupCheck{}, ctx, Fragment::WRAP_N, Vector(std::move(root))};769}770BOOST_CHECK(root.IsValid());771BOOST_CHECK_EQUAL(compute_depth(root), depth);773auto clone{root.Clone()};774BOOST_CHECK_EQUAL(compute_depth(clone), depth);776clone = std::move(root);777BOOST_CHECK_EQUAL(compute_depth(clone), depth);778}780BOOST_AUTO_TEST_SUITE_END()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.