fees: add ForecasterMan class

- Its a module for managing and utilising multiple
  fee rate forecasters to provide fee rate forecast.

- The ForecasterManager class allows for the registration of
  multiple fee rate forecasters.

Co-authored-by: willcl-ark <will@256k1.dev>
This commit is contained in:
ismaelsadeeq 2025-01-13 17:02:27 -05:00
parent 0745dd789b
commit df16b70a71
3 changed files with 52 additions and 0 deletions

View File

@ -259,6 +259,7 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
policy/ephemeral_policy.cpp
policy/fees.cpp
policy/fees_args.cpp
policy/fees/forecaster_man.cpp
policy/packages.cpp
policy/rbf.cpp
policy/settings.cpp

View File

@ -0,0 +1,14 @@
// Copyright (c) 2025 The Bitcoin Core developers
// Distributed under the MIT software license. See the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <policy/fees/forecaster.h>
#include <policy/fees/forecaster_man.h>
#include <policy/fees/forecaster_util.h>
#include <utility>
void FeeRateForecasterManager::RegisterForecaster(std::shared_ptr<Forecaster> forecaster)
{
forecasters.emplace(forecaster->GetForecastType(), forecaster);
}

View File

@ -0,0 +1,37 @@
// Copyright (c) 2025 The Bitcoin Core developers
// Distributed under the MIT software license. See the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_POLICY_FEES_FORECASTER_MAN_H
#define BITCOIN_POLICY_FEES_FORECASTER_MAN_H
#include <memory>
#include <unordered_map>
class Forecaster;
class ForecastResult;
enum class ForecastType;
/** \class FeeRateForecasterManager
* Module for managing and utilising multiple fee rate forecasters to provide a forecast for a target.
*
* The FeeRateForecasterManager class allows for the registration of multiple fee rate
* forecasters.
*/
class FeeRateForecasterManager
{
private:
//! Map of all registered forecasters to their shared pointers.
std::unordered_map<ForecastType, std::shared_ptr<Forecaster>> forecasters;
public:
/**
* Register a forecaster to provide fee rate estimates.
*
* @param[in] forecaster shared pointer to a Forecaster instance.
*/
void RegisterForecaster(std::shared_ptr<Forecaster> forecaster);
};
#endif // BITCOIN_POLICY_FEES_FORECASTER_MAN_H