From cbdbae2be1bd601f14e8dc128d2327d30eefd8fe Mon Sep 17 00:00:00 2001 From: Ken Sedgwick Date: Mon, 8 Jun 2026 12:30:32 -0700 Subject: [PATCH] Add rebalancer mode selector (classic/off) as a dynamic option Introduces a single source of truth for which rebalancing track is active. Boss::Mod::RebalanceModeManager owns the mode in memory (no sqlite, so a restart reverts to the configured default, giving a known-good baseline on every boot) and registers clboss-rebalance-mode as a dynamic option: the config file sets the startup default and `setconfig clboss-rebalance-mode ` switches it at runtime without a restart. It answers RequestRebalanceMode queries and reports the mode under clboss-status. Modes are "classic" (run the rebalancer) and "off" (a real quiesce, also the supported way to disable rebalancing entirely). This is the seam that later lets a second rebalancing track coexist and be toggled without a restart. The classic-track rebalancers self-gate on the mode at their existing decision points, modeled on RebalanceUnmanager: EarningsRebalancer gates its trigger, InitialRebalancer gates its run, and JitRebalancer gates the top of htlc_accepted so that in off mode it does not defer the HTLC and adds no forwarding latency. A header-only Boss::ModG:: RebalanceModeProxy provides get_mode for the gate sites. off composes with the existing per-peer unmanage balance tag: off wins globally, otherwise the per-peer tag still excludes specific peers. The three rebalancers' unit tests now install a RebalanceModeManager on the test bus so the self-gate query is answered (default classic, so they behave as before). Without a responder the RequestRebalanceMode ReqResp is never satisfied and leaks, which the valgrind-checked tests flag as a failure. New files: Boss/RebalanceMode.hpp, Boss/Msg/RequestRebalanceMode.hpp, Boss/Msg/ResponseRebalanceMode.hpp, Boss/ModG/RebalanceModeProxy.hpp, Boss/Mod/RebalanceModeManager.{hpp,cpp}. --- Boss/Mod/EarningsRebalancer.cpp | 34 +++++-- Boss/Mod/InitialRebalancer.cpp | 35 +++++--- Boss/Mod/JitRebalancer.cpp | 33 ++++--- Boss/Mod/RebalanceModeManager.cpp | 118 +++++++++++++++++++++++++ Boss/Mod/RebalanceModeManager.hpp | 40 +++++++++ Boss/Mod/all.cpp | 2 + Boss/ModG/RebalanceModeProxy.hpp | 53 +++++++++++ Boss/Msg/RequestRebalanceMode.hpp | 17 ++++ Boss/Msg/ResponseRebalanceMode.hpp | 21 +++++ Boss/RebalanceMode.hpp | 52 +++++++++++ Makefile.am | 6 ++ tests/boss/test_earningsrebalancer.cpp | 5 ++ tests/boss/test_initialrebalancer.cpp | 5 ++ tests/boss/test_jitrebalancer.cpp | 5 ++ 14 files changed, 393 insertions(+), 33 deletions(-) create mode 100644 Boss/Mod/RebalanceModeManager.cpp create mode 100644 Boss/Mod/RebalanceModeManager.hpp create mode 100644 Boss/ModG/RebalanceModeProxy.hpp create mode 100644 Boss/Msg/RequestRebalanceMode.hpp create mode 100644 Boss/Msg/ResponseRebalanceMode.hpp create mode 100644 Boss/RebalanceMode.hpp diff --git a/Boss/Mod/EarningsRebalancer.cpp b/Boss/Mod/EarningsRebalancer.cpp index 6e5e871..478ab29 100644 --- a/Boss/Mod/EarningsRebalancer.cpp +++ b/Boss/Mod/EarningsRebalancer.cpp @@ -1,5 +1,6 @@ #include"Boss/Mod/EarningsRebalancer.hpp" +#include"Boss/ModG/RebalanceModeProxy.hpp" #include"Boss/ModG/RebalanceUnmanagerProxy.hpp" #include"Boss/ModG/ReqResp.hpp" #include"Boss/Msg/CommandRequest.hpp" @@ -82,6 +83,7 @@ private: std::map earnings; ModG::RebalanceUnmanagerProxy unmanager; + ModG::RebalanceModeProxy mode_proxy; std::set const* unmanaged; std::uint32_t max_fee_ppm; @@ -105,17 +107,30 @@ private: if (working) return Ev::lift(); - working = true; - return Boss::log( bus, Debug - , "EarningsRebalancer: Triggering." - ).then([this]() { - return run(); - }).then([this]() { - working = false; + /* Self-gate on the rebalance mode: only the + * "classic" track runs the EarningsRebalancer. */ + return mode_proxy.get_mode().then([this](RebalanceMode m) { + if (m != RebalanceMode::classic) + return Boss::log( bus, Debug + , "EarningsRebalancer: " + "rebalance mode is not " + "\"classic\", skipping." + ); + if (working) + return Ev::lift(); + working = true; return Boss::log( bus, Debug - , "EarningsRebalancer: Finished." - ); + , "EarningsRebalancer: Triggering." + ).then([this]() { + return run(); + }).then([this]() { + working = false; + + return Boss::log( bus, Debug + , "EarningsRebalancer: Finished." + ); + }); }); }); @@ -395,6 +410,7 @@ public: ) : bus(bus_) , earnings_rr(bus_) , unmanager(bus_) + , mode_proxy(bus_) { start(); } }; diff --git a/Boss/Mod/InitialRebalancer.cpp b/Boss/Mod/InitialRebalancer.cpp index 2cf8073..6b526d1 100644 --- a/Boss/Mod/InitialRebalancer.cpp +++ b/Boss/Mod/InitialRebalancer.cpp @@ -1,4 +1,5 @@ #include"Boss/Mod/InitialRebalancer.hpp" +#include"Boss/ModG/RebalanceModeProxy.hpp" #include"Boss/ModG/RebalanceUnmanagerProxy.hpp" #include"Boss/ModG/ReqResp.hpp" #include"Boss/Msg/ListpeersResult.hpp" @@ -63,6 +64,7 @@ private: ExpenseRR expense_rr; /* Interface to the rebalance unmanager. */ ModG::RebalanceUnmanagerProxy unmanager; + ModG::RebalanceModeProxy mode_proxy; /* Peers currently being rebalanced. */ std::set current_sources; @@ -103,19 +105,25 @@ private: Ev::Io run(Boss::Mod::ConstructedListpeers const& peers) { auto ppeers = std::make_shared(peers); - return Ev::lift().then([this]() { - return unmanager.get_unmanaged(); - }).then([ this - , ppeers - ](std::set const* unmanagedp) { - return Boss::concurrent( Run( bus - , *ppeers - , move_rr - , expense_rr - , current_sources - , *unmanagedp - ).run() - ); + return mode_proxy.get_mode().then([this, ppeers](RebalanceMode m) { + /* Self-gate on the rebalance mode: only the "classic" + * track runs the InitialRebalancer. */ + if (m != RebalanceMode::classic) + return Ev::lift(); + return Ev::lift().then([this]() { + return unmanager.get_unmanaged(); + }).then([ this + , ppeers + ](std::set const* unmanagedp) { + return Boss::concurrent( Run( bus + , *ppeers + , move_rr + , expense_rr + , current_sources + , *unmanagedp + ).run() + ); + }); }); } @@ -130,6 +138,7 @@ public: , move_rr(bus_) , expense_rr(bus_) , unmanager(bus_) + , mode_proxy(bus_) { start(); } }; diff --git a/Boss/Mod/JitRebalancer.cpp b/Boss/Mod/JitRebalancer.cpp index d204afe..6506fb1 100644 --- a/Boss/Mod/JitRebalancer.cpp +++ b/Boss/Mod/JitRebalancer.cpp @@ -1,4 +1,5 @@ #include"Boss/Mod/JitRebalancer.hpp" +#include"Boss/ModG/RebalanceModeProxy.hpp" #include"Boss/ModG/RebalanceUnmanagerProxy.hpp" #include"Boss/ModG/ReqResp.hpp" #include"Boss/ModG/RpcProxy.hpp" @@ -108,6 +109,7 @@ private: PeerFromScidRR peer_from_scid_rr; ModG::RebalanceUnmanagerProxy unmanager; + ModG::RebalanceModeProxy mode_proxy; std::uint32_t max_rebalance_fee_ppm; void start() { @@ -151,18 +153,26 @@ private: if (!req.next_channel) return Ev::lift(false); - /* Get it from the table. */ - return peer_from_scid_rr.execute(Msg::RequestPeerFromScid{ - nullptr, req.next_channel - }).then([ this - , req - ](Msg::ResponsePeerFromScid const& r) { - if (!r.peer) + /* Self-gate on the rebalance mode: JIT rebalancing only runs + * in the "classic" track. In other modes do not defer the + * HTLC, so forwarding is never delayed by the JIT logic. */ + return mode_proxy.get_mode().then([this, req](RebalanceMode m) { + if (m != RebalanceMode::classic) return Ev::lift(false); - return htlc_accepted_cont( r.peer - , req.id - , req.next_amount - ); + + /* Get it from the table. */ + return peer_from_scid_rr.execute(Msg::RequestPeerFromScid{ + nullptr, req.next_channel + }).then([ this + , req + ](Msg::ResponsePeerFromScid const& r) { + if (!r.peer) + return Ev::lift(false); + return htlc_accepted_cont( r.peer + , req.id + , req.next_amount + ); + }); }); } Ev::Io @@ -239,6 +249,7 @@ public: , move_funds_rr(bus) , peer_from_scid_rr(bus) , unmanager(bus) + , mode_proxy(bus) { start(); } }; diff --git a/Boss/Mod/RebalanceModeManager.cpp b/Boss/Mod/RebalanceModeManager.cpp new file mode 100644 index 0000000..7bf3ead --- /dev/null +++ b/Boss/Mod/RebalanceModeManager.cpp @@ -0,0 +1,118 @@ +#include"Boss/Mod/RebalanceModeManager.hpp" +#include"Boss/Msg/Manifestation.hpp" +#include"Boss/Msg/ManifestOption.hpp" +#include"Boss/Msg/Option.hpp" +#include"Boss/Msg/OptionType.hpp" +#include"Boss/Msg/ProvideStatus.hpp" +#include"Boss/Msg/RequestRebalanceMode.hpp" +#include"Boss/Msg/ResponseRebalanceMode.hpp" +#include"Boss/Msg/SolicitStatus.hpp" +#include"Boss/RebalanceMode.hpp" +#include"Boss/log.hpp" +#include"Ev/Io.hpp" +#include"Json/Out.hpp" +#include"S/Bus.hpp" +#include"Util/make_unique.hpp" + +namespace { + +/* Single dynamic option: the config file sets the startup default and + * `setconfig clboss-rebalance-mode ` switches it at runtime. */ +auto const option_name = std::string("clboss-rebalance-mode"); + +} + +namespace Boss { namespace Mod { + +class RebalanceModeManager::Impl { +private: + S::Bus& bus; + + RebalanceMode mode; + + void start() { + mode = default_rebalance_mode; + + bus.subscribe([this](Msg::Manifestation const& _) { + return bus.raise(Msg::ManifestOption{ + option_name, + Msg::OptionType_String, + Json::Out::direct(std::string( + rebalance_mode_to_string( + default_rebalance_mode + ) + )), + "Rebalancer mode: \"classic\" (the original " + "rebalancer) or \"off\" (disable rebalancing). " + " Set in the config for the startup default or " + "at runtime with " + "`setconfig clboss-rebalance-mode `.", + true /* dynamic: runtime-settable via setconfig */ + }); + }); + + bus.subscribe([this](Msg::Option const& o) { + if (o.name != option_name) + return Ev::lift(); + auto s = std::string(o.value); + auto m = RebalanceMode(); + if (!rebalance_mode_from_string(s, m)) + return Boss::log( bus, Error + , "RebalanceModeManager: " + "ignoring unrecognized " + "%s value \"%s\"; " + "keeping \"%s\"." + , option_name.c_str() + , s.c_str() + , rebalance_mode_to_string(mode) + ); + if (m == mode) + return Ev::lift(); + mode = m; + return Boss::log( bus, Info + , "RebalanceModeManager: " + "mode set to \"%s\"." + , rebalance_mode_to_string(mode) + ); + }); + + bus.subscribe([this](Msg::RequestRebalanceMode const& m) { + return bus.raise(Msg::ResponseRebalanceMode{ + m.requester, mode + }); + }); + + bus.subscribe([this](Msg::SolicitStatus const& _) { + auto out = Json::Out(); + out.start_object() + .field("mode", std::string(rebalance_mode_to_string(mode))) + .end_object() + ; + return bus.raise(Msg::ProvideStatus{ + "rebalance_mode", std::move(out) + }); + }); + } + +public: + Impl() =delete; + Impl(Impl&&) =delete; + Impl(Impl const&) =delete; + + explicit + Impl(S::Bus& bus_) : bus(bus_) { + start(); + } +}; + +RebalanceModeManager::RebalanceModeManager(RebalanceModeManager&&) =default; +RebalanceModeManager::~RebalanceModeManager() =default; + +RebalanceModeManager::RebalanceModeManager(S::Bus& bus) + : pimpl(Util::make_unique(bus)) { } + +}} diff --git a/Boss/Mod/RebalanceModeManager.hpp b/Boss/Mod/RebalanceModeManager.hpp new file mode 100644 index 0000000..2cdbff6 --- /dev/null +++ b/Boss/Mod/RebalanceModeManager.hpp @@ -0,0 +1,40 @@ +#ifndef BOSS_MOD_REBALANCEMODEMANAGER_HPP +#define BOSS_MOD_REBALANCEMODEMANAGER_HPP + +#include + +namespace S { class Bus; } + +namespace Boss { namespace Mod { + +/** class Boss::Mod::RebalanceModeManager + * + * @brief Owns the currently-active rebalancing mode (the single + * source of truth) via the dynamic `clboss-rebalance-mode` option: + * the config file sets the startup default and + * `setconfig clboss-rebalance-mode ` switches it at runtime. + * Answers `Boss::Msg::RequestRebalanceMode` queries from rebalancing + * modules that self-gate on the mode. + * + * Mode is in-memory only: a restart reverts to the configured + * startup default, giving a known-good baseline on every boot. + */ +class RebalanceModeManager { +private: + class Impl; + std::unique_ptr pimpl; + +public: + RebalanceModeManager() =delete; + RebalanceModeManager(RebalanceModeManager const&) =delete; + + RebalanceModeManager(RebalanceModeManager&&); + ~RebalanceModeManager(); + + explicit + RebalanceModeManager(S::Bus& bus); +}; + +}} + +#endif /* !defined(BOSS_MOD_REBALANCEMODEMANAGER_HPP) */ diff --git a/Boss/Mod/all.cpp b/Boss/Mod/all.cpp index 5cb777c..16b96ba 100644 --- a/Boss/Mod/all.cpp +++ b/Boss/Mod/all.cpp @@ -60,6 +60,7 @@ #include"Boss/Mod/PeerFromScidMapper.hpp" #include"Boss/Mod/PeerMetrician.hpp" #include"Boss/Mod/PeerStatistician.hpp" +#include"Boss/Mod/RebalanceModeManager.hpp" #include"Boss/Mod/RebalanceUnmanager.hpp" #include"Boss/Mod/Reconnector.hpp" #include"Boss/Mod/RegularActiveProbe.hpp" @@ -207,6 +208,7 @@ std::shared_ptr all( std::ostream& cout #endif /* ENABLE_COMPLAINER_BY_LOW_SUCCESS_PER_DAY */ /* Channel balancing. */ + all->install(bus); all->install(bus); all->install(bus); all->install(bus); diff --git a/Boss/ModG/RebalanceModeProxy.hpp b/Boss/ModG/RebalanceModeProxy.hpp new file mode 100644 index 0000000..f2b8eba --- /dev/null +++ b/Boss/ModG/RebalanceModeProxy.hpp @@ -0,0 +1,53 @@ +#ifndef BOSS_MODG_REBALANCEMODEPROXY_HPP +#define BOSS_MODG_REBALANCEMODEPROXY_HPP + +#include"Boss/ModG/ReqResp.hpp" +#include"Boss/Msg/RequestRebalanceMode.hpp" +#include"Boss/Msg/ResponseRebalanceMode.hpp" +#include"Boss/RebalanceMode.hpp" + +namespace Boss { namespace ModG { + +/** class Boss::ModG::RebalanceModeProxy + * + * @brief a proxy for Boss::Mod::RebalanceModeManager, + * allowing a rebalancing module to query the currently-active + * mode and self-gate on it. + */ +class RebalanceModeProxy { +private: + ReqResp< Msg::RequestRebalanceMode + , Msg::ResponseRebalanceMode + > core; + +public: + RebalanceModeProxy() =delete; + RebalanceModeProxy(RebalanceModeProxy const&) =delete; + RebalanceModeProxy(RebalanceModeProxy&&) =delete; + + explicit + RebalanceModeProxy(S::Bus& bus) + : core(bus) + { } + + Ev::Io + get_mode() { + return core.execute(Msg::RequestRebalanceMode{ + nullptr + }).then([](Msg::ResponseRebalanceMode m) { + return Ev::lift(m.mode); + }); + } + + /* Convenience: is Track A (classic) the active mode? */ + Ev::Io + is_classic() { + return get_mode().then([](RebalanceMode m) { + return Ev::lift(m == RebalanceMode::classic); + }); + } +}; + +}} + +#endif /* !defined(BOSS_MODG_REBALANCEMODEPROXY_HPP) */ diff --git a/Boss/Msg/RequestRebalanceMode.hpp b/Boss/Msg/RequestRebalanceMode.hpp new file mode 100644 index 0000000..ca232d3 --- /dev/null +++ b/Boss/Msg/RequestRebalanceMode.hpp @@ -0,0 +1,17 @@ +#ifndef BOSS_MSG_REQUESTREBALANCEMODE_HPP +#define BOSS_MSG_REQUESTREBALANCEMODE_HPP + +namespace Boss { namespace Msg { + +/** struct Boss::Msg::RequestRebalanceMode + * + * @brief Requests the `Boss::Mod::RebalanceModeManager` to provide + * the currently-active rebalancing mode. + */ +struct RequestRebalanceMode { + void* requester; +}; + +}} + +#endif /* !defined(BOSS_MSG_REQUESTREBALANCEMODE_HPP) */ diff --git a/Boss/Msg/ResponseRebalanceMode.hpp b/Boss/Msg/ResponseRebalanceMode.hpp new file mode 100644 index 0000000..dbd1068 --- /dev/null +++ b/Boss/Msg/ResponseRebalanceMode.hpp @@ -0,0 +1,21 @@ +#ifndef BOSS_MSG_RESPONSEREBALANCEMODE_HPP +#define BOSS_MSG_RESPONSEREBALANCEMODE_HPP + +#include"Boss/RebalanceMode.hpp" + +namespace Boss { namespace Msg { + +/** struct Boss::Msg::ResponseRebalanceMode + * + * @brief Broadcasted by `Boss::Mod::RebalanceModeManager` in response + * to `Boss::Msg::RequestRebalanceMode`. + */ +struct ResponseRebalanceMode { + void* requester; + + RebalanceMode mode; +}; + +}} + +#endif /* !defined(BOSS_MSG_RESPONSEREBALANCEMODE_HPP) */ diff --git a/Boss/RebalanceMode.hpp b/Boss/RebalanceMode.hpp new file mode 100644 index 0000000..5db70ec --- /dev/null +++ b/Boss/RebalanceMode.hpp @@ -0,0 +1,52 @@ +#ifndef BOSS_REBALANCEMODE_HPP +#define BOSS_REBALANCEMODE_HPP + +#include + +namespace Boss { + +/** enum class Boss::RebalanceMode + * + * @brief which rebalancing track, if any, is currently active. + * + * @desc + * - `classic` : Track A, the original clboss rebalancer/funds-mover + * ported to getroutes/askrene (heuristic, JIT-capable). + * - `off` : no autonomous rebalancing at all; also the supported + * way to disable the rebalancer entirely. + */ +enum class RebalanceMode { + classic, + off +}; + +/* Default mode at startup if the operator does not configure one. */ +constexpr RebalanceMode default_rebalance_mode = RebalanceMode::classic; + +inline +char const* rebalance_mode_to_string(RebalanceMode m) { + switch (m) { + case RebalanceMode::classic: return "classic"; + case RebalanceMode::off: return "off"; + } + return "classic"; +} + +/* Parse a mode string; returns true and sets `out` on success, + * false on an unrecognized string (leaving `out` untouched). */ +inline +bool rebalance_mode_from_string(std::string const& s, RebalanceMode& out) { + if (s == "classic") { + out = RebalanceMode::classic; + return true; + } + if (s == "off") { + out = RebalanceMode::off; + return true; + } + return false; +} + +} + +#endif /* !defined(BOSS_REBALANCEMODE_HPP) */ diff --git a/Makefile.am b/Makefile.am index 8b5c05a..9a3d6f3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -252,6 +252,8 @@ libclboss_la_SOURCES = \ Boss/Mod/Rpc.hpp \ Boss/Mod/RpcWrapper.cpp \ Boss/Mod/RpcWrapper.hpp \ + Boss/Mod/RebalanceModeManager.cpp \ + Boss/Mod/RebalanceModeManager.hpp \ Boss/Mod/RebalanceUnmanager.cpp \ Boss/Mod/RebalanceUnmanager.hpp \ Boss/Mod/SelfUptimeMonitor.cpp \ @@ -281,6 +283,7 @@ libclboss_la_SOURCES = \ Boss/ModG/ReqResp.hpp \ Boss/ModG/RpcProxy.cpp \ Boss/ModG/RpcProxy.hpp \ + Boss/ModG/RebalanceModeProxy.hpp \ Boss/ModG/RebalanceUnmanagerProxy.hpp \ Boss/ModG/Swapper.cpp \ Boss/ModG/Swapper.hpp \ @@ -354,6 +357,7 @@ libclboss_la_SOURCES = \ Boss/Msg/RequestPeerFromScid.hpp \ Boss/Msg/RequestPeerMetrics.hpp \ Boss/Msg/RequestPeerStatistics.hpp \ + Boss/Msg/RequestRebalanceMode.hpp \ Boss/Msg/RequestRebalanceUnmanaged.hpp \ Boss/Msg/RequestRpcCommand.hpp \ Boss/Msg/RequestSelfUptime.hpp \ @@ -367,6 +371,7 @@ libclboss_la_SOURCES = \ Boss/Msg/ResponsePeerFromScid.hpp \ Boss/Msg/ResponsePeerMetrics.hpp \ Boss/Msg/ResponsePeerStatistics.hpp \ + Boss/Msg/ResponseRebalanceMode.hpp \ Boss/Msg/ResponseRebalanceUnmanaged.hpp \ Boss/Msg/ResponseRpcCommand.hpp \ Boss/Msg/ResponseSelfUptime.hpp \ @@ -392,6 +397,7 @@ libclboss_la_SOURCES = \ Boss/Msg/TimerRandomDaily.hpp \ Boss/Msg/TimerRandomHourly.hpp \ Boss/Msg/TimerTwiceDaily.hpp \ + Boss/RebalanceMode.hpp \ Boss/Shutdown.hpp \ Boss/Signer.cpp \ Boss/Signer.hpp \ diff --git a/tests/boss/test_earningsrebalancer.cpp b/tests/boss/test_earningsrebalancer.cpp index 615c992..667f8a7 100644 --- a/tests/boss/test_earningsrebalancer.cpp +++ b/tests/boss/test_earningsrebalancer.cpp @@ -1,6 +1,7 @@ #undef NDEBUG #include"Boss/Mod/JsonOutputter.hpp" #include"Boss/Mod/EarningsRebalancer.hpp" +#include"Boss/Mod/RebalanceModeManager.hpp" #include"Boss/Mod/RebalanceUnmanager.hpp" #include"Boss/Msg/CommandRequest.hpp" #include"Boss/Mod/ConstructedListpeers.hpp" @@ -114,6 +115,10 @@ auto const Z = Ln::NodeId("02000000000000000000000000000000000000000000000000000 int main() { auto bus = S::Bus(); + /* Mode manager answers the EarningsRebalancer's self-gate query; + * default mode is classic, so the rebalancer runs as before. */ + Boss::Mod::RebalanceModeManager mode_manager(bus); + /* Utility outputter. */ Boss::Mod::JsonOutputter cout(std::cout, bus); /* Unmanager. */ diff --git a/tests/boss/test_initialrebalancer.cpp b/tests/boss/test_initialrebalancer.cpp index 4746142..88aed63 100644 --- a/tests/boss/test_initialrebalancer.cpp +++ b/tests/boss/test_initialrebalancer.cpp @@ -1,5 +1,6 @@ #undef NDEBUG #include"Boss/Mod/InitialRebalancer.hpp" +#include"Boss/Mod/RebalanceModeManager.hpp" #include"Boss/Mod/RebalanceUnmanager.hpp" #include"Boss/Msg/JsonCout.hpp" #include"Boss/Msg/ListpeersResult.hpp" @@ -126,6 +127,10 @@ int main() { auto bus = S::Bus(); + /* Mode manager answers the InitialRebalancer's self-gate query; + * default mode is classic, so the rebalancer runs as before. */ + Boss::Mod::RebalanceModeManager mode_manager(bus); + /* Unmanager mock. */ Boss::Mod::RebalanceUnmanager unmanager(bus, { "020000000000000000000000000000000000000000000000000000000000000003", diff --git a/tests/boss/test_jitrebalancer.cpp b/tests/boss/test_jitrebalancer.cpp index afa0e8d..4ebd77d 100644 --- a/tests/boss/test_jitrebalancer.cpp +++ b/tests/boss/test_jitrebalancer.cpp @@ -1,6 +1,7 @@ #undef NDEBUG #include"Boss/Mod/JitRebalancer.hpp" #include"Boss/Mod/PeerFromScidMapper.hpp" +#include"Boss/Mod/RebalanceModeManager.hpp" #include"Boss/Mod/RebalanceUnmanager.hpp" #include"Boss/Msg/JsonCout.hpp" #include"Boss/Msg/ListpeersResult.hpp" @@ -284,6 +285,10 @@ int main() { auto bus = S::Bus(); + /* Mode manager answers the JitRebalancer's self-gate query; + * default mode is classic, so the rebalancer runs as before. */ + Boss::Mod::RebalanceModeManager mode_manager(bus); + Cout cout(bus); /* Needed utility module. */ auto mapper = Boss::Mod::PeerFromScidMapper(bus);