void Transactor::calculateFee () { mFeeDue = STAmount (mEngine->getLedger ()->scaleFeeLoad (calculateBaseFee (), isSetBit (mParams, tapADMIN))); }
void Transactor::calculateFee() { mFeeDue = STAmount(mEngine->getLedger()->scaleFeeLoad(calculateBaseFee())); }
std::size_t FeeMetrics::updateFeeMetrics(Application& app, ReadView const& view, bool timeLeap) { std::vector<uint64_t> feeLevels; std::size_t txnsExpected; std::size_t mimimumTx; std::uint32_t escalationMultiplier; { std::lock_guard <std::mutex> sl(lock_); feeLevels.reserve(txnsExpected_); txnsExpected = txnsExpected_; mimimumTx = minimumTxnCount_; escalationMultiplier = escalationMultiplier_; } for (auto const& tx : view.txs) { auto const baseFee = calculateBaseFee(app, view, *tx.first, j_); feeLevels.push_back(getFeeLevelPaid(*tx.first, baseLevel, baseFee)); } std::sort(feeLevels.begin(), feeLevels.end()); auto const size = feeLevels.size(); JLOG(j_.debug) << "Ledger " << view.info().seq << " has " << size << " transactions. " << "Ledgers are processing " << (timeLeap ? "slowly" : "as expected") << ". Expected transactions is currently " << txnsExpected << " and multiplier is " << escalationMultiplier; if (timeLeap) { // Ledgers are taking to long to process, // so clamp down on limits. txnsExpected = boost::algorithm::clamp(feeLevels.size(), mimimumTx, targetTxnCount_ - 1); } else if (feeLevels.size() > txnsExpected || feeLevels.size() > targetTxnCount_) { // Ledgers are processing in a timely manner, // so keep the limit high, but don't let it // grow without bound. txnsExpected = feeLevels.size(); } if (feeLevels.empty()) { escalationMultiplier = minimumMultiplier_; } else { // In the case of an odd number of elements, this // evaluates to the middle element; for an even // number of elements, it will add the two elements // on either side of the "middle" and average them. escalationMultiplier = (feeLevels[size / 2] + feeLevels[(size - 1) / 2] + 1) / 2; escalationMultiplier = std::max(escalationMultiplier, minimumMultiplier_); } JLOG(j_.debug) << "Expected transactions updated to " << txnsExpected << " and multiplier updated to " << escalationMultiplier; std::lock_guard <std::mutex> sl(lock_); txnsExpected_ = txnsExpected; escalationMultiplier_ = escalationMultiplier; return size; }