1#include <xrpld/app/ledger/Ledger.h>
2#include <xrpld/app/misc/FeeVote.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/protocol/STValidation.h>
6#include <xrpl/protocol/st.h>
55 for (
auto const& [key, val] :
voteMap_)
66 return {ourVote, ourVote !=
current_};
96 : target_(setup), journal_(journal)
102 Fees const& lastFees,
109 if (rules.
enabled(featureXRPFees))
111 auto vote = [&v,
this](
115 auto const& sfield) {
119 <<
"Voting for " << name <<
" of " << target;
134 sfReserveIncrementDrops);
144 auto vote = [&v,
this](
147 auto const& convertCallback,
149 auto const& sfield) {
153 <<
"Voting for " << name <<
" of " << target;
155 if (
auto const f = convertCallback(target))
184 lastClosedLedger &&
isFlagLedger(lastClosedLedger->seq()),
185 "xrpl::FeeVoteImpl::doVoting : has a flag ledger");
196 auto const& rules = lastClosedLedger->rules();
197 if (rules.enabled(featureXRPFees))
202 if (
auto const field = ~val->at(~xrpField);
203 field && field->native())
205 auto const vote = field->xrp();
217 for (
auto const& val :
set)
219 if (!val->isTrusted())
221 doVote(val, baseFeeVote, sfBaseFeeDrops);
222 doVote(val, baseReserveVote, sfReserveBaseDrops);
223 doVote(val, incReserveVote, sfReserveIncrementDrops);
230 auto const& valueField) {
231 if (
auto const field = val->at(~valueField))
234 auto const vote = *field;
237 value.addVote(
XRPAmount{unsafe_cast<XRPType>(vote)});
250 for (
auto const& val :
set)
252 if (!val->isTrusted())
254 doVote(val, baseFeeVote, sfBaseFee);
255 doVote(val, baseReserveVote, sfReserveBase);
256 doVote(val, incReserveVote, sfReserveIncrement);
264 auto const baseFee = baseFeeVote.
getVotes();
265 auto const baseReserve = baseReserveVote.
getVotes();
266 auto const incReserve = incReserveVote.
getVotes();
268 auto const seq = lastClosedLedger->header().seq + 1;
271 if (baseFee.second || baseReserve.second || incReserve.second)
274 <<
"We are voting for a fee change: " << baseFee.first <<
"/"
275 << baseReserve.first <<
"/" << incReserve.first;
277 STTx feeTx(ttFEE, [=, &rules](
auto& obj) {
279 obj[sfLedgerSequence] = seq;
280 if (rules.enabled(featureXRPFees))
282 obj[sfBaseFeeDrops] = baseFee.first;
283 obj[sfReserveBaseDrops] = baseReserve.first;
284 obj[sfReserveIncrementDrops] = incReserve.first;
292 obj[sfReserveBase] = baseReserve.first.dropsAs<
std::uint32_t>(
294 obj[sfReserveIncrement] =
301 uint256 txID = feeTx.getTransactionID();
308 if (!initialPosition->addGiveItem(
312 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.
FeeVoteImpl(FeeSetup const &setup, beast::Journal journal)
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.
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
value_type const current_
std::map< value_type, int > voteMap_
std::pair< value_type, bool > getVotes() const
value_type current() const
VotableValue(value_type current, value_type target)
void addVote(value_type vote)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::unique_ptr< FeeVote > make_FeeVote(FeeSetup const &setup, beast::Journal journal)
Create an instance of the FeeVote logic.
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 isFlagLedger(LedgerIndex seq)
Returns true if the given ledgerIndex is a flag ledgerIndex.
boost::intrusive_ptr< SHAMapItem > make_shamapitem(uint256 const &tag, Slice data)
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
@ current
This was a new validation and was added.
bool isLegalAmountSigned(XRPAmount const &amount)
Returns true if the absolute value of the amount does not exceed the initial XRP in existence.
Fee schedule for startup / standalone, and to vote for.
XRPAmount reference_fee
The cost of a reference transaction in drops.
XRPAmount account_reserve
The account reserve requirement in drops.
XRPAmount owner_reserve
The per-owned item reserve requirement in drops.
Reflects the fee settings for a particular ledger.
A field with a type known at compile time.