20#include <xrpld/app/ledger/Ledger.h>
21#include <xrpld/app/misc/FeeVote.h>
22#include <xrpl/beast/utility/Journal.h>
23#include <xrpl/protocol/STValidation.h>
24#include <xrpl/protocol/st.h>
73 for (
auto const& [key, val] :
voteMap_)
84 return {ourVote, ourVote !=
current_};
114 : target_(setup), journal_(journal)
120 Fees const& lastFees,
127 if (rules.
enabled(featureXRPFees))
129 auto vote = [&v,
this](
133 auto const& sfield) {
137 <<
"Voting for " << name <<
" of " << target;
152 sfReserveIncrementDrops);
162 auto vote = [&v,
this](
165 auto const& convertCallback,
167 auto const& sfield) {
171 <<
"Voting for " << name <<
" of " << target;
173 if (
auto const f = convertCallback(target))
202 lastClosedLedger &&
isFlagLedger(lastClosedLedger->seq()),
203 "ripple::FeeVoteImpl::doVoting : has a flag ledger");
214 auto const& rules = lastClosedLedger->rules();
215 if (rules.enabled(featureXRPFees))
220 if (
auto const field = ~val->at(~xrpField);
221 field && field->native())
223 auto const vote = field->xrp();
235 for (
auto const& val :
set)
237 if (!val->isTrusted())
239 doVote(val, baseFeeVote, sfBaseFeeDrops);
240 doVote(val, baseReserveVote, sfReserveBaseDrops);
241 doVote(val, incReserveVote, sfReserveIncrementDrops);
248 auto const& valueField) {
249 if (
auto const field = val->at(~valueField))
252 auto const vote = *field;
256 XRPAmount{unsafe_cast<XRPAmount::value_type>(vote)});
269 for (
auto const& val :
set)
271 if (!val->isTrusted())
273 doVote(val, baseFeeVote, sfBaseFee);
274 doVote(val, baseReserveVote, sfReserveBase);
275 doVote(val, incReserveVote, sfReserveIncrement);
283 auto const baseFee = baseFeeVote.
getVotes();
284 auto const baseReserve = baseReserveVote.
getVotes();
285 auto const incReserve = incReserveVote.
getVotes();
287 auto const seq = lastClosedLedger->info().seq + 1;
290 if (baseFee.second || baseReserve.second || incReserve.second)
293 <<
"We are voting for a fee change: " << baseFee.first <<
"/"
294 << baseReserve.first <<
"/" << incReserve.first;
296 STTx feeTx(ttFEE, [=, &rules](
auto& obj) {
298 obj[sfLedgerSequence] = seq;
299 if (rules.enabled(featureXRPFees))
301 obj[sfBaseFeeDrops] = baseFee.first;
302 obj[sfReserveBaseDrops] = baseReserve.first;
303 obj[sfReserveIncrementDrops] = incReserve.first;
311 obj[sfReserveBase] = baseReserve.first.dropsAs<
std::uint32_t>(
313 obj[sfReserveIncrement] =
320 uint256 txID = feeTx.getTransactionID();
327 if (!initialPosition->addGiveItem(
331 JLOG(
journal_.
warn()) <<
"Ledger already had fee change";
341 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.