Decouple HashRouter from Config

This commit is contained in:
JCW
2026-01-09 12:47:45 +00:00
parent 8bba90df0f
commit 4a49f4884f
13 changed files with 65 additions and 46 deletions

View File

@@ -1,4 +1,5 @@
#include <xrpld/app/misc/HashRouter.h>
#include <xrpld/app/misc/setup_HashRouter.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/chrono.h>

View File

@@ -23,6 +23,7 @@
#include <xrpld/app/misc/ValidatorKeys.h>
#include <xrpld/app/misc/ValidatorSite.h>
#include <xrpld/app/misc/make_NetworkOPs.h>
#include <xrpld/app/misc/setup_HashRouter.h>
#include <xrpld/app/paths/PathRequests.h>
#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
#include <xrpld/app/tx/apply.h>

View File

@@ -114,39 +114,4 @@ HashRouter::shouldRelay(uint256 const& key)
return s.releasePeerSet();
}
HashRouter::Setup
setup_HashRouter(Config const& config)
{
using namespace std::chrono;
HashRouter::Setup setup;
auto const& section = config.section("hashrouter");
std::int32_t tmp;
if (set(tmp, "hold_time", section))
{
if (tmp < 12)
Throw<std::runtime_error>(
"HashRouter hold time must be at least 12 seconds (the "
"approximate validation time for three ledgers).");
setup.holdTime = seconds(tmp);
}
if (set(tmp, "relay_time", section))
{
if (tmp < 8)
Throw<std::runtime_error>(
"HashRouter relay time must be at least 8 seconds (the "
"approximate validation time for two ledgers).");
setup.relayTime = seconds(tmp);
}
if (setup.relayTime > setup.holdTime)
{
Throw<std::runtime_error>(
"HashRouter relay time must be less than or equal to hold time");
}
return setup;
}
} // namespace xrpl

View File

@@ -267,9 +267,6 @@ private:
suppressionMap_;
};
HashRouter::Setup
setup_HashRouter(Config const&);
} // namespace xrpl
#endif

View File

@@ -0,0 +1,43 @@
#include <xrpld/app/misc/setup_HashRouter.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/BasicConfig.h>
namespace xrpl {
HashRouter::Setup
setup_HashRouter(Config const& config)
{
using namespace std::chrono;
HashRouter::Setup setup;
auto const& section = config.section("hashrouter");
std::int32_t tmp;
if (set(tmp, "hold_time", section))
{
if (tmp < 12)
Throw<std::runtime_error>(
"HashRouter hold time must be at least 12 seconds (the "
"approximate validation time for three ledgers).");
setup.holdTime = seconds(tmp);
}
if (set(tmp, "relay_time", section))
{
if (tmp < 8)
Throw<std::runtime_error>(
"HashRouter relay time must be at least 8 seconds (the "
"approximate validation time for two ledgers).");
setup.relayTime = seconds(tmp);
}
if (setup.relayTime > setup.holdTime)
{
Throw<std::runtime_error>(
"HashRouter relay time must be less than or equal to hold time");
}
return setup;
}
} // namespace xrpl

View File

@@ -0,0 +1,17 @@
#ifndef XRPLD_APP_MISC_SETUP_HASHROUTER_H_INCLUDED
#define XRPLD_APP_MISC_SETUP_HASHROUTER_H_INCLUDED
#include <xrpld/app/misc/HashRouter.h>
namespace xrpl {
// Forward declaration
class Config;
/** Create HashRouter setup from configuration */
HashRouter::Setup
setup_HashRouter(Config const& config);
} // namespace xrpl
#endif

View File

@@ -2,7 +2,6 @@
#define XRPL_TX_APPLY_H_INCLUDED
#include <xrpld/app/tx/applySteps.h>
#include <xrpld/core/Config.h>
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/ledger/View.h>

View File

@@ -2,7 +2,6 @@
#define XRPL_TX_BATCH_H_INCLUDED
#include <xrpld/app/tx/detail/Transactor.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/Log.h>
#include <xrpl/protocol/Indexes.h>

View File

@@ -1,8 +1,8 @@
#include <xrpld/app/ledger/Ledger.h>
#include <xrpld/app/tx/detail/CancelCheck.h>
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/View.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/TER.h>

View File

@@ -1,9 +1,9 @@
#include <xrpld/app/ledger/Ledger.h>
#include <xrpld/app/paths/Flow.h>
#include <xrpld/app/tx/detail/CashCheck.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/scope.h>
#include <xrpl/ledger/View.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/TER.h>

View File

@@ -1,7 +1,6 @@
#ifndef XRPL_TX_CREATETICKET_H_INCLUDED
#define XRPL_TX_CREATETICKET_H_INCLUDED
#include <xrpld/app/ledger/Ledger.h>
#include <xrpld/app/tx/detail/Transactor.h>
namespace xrpl {

View File

@@ -1,6 +1,5 @@
#include <xrpld/app/misc/DelegateUtils.h>
#include <xrpld/app/tx/detail/SetAccount.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>

View File

@@ -1,11 +1,9 @@
#include <xrpld/app/main/Application.h>
#include <xrpld/app/misc/DelegateUtils.h>
#include <xrpld/app/misc/LoadFeeTrack.h>
#include <xrpld/app/tx/apply.h>
#include <xrpld/app/tx/detail/NFTokenUtils.h>
#include <xrpld/app/tx/detail/SignerEntries.h>
#include <xrpld/app/tx/detail/Transactor.h>
#include <xrpld/core/Config.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/contract.h>
@@ -16,6 +14,7 @@
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/Protocol.h>
#include <xrpl/protocol/SystemParameters.h>
#include <xrpl/protocol/TxFlags.h>
#include <xrpl/protocol/UintTypes.h>