20#include <xrpld/app/ledger/Ledger.h>
21#include <xrpld/app/misc/FeeVote.h>
23#include <xrpl/beast/utility/Journal.h>
24#include <xrpl/protocol/STValidation.h>
25#include <xrpl/protocol/st.h>
74 for (
auto const& [key, val] :
voteMap_)
85 return {ourVote, ourVote !=
current_};
115 : target_(setup), journal_(journal)
121 Fees const& lastFees,
128 if (rules.
enabled(featureXRPFees))
130 auto vote = [&v,
this](
134 auto const& sfield) {
138 <<
"Voting for " << name <<
" of " << target;
153 sfReserveIncrementDrops);
163 auto vote = [&v,
this](
166 auto const& convertCallback,
168 auto const& sfield) {
172 <<
"Voting for " << name <<
" of " << target;
174 if (
auto const f = convertCallback(target))
203 lastClosedLedger &&
isFlagLedger(lastClosedLedger->seq()),
204 "ripple::FeeVoteImpl::doVoting : has a flag ledger");
215 auto const& rules = lastClosedLedger->rules();
216 if (rules.enabled(featureXRPFees))
221 if (
auto const field = ~val->at(~xrpField);
222 field && field->native())
224 auto const vote = field->xrp();
236 for (
auto const& val :
set)
238 if (!val->isTrusted())
240 doVote(val, baseFeeVote, sfBaseFeeDrops);
241 doVote(val, baseReserveVote, sfReserveBaseDrops);
242 doVote(val, incReserveVote, sfReserveIncrementDrops);
249 auto const& valueField) {
250 if (
auto const field = val->at(~valueField))
253 auto const vote = *field;
257 XRPAmount{unsafe_cast<XRPAmount::value_type>(vote)});
270 for (
auto const& val :
set)
272 if (!val->isTrusted())
274 doVote(val, baseFeeVote, sfBaseFee);
275 doVote(val, baseReserveVote, sfReserveBase);
276 doVote(val, incReserveVote, sfReserveIncrement);
284 auto const baseFee = baseFeeVote.
getVotes();
285 auto const baseReserve = baseReserveVote.
getVotes();
286 auto const incReserve = incReserveVote.
getVotes();
288 auto const seq = lastClosedLedger->info().seq + 1;
291 if (baseFee.second || baseReserve.second || incReserve.second)
294 <<
"We are voting for a fee change: " << baseFee.first <<
"/"
295 << baseReserve.first <<
"/" << incReserve.first;
297 STTx feeTx(ttFEE, [=, &rules](
auto& obj) {
299 obj[sfLedgerSequence] = seq;
300 if (rules.enabled(featureXRPFees))
302 obj[sfBaseFeeDrops] = baseFee.first;
303 obj[sfReserveBaseDrops] = baseReserve.first;
304 obj[sfReserveIncrementDrops] = incReserve.first;
312 obj[sfReserveBase] = baseReserve.first.dropsAs<
std::uint32_t>(
314 obj[sfReserveIncrement] =
321 uint256 txID = feeTx.getTransactionID();
328 if (!initialPosition->addGiveItem(
332 JLOG(
journal_.
warn()) <<
"Ledger already had fee change";
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.