Skip to content

Commit

Permalink
[FOLD] Make the unhealthy factor a constexpr param, set to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ximinez committed Aug 9, 2024
1 parent f5a6ac4 commit ac212e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/test/app/TxQ_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,9 @@ class TxQPosNegFlows_test : public beast::unit_test::suite
env.fund(XRP(1000), noripple(alice, bob));
env.close(env.now() + 5s, 10000ms);
env.fund(XRP(1000), noripple(charlie, daria));
env.close(env.now() + 5s, 20001ms);
env.close(env.now() + 5s, 30001ms);
env.fund(XRP(1000), noripple(edgar, felicia));
env.close(env.now() + 5s, 30002ms);
env.close(env.now() + 5s, 60002ms);

checkMetrics(__LINE__, env, 0, std::nullopt, 0, 2, 256);
env(noop(bob));
Expand Down Expand Up @@ -923,7 +923,7 @@ class TxQPosNegFlows_test : public beast::unit_test::suite
env.fund(XRP(1000), noripple(alice, bob));
env.close(env.now() + 5s, 10000ms);
env.fund(XRP(1000), noripple(carol));
env.close(env.now() + 5s, 20001ms);
env.close(env.now() + 5s, 30001ms);

// Fill the ledger
env(noop(alice));
Expand Down Expand Up @@ -4062,19 +4062,19 @@ class TxQPosNegFlows_test : public beast::unit_test::suite
checkMetrics(__LINE__, env, txCount, 56, 15, 14, 256);

// Close the ledger with a delay.
env.close(env.now() + 5s, 20001ms);
env.close(env.now() + 5s, 30001ms);
txCount -= 8;
checkMetrics(__LINE__, env, txCount, 56, 8, 7, 256);

// Close the ledger with a delay.
env.close(env.now() + 5s, 30002ms);
env.close(env.now() + 5s, 60002ms);
txCount -= 4;
checkMetrics(__LINE__, env, txCount, 56, 4, 3, 256);

// From 28 expected back down to 3 in 3 "slow" ledgers.

// Confirm the minimum sticks
env.close(env.now() + 5s, 60003ms);
env.close(env.now() + 5s, 150s);
txCount -= 4;
checkMetrics(__LINE__, env, txCount, 56, 4, 3, 256);

Expand Down
1 change: 1 addition & 0 deletions src/xrpld/app/misc/TxQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ class TxQ
/// Any round time less than 5 seconds is considered good, regardless of
/// recent history.
static constexpr std::chrono::seconds timeLeapCutoff{5};
static constexpr std::uint32_t timeLeapFactor{3};

public:
/// Constructor
Expand Down
3 changes: 2 additions & 1 deletion src/xrpld/app/misc/detail/TxQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ TxQ::FeeMetrics::update(
recentRoundTimes_.begin(), recentRoundTimes_.end(), 0ms) /
recentRoundTimes_.size()};
bool const timeLeap = !roundTime ||
(roundTime > timeLeapCutoff && roundTime > averageTime * 2);
(roundTime > timeLeapCutoff &&
roundTime > averageTime * timeLeapFactor);
if (roundTime)
recentRoundTimes_.push_back(*roundTime);

Expand Down

0 comments on commit ac212e8

Please sign in to comment.