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>
54 for (
auto const& [key, val] :
voteMap_)
64 return {ourVote, ourVote !=
current_};
102 if (rules.
enabled(featureXRPFees))
104 auto vote = [&v,
this](
auto const current,
XRPAmount target,
char const* name,
auto const& sfield) {
107 JLOG(
journal_.
info()) <<
"Voting for " << name <<
" of " << target;
120 auto vote = [&v,
this](
123 auto const& convertCallback,
125 auto const& sfield) {
128 JLOG(
journal_.
info()) <<
"Voting for " << name <<
" of " << target;
130 if (
auto const f = convertCallback(target))
149 lastClosedLedger &&
isFlagLedger(lastClosedLedger->seq()),
"xrpl::FeeVoteImpl::doVoting : has a flag ledger");
157 auto const& rules = lastClosedLedger->rules();
158 if (rules.enabled(featureXRPFees))
162 if (
auto const field = ~val->at(~xrpField); field && field->native())
164 auto const vote = field->xrp();
176 for (
auto const& val :
set)
178 if (!val->isTrusted())
180 doVote(val, baseFeeVote, sfBaseFeeDrops);
181 doVote(val, baseReserveVote, sfReserveBaseDrops);
182 doVote(val, incReserveVote, sfReserveIncrementDrops);
189 if (
auto const field = val->at(~valueField))
192 auto const vote = *field;
195 value.addVote(
XRPAmount{unsafe_cast<XRPType>(vote)});
208 for (
auto const& val :
set)
210 if (!val->isTrusted())
212 doVote(val, baseFeeVote, sfBaseFee);
213 doVote(val, baseReserveVote, sfReserveBase);
214 doVote(val, incReserveVote, sfReserveIncrement);
222 auto const baseFee = baseFeeVote.
getVotes();
223 auto const baseReserve = baseReserveVote.
getVotes();
224 auto const incReserve = incReserveVote.
getVotes();
226 auto const seq = lastClosedLedger->header().seq + 1;
229 if (baseFee.second || baseReserve.second || incReserve.second)
231 JLOG(
journal_.
warn()) <<
"We are voting for a fee change: " << baseFee.first <<
"/" << baseReserve.first <<
"/"
234 STTx feeTx(ttFEE, [=, &rules](
auto& obj) {
236 obj[sfLedgerSequence] = seq;
237 if (rules.enabled(featureXRPFees))
239 obj[sfBaseFeeDrops] = baseFee.first;
240 obj[sfReserveBaseDrops] = baseReserve.first;
241 obj[sfReserveIncrementDrops] = incReserve.first;
254 uint256 txID = feeTx.getTransactionID();
263 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.