mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Refactor fee initialization and configuration: (#4319)
* Create the FeeSettings object in genesis ledger. * Initialize with default values from the config. Removes the need to pass a Config down into the Ledger initialization functions, including setup(). * Drop the undocumented fee config settings in favor of the [voting] section. * Fix #3734. * If you previously used fee_account_reserve and/or fee_owner_reserve, you should change to using the [voting] section instead. Example: ``` [voting] account_reserve=10000000 owner_reserve=2000000 ``` * Because old Mainnet ledgers (prior to 562177 - yes, I looked it up) don't have FeeSettings, some of the other ctors will default them to the config values before setup() tries to load the object. * Update default Config fee values to match Mainnet. * Fix unit tests: * Updated fees: Some tests are converted to use computed values of fee object, but the default Env config was also updated to fix the rest. * Unit tests that check the structure of the ledger have updated hashes and counts.
This commit is contained in:
@@ -611,14 +611,12 @@ Config::loadFromString(std::string const& fileContents)
|
||||
if (getSingleSection(secConfig, SECTION_NETWORK_QUORUM, strTemp, j_))
|
||||
NETWORK_QUORUM = beast::lexicalCastThrow<std::size_t>(strTemp);
|
||||
|
||||
if (getSingleSection(secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp, j_))
|
||||
FEE_ACCOUNT_RESERVE = beast::lexicalCastThrow<std::uint64_t>(strTemp);
|
||||
|
||||
if (getSingleSection(secConfig, SECTION_FEE_OWNER_RESERVE, strTemp, j_))
|
||||
FEE_OWNER_RESERVE = beast::lexicalCastThrow<std::uint64_t>(strTemp);
|
||||
|
||||
FEES = setup_FeeVote(section("voting"));
|
||||
/* [fee_default] is documented in the example config files as useful for
|
||||
* things like offline transaction signing. Until that's completely
|
||||
* deprecated, allow it to override the [voting] section. */
|
||||
if (getSingleSection(secConfig, SECTION_FEE_DEFAULT, strTemp, j_))
|
||||
FEE_DEFAULT = beast::lexicalCastThrow<std::uint64_t>(strTemp);
|
||||
FEES.reference_fee = beast::lexicalCastThrow<std::uint64_t>(strTemp);
|
||||
|
||||
if (getSingleSection(secConfig, SECTION_LEDGER_HISTORY, strTemp, j_))
|
||||
{
|
||||
@@ -1017,4 +1015,24 @@ Config::getValueFor(SizedItem item, std::optional<std::size_t> node) const
|
||||
return sizedItems.at(index).second.at(node.value_or(NODE_SIZE));
|
||||
}
|
||||
|
||||
FeeSetup
|
||||
setup_FeeVote(Section const& section)
|
||||
{
|
||||
FeeSetup setup;
|
||||
{
|
||||
std::uint64_t temp;
|
||||
if (set(temp, "reference_fee", section) &&
|
||||
temp <= std::numeric_limits<XRPAmount::value_type>::max())
|
||||
setup.reference_fee = temp;
|
||||
}
|
||||
{
|
||||
std::uint32_t temp;
|
||||
if (set(temp, "account_reserve", section))
|
||||
setup.account_reserve = temp;
|
||||
if (set(temp, "owner_reserve", section))
|
||||
setup.owner_reserve = temp;
|
||||
}
|
||||
return setup;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user