clboss/Boss/Mod/ChannelCreator/Manager.hpp
Ken Sedgwick 0aecb8bcc3
Some checks failed
Code Base Sanity Check / tests (push) Has been cancelled
Code Base Sanity Check / coverage (push) Has been cancelled
Code Base Sanity Check / build-clang (push) Has been cancelled
ChannelCreator: fund candidates in track-record tier order
After the size rearranger and the IP-binning reprioritizer, partition
the proposal list by track-record verdict: keepers first, then
candidates with no record, then underperformers.  Within a tier the
earlier stages' order is preserved.  Because the Planner consumes
proposals in order until funds run out, placing a tier last implements
'only used if no better candidate can absorb the funds' without an
outright veto.  The partition runs last so the earlier perturbation
stages cannot promote a candidate across a tier boundary.

Logs one Info line per creation request with the per-tier membership
and each judged candidate's TRAL and observed days.
2026-08-04 11:02:15 -07:00

91 lines
2.6 KiB
C++

#ifndef BOSS_MOD_CHANNELCREATOR_MANAGER_HPP
#define BOSS_MOD_CHANNELCREATOR_MANAGER_HPP
#include"Boss/Mod/ChannelCreator/Reprioritizer.hpp"
#include"Boss/ModG/ReqResp.hpp"
#include"Boss/Msg/RequestDowser.hpp"
#include"Boss/Msg/RequestPeerTrackRecord.hpp"
#include"Boss/Msg/ResponseDowser.hpp"
#include"Boss/Msg/ResponsePeerTrackRecord.hpp"
#include"Ln/NodeId.hpp"
#include<memory>
#include<utility>
#include<vector>
namespace Boss { namespace Mod { namespace ChannelCandidateInvestigator {
class Main;
}}}
namespace Boss { namespace Mod { namespace ChannelCreator {
class Carpenter;
}}}
namespace Boss { namespace Mod { class Rpc; }}
namespace Ev { template<typename a> class Io; }
namespace Ln { class Amount; }
namespace Ln { class NodeId; }
namespace Net { class IPAddrOrOnion; }
namespace S { class Bus; }
namespace Boss { namespace Mod { namespace ChannelCreator {
/** class Boss::Mod::ChannelCreator::Manager
*
* @brief submodule that handles incoming
* messages to the channel creator, then
* drives the rest of the processing.
*/
class Manager {
private:
S::Bus& bus;
Boss::Mod::Rpc* rpc;
Boss::Mod::ChannelCandidateInvestigator::Main& investigator;
Boss::Mod::ChannelCreator::Carpenter& carpenter;
Ln::NodeId self;
ModG::ReqResp<Msg::RequestDowser, Msg::ResponseDowser> dowser;
ModG::ReqResp< Msg::RequestPeerTrackRecord
, Msg::ResponsePeerTrackRecord
> track_record;
std::unique_ptr<Boss::Mod::ChannelCreator::Reprioritizer> reprioritizer;
Ln::Amount min_amount;
Ln::Amount max_amount;
Ln::Amount min_remaining;
void start();
Ev::Io<void> on_request_channel_creation(Ln::Amount);
/* Needed by reprioritizer. */
Ev::Io<std::unique_ptr<Net::IPAddrOrOnion>> get_node_addr(Ln::NodeId);
Ev::Io<std::vector<Ln::NodeId>> get_peers();
/* Perform reprioritization and log it. */
Ev::Io<std::vector<std::pair<Ln::NodeId, Ln::NodeId>>>
reprioritize(std::vector<std::pair<Ln::NodeId, Ln::NodeId>>);
/* Partition proposals by earnings track record and log it. */
Ev::Io<std::vector<std::pair<Ln::NodeId, Ln::NodeId>>>
prioritize_by_track_record(std::vector<std::pair<Ln::NodeId, Ln::NodeId>>);
public:
Manager() =delete;
Manager(Manager const&) =delete;
Manager(Manager&&) =delete;
explicit
Manager( S::Bus& bus_
, Boss::Mod::ChannelCandidateInvestigator::Main& investigator_
, Boss::Mod::ChannelCreator::Carpenter& carpenter_
) : bus(bus_)
, rpc(nullptr)
, investigator(investigator_)
, carpenter(carpenter_)
, self()
, dowser(bus)
, track_record(bus)
{
start();
}
};
}}}
#endif /* !defined(BOSS_MOD_CHANNELCREATOR_MANAGER_HPP) */