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]; } //--------------------------------------------------------------------------