Use trusted validators median fee

Conflicts:
	src/ripple/app/misc/Validations.cpp
This commit is contained in:
Vinnie Falco
2014-09-30 18:00:40 -07:00
parent 40a955e192
commit 01e52e6f9f
4 changed files with 40 additions and 32 deletions

View File

@@ -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)