This PR removes the g_rpc_node
global, to get same benefits we see removing other globals and make RPC code more testable, modular, and reusable.
This uses a hybrid of the approaches suggested in #17548. Instead of using std::any
, which isn’t available in c++11, or void*
, which isn’t type safe, it uses a small new util::Ref
helper class, which acts like a simplified std::any
that only holds references, not values.
Motivation for writing this was to provide an simpler alternative to #18647 by Harris Brakmić (brakmic) which avoids some shortcomings of that PR (https://github.com/bitcoin/bitcoin/pull/18647#issuecomment-617878826)