20#include <xrpld/app/ledger/Ledger.h>
21#include <xrpld/app/main/Application.h>
22#include <xrpld/app/misc/FeeVote.h>
23#include <xrpl/basics/BasicConfig.h>
24#include <xrpl/beast/utility/Journal.h>
25#include <xrpl/protocol/STValidation.h>
26#include <xrpl/protocol/st.h>
75 for (
auto const& [key, val] :
voteMap_)
86 return {ourVote, ourVote !=
current_};
116 : target_(setup), journal_(journal)
122 Fees const& lastFees,
129 if (rules.
enabled(featureXRPFees))
131 auto vote = [&v,
this](
135 auto const& sfield) {
139 <<
"Voting for " << name <<
" of " << target;
154 sfReserveIncrementDrops);
164 auto vote = [&v,
this](
167 auto const& convertCallback,
169 auto const& sfield) {
173 <<
"Voting for " << name <<
" of " << target;
175 if (
auto const f = convertCallback(target))
204 lastClosedLedger &&
isFlagLedger(lastClosedLedger->seq()),
205 "ripple::FeeVoteImpl::doVoting : has a flag ledger");
216 auto const& rules = lastClosedLedger->rules();
217 if (rules.enabled(featureXRPFees))
222 if (
auto const field = ~val->at(~xrpField);
223 field && field->native())
225 auto const vote = field->xrp();
237 for (
auto const& val :
set)
239 if (!val->isTrusted())
241 doVote(val, baseFeeVote, sfBaseFeeDrops);
242 doVote(val, baseReserveVote, sfReserveBaseDrops);
243 doVote(val, incReserveVote, sfReserveIncrementDrops);
250 auto const& valueField) {
251 if (
auto const field = val->at(~valueField))
254 auto const vote = *field;
258 XRPAmount{unsafe_cast<XRPAmount::value_type>(vote)});
271 for (
auto const& val :
set)
273 if (!val->isTrusted())
275 doVote(val, baseFeeVote, sfBaseFee);
276 doVote(val, baseReserveVote, sfReserveBase);
277 doVote(val, incReserveVote, sfReserveIncrement);
285 auto const baseFee = baseFeeVote.
getVotes();
286 auto const baseReserve = baseReserveVote.
getVotes();
287 auto const incReserve = incReserveVote.
getVotes();
289 auto const seq = lastClosedLedger->info().seq + 1;
292 if (baseFee.second || baseReserve.second || incReserve.second)
295 <<
"We are voting for a fee change: " << baseFee.first <<
"/"
296 << baseReserve.first <<
"/" << incReserve.first;
298 STTx feeTx(ttFEE, [=, &rules](
auto& obj) {
300 obj[sfLedgerSequence] = seq;
301 if (rules.enabled(featureXRPFees))
303 obj[sfBaseFeeDrops] = baseFee.first;
304 obj[sfReserveBaseDrops] = baseReserve.first;
305 obj[sfReserveIncrementDrops] = incReserve.first;
313 obj[sfReserveBase] = baseReserve.first.dropsAs<
std::uint32_t>(
315 obj[sfReserveIncrement] =
322 uint256 txID = feeTx.getTransactionID();
329 if (!initialPosition->addGiveItem(
333 JLOG(
journal_.
warn()) <<
"Ledger already had fee change";
343 return std::make_unique<FeeVoteImpl>(setup, journal);
A generic endpoint for log messages.
static constexpr std::uint32_t FEE_UNITS_DEPRECATED
void doValidation(Fees const &lastFees, Rules const &rules, STValidation &val) override
Add local fee preference to validation.
void doVoting(std::shared_ptr< ReadView const > const &lastClosedLedger, std::vector< std::shared_ptr< STValidation > > const &parentValidations, std::shared_ptr< SHAMap > const &initialPosition) override
Cast our local vote on the fee.
FeeVoteImpl(FeeSetup const &setup, beast::Journal journal)
beast::Journal const journal_
Manager to process fee votes.
Rules controlling protocol behavior.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
Slice slice() const noexcept
VotableValue(value_type current, value_type target)
std::pair< value_type, bool > getVotes() const
std::map< value_type, int > voteMap_
value_type const current_
void addVote(value_type vote)
value_type current() const
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
bool isLegalAmountSigned(XRPAmount const &amount)
Returns true if the absolute value of the amount does not exceed the initial XRP in existence.
std::unique_ptr< FeeVote > make_FeeVote(FeeSetup const &setup, beast::Journal journal)
Create an instance of the FeeVote logic.
@ current
This was a new validation and was added.
bool isFlagLedger(LedgerIndex seq)
Returns true if the given ledgerIndex is a flag ledgerIndex.
boost::intrusive_ptr< SHAMapItem > make_shamapitem(uint256 const &tag, Slice data)
Fee schedule for startup / standalone, and to vote for.
XRPAmount reference_fee
The cost of a reference transaction in drops.
XRPAmount owner_reserve
The per-owned item reserve requirement in drops.
XRPAmount account_reserve
The account reserve requirement in drops.
Reflects the fee settings for a particular ledger.
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
A field with a type known at compile time.