mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Use trusted validators median fee
Conflicts: src/ripple/app/misc/Validations.cpp
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
namespace ripple {
|
||||
@@ -26,10 +27,10 @@ namespace ripple {
|
||||
class ValidationsImp : public Validations
|
||||
{
|
||||
private:
|
||||
typedef RippleMutex LockType;
|
||||
using LockType = std::mutex;
|
||||
typedef std::lock_guard <LockType> ScopedLockType;
|
||||
typedef beast::GenericScopedUnlock <LockType> ScopedUnlockType;
|
||||
LockType mLock;
|
||||
std::mutex mutable mLock;
|
||||
|
||||
TaggedCache<uint256, ValidationSet> mValidations;
|
||||
ValidationSet mCurrentValidations;
|
||||
@@ -233,34 +234,27 @@ private:
|
||||
return trusted;
|
||||
}
|
||||
|
||||
int getFeeAverage (uint256 const& ledger, std::uint64_t ref, std::uint64_t& fee)
|
||||
std::vector <std::uint64_t>
|
||||
fees (uint256 const& ledger, std::uint64_t base) override
|
||||
{
|
||||
int trusted = 0;
|
||||
fee = 0;
|
||||
|
||||
ScopedLockType sl (mLock);
|
||||
auto set = findSet (ledger);
|
||||
|
||||
std::vector <std::uint64_t> result;
|
||||
std::lock_guard <std::mutex> lock (mLock);
|
||||
auto const set = findSet (ledger);
|
||||
if (set)
|
||||
{
|
||||
for (auto& it: *set)
|
||||
for (auto const& v : *set)
|
||||
{
|
||||
if (it.second->isTrusted ())
|
||||
if (v.second->isTrusted())
|
||||
{
|
||||
++trusted;
|
||||
if (it.second->isFieldPresent(sfLoadFee))
|
||||
fee += it.second->getFieldU32(sfLoadFee);
|
||||
if (v.second->isFieldPresent(sfLoadFee))
|
||||
result.push_back(v.second->getFieldU32(sfLoadFee));
|
||||
else
|
||||
fee += ref;
|
||||
}
|
||||
result.push_back(base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (trusted == 0)
|
||||
fee = ref;
|
||||
else
|
||||
fee /= trusted;
|
||||
return trusted;
|
||||
return result;
|
||||
}
|
||||
|
||||
int getNodesAfter (uint256 const& ledger)
|
||||
|
||||
Reference in New Issue
Block a user