From 5f4a1917a6fe9f757feeb1d73ab08ec146d7662b Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Fri, 1 Nov 2013 16:47:19 -0700 Subject: [PATCH] Change how cluster load is computed from average-ish to median-ish. --- src/ripple_app/peers/UniqueNodeList.cpp | 29 ++++++++++--------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/ripple_app/peers/UniqueNodeList.cpp b/src/ripple_app/peers/UniqueNodeList.cpp index 9f312a3f7..466d8af8d 100644 --- a/src/ripple_app/peers/UniqueNodeList.cpp +++ b/src/ripple_app/peers/UniqueNodeList.cpp @@ -383,32 +383,25 @@ public: uint32 getClusterFee () { - int thresh = getApp().getOPs().getNetworkTimeNC() - 120; - uint32 a = 0, b = 0; + int thresh = getApp().getOPs().getNetworkTimeNC() - 90; - ScopedUNLLockType sl (mUNLLock, __FILE__, __LINE__); + std::vector fees; { - for (std::map::iterator it = m_clusterNodes.begin(), - end = m_clusterNodes.end(); it != end; ++it) + ScopedUNLLockType sl (mUNLLock, __FILE__, __LINE__); { - if (it->second.getReportTime() >= thresh) + for (std::map::iterator it = m_clusterNodes.begin(), + end = m_clusterNodes.end(); it != end; ++it) { - uint32 fee = it->second.getLoadFee(); - if (fee > b) - { - if (fee > a) - { - b = a; - a = fee; - } - else - b = fee; - } + if (it->second.getReportTime() >= thresh) + fees.push_back(it->second.getLoadFee()); } } } - return (b == 0) ? a : ((a + b + 1) / 2); + if (fees.empty()) + return 0; + std::sort (fees.begin(), fees.end()); + return fees[fees.size() / 2]; } //--------------------------------------------------------------------------