Skip to content

Commit

Permalink
[FOLD] Review feedback #1: First batch from @SEELab:
Browse files Browse the repository at this point in the history
* Move IOUAmount to basics
* Rename units namespace to feeunit
* Fix some FeeLevel unit handling in server_info
  • Loading branch information
ximinez committed Aug 19, 2019
1 parent 3d0324f commit 8329af6
Show file tree
Hide file tree
Showing 32 changed files with 79 additions and 77 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,7 @@ else ()
src/ripple/basics/impl/contract.cpp
src/ripple/basics/impl/CountedObject.cpp
src/ripple/basics/impl/FileUtilities.cpp
src/ripple/basics/impl/IOUAmount.cpp
src/ripple/basics/impl/Log.cpp
src/ripple/basics/impl/strHex.cpp
src/ripple/basics/impl/StringUtilities.cpp
Expand All @@ -1735,7 +1736,6 @@ else ()
src/ripple/protocol/impl/ErrorCodes.cpp
src/ripple/protocol/impl/Feature.cpp
src/ripple/protocol/impl/HashPrefix.cpp
src/ripple/protocol/impl/IOUAmount.cpp
src/ripple/protocol/impl/Indexes.cpp
src/ripple/protocol/impl/InnerObjectFormats.cpp
src/ripple/protocol/impl/Issue.cpp
Expand Down Expand Up @@ -1808,6 +1808,7 @@ install (
src/ripple/basics/Buffer.h
src/ripple/basics/CountedObject.h
src/ripple/basics/FileUtilities.h
src/ripple/basics/IOUAmount.h
src/ripple/basics/LocalValue.h
src/ripple/basics/Log.h
src/ripple/basics/safe_cast.h
Expand Down Expand Up @@ -1862,7 +1863,6 @@ install (
src/ripple/protocol/ErrorCodes.h
src/ripple/protocol/Feature.h
src/ripple/protocol/HashPrefix.h
src/ripple/protocol/IOUAmount.h
src/ripple/protocol/Indexes.h
src/ripple/protocol/InnerObjectFormats.h
src/ripple/protocol/Issue.h
Expand Down Expand Up @@ -2418,12 +2418,14 @@ else ()
src/test/basics/Buffer_test.cpp
src/test/basics/DetectCrash_test.cpp
src/test/basics/FileUtilities_test.cpp
src/test/basics/IOUAmount_test.cpp
src/test/basics/KeyCache_test.cpp
src/test/basics/PerfLog_test.cpp
src/test/basics/RangeSet_test.cpp
src/test/basics/Slice_test.cpp
src/test/basics/StringUtilities_test.cpp
src/test/basics/TaggedCache_test.cpp
src/test/basics/XRPAmount_test.cpp
src/test/basics/base64_test.cpp
src/test/basics/base_uint_test.cpp
src/test/basics/contract_test.cpp
Expand Down Expand Up @@ -2579,7 +2581,6 @@ else ()
subdir: protocol
#]===============================]
src/test/protocol/BuildInfo_test.cpp
src/test/protocol/IOUAmount_test.cpp
src/test/protocol/InnerObjectFormats_test.cpp
src/test/protocol/Issue_test.cpp
src/test/protocol/PublicKey_test.cpp
Expand All @@ -2592,7 +2593,6 @@ else ()
src/test/protocol/SecretKey_test.cpp
src/test/protocol/Seed_test.cpp
src/test/protocol/TER_test.cpp
src/test/protocol/XRPAmount_test.cpp
src/test/protocol/digest_test.cpp
src/test/protocol/types_test.cpp
#[===============================[
Expand Down
34 changes: 18 additions & 16 deletions src/ripple/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2226,14 +2226,15 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin, bool counters)

auto const loadFactorServer = app_.getFeeTrack().getLoadFactor();
auto const loadBaseServer = app_.getFeeTrack().getLoadBase();
auto const loadFactorFeeEscalation =
escalationMetrics.openLedgerFeeLevel;
auto const loadBaseFeeEscalation =
escalationMetrics.referenceFeeLevel;
/* Scale the escalated fee level to unitless "load factor".
In practice, this just strips the units, but it will continue
to work correctly if either base value ever changes. */
auto const loadFactorFeeEscalation = mulDiv(
escalationMetrics.openLedgerFeeLevel, loadBaseServer,
escalationMetrics.referenceFeeLevel).second;

auto const loadFactor = std::max(safe_cast<std::uint64_t>(loadFactorServer),
mulDiv(loadFactorFeeEscalation, loadBaseServer,
loadBaseFeeEscalation).second);
loadFactorFeeEscalation);

if (!human)
{
Expand All @@ -2247,11 +2248,11 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin, bool counters)
that high.
*/
info[jss::load_factor_fee_escalation] =
loadFactorFeeEscalation.json();
escalationMetrics.openLedgerFeeLevel.json();
info[jss::load_factor_fee_queue] =
escalationMetrics.minProcessingFeeLevel.json();
info[jss::load_factor_fee_reference] =
loadBaseFeeEscalation.json();
escalationMetrics.referenceFeeLevel.json();
}
else
{
Expand All @@ -2276,13 +2277,14 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin, bool counters)
info[jss::load_factor_cluster] =
static_cast<double> (fee) / loadBaseServer;
}
if (loadFactorFeeEscalation !=
if (escalationMetrics.openLedgerFeeLevel !=
escalationMetrics.referenceFeeLevel &&
(admin ||
loadFactorFeeEscalation != FeeLevel64{ loadFactor }))
loadFactorFeeEscalation != loadFactor))
info[jss::load_factor_fee_escalation] =
static_cast<FeeLevelDouble>(loadFactorFeeEscalation) /
escalationMetrics.referenceFeeLevel;
static_cast<FeeLevelDouble>(
escalationMetrics.openLedgerFeeLevel) /
escalationMetrics.referenceFeeLevel;
if (escalationMetrics.minProcessingFeeLevel !=
escalationMetrics.referenceFeeLevel)
info[jss::load_factor_fee_queue] =
Expand Down Expand Up @@ -2319,16 +2321,16 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin, bool counters)
{
// Make a local specialization of the TaggedFee class, using
// XRPAmount as the "unit" to make some of the math here easier.
using DropsDouble = units::TaggedFee<XRPAmount, double>;
using XRPDouble = feeunit::TaggedFee<XRPAmount, double>;

l[jss::base_fee_xrp] =
static_cast<DropsDouble>(baseFee) /
static_cast<XRPDouble>(baseFee) /
DROPS_PER_XRP;
l[jss::reserve_base_xrp] =
static_cast<DropsDouble>(
static_cast<XRPDouble>(
lpClosed->fees().accountReserve(0)) / DROPS_PER_XRP;
l[jss::reserve_inc_xrp] =
static_cast<DropsDouble>(
static_cast<XRPDouble>(
lpClosed->fees().increment) / DROPS_PER_XRP;

auto const nowOffset = app_.timeKeeper().nowOffset();
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/misc/impl/LoadFeeTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace detail
struct xrp_unit_product_tag;

using xrp_unit_product =
units::TaggedFee<detail::xrp_unit_product_tag, std::uint64_t>;
feeunit::TaggedFee<detail::xrp_unit_product_tag, std::uint64_t>;

} // detail

Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/paths/Credit.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#ifndef RIPPLE_APP_PATHS_CREDIT_H_INCLUDED
#define RIPPLE_APP_PATHS_CREDIT_H_INCLUDED

#include <ripple/basics/IOUAmount.h>
#include <ripple/ledger/View.h>
#include <ripple/protocol/STAmount.h>
#include <ripple/protocol/IOUAmount.h>

namespace ripple {

Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/paths/Flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <ripple/app/paths/impl/StrandFlow.h>
#include <ripple/app/paths/impl/Steps.h>
#include <ripple/basics/Log.h>
#include <ripple/protocol/IOUAmount.h>
#include <ripple/basics/IOUAmount.h>
#include <ripple/basics/XRPAmount.h>

#include <boost/container/flat_set.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/paths/impl/AmountSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef RIPPLE_PATH_IMPL_AMOUNTSPEC_H_INCLUDED
#define RIPPLE_PATH_IMPL_AMOUNTSPEC_H_INCLUDED

#include <ripple/protocol/IOUAmount.h>
#include <ripple/basics/IOUAmount.h>
#include <ripple/basics/XRPAmount.h>
#include <ripple/protocol/STAmount.h>

Expand Down
4 changes: 2 additions & 2 deletions src/ripple/app/paths/impl/BookStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
#include <ripple/app/paths/NodeDirectory.h>
#include <ripple/app/tx/impl/OfferStream.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/IOUAmount.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/XRPAmount.h>
#include <ripple/ledger/Directory.h>
#include <ripple/ledger/PaymentSandbox.h>
#include <ripple/protocol/Book.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/IOUAmount.h>
#include <ripple/protocol/Quality.h>
#include <ripple/basics/XRPAmount.h>

#include <boost/container/flat_set.hpp>

Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/paths/impl/DirectStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include <ripple/app/paths/Credit.h>
#include <ripple/app/paths/impl/StepChecks.h>
#include <ripple/app/paths/impl/Steps.h>
#include <ripple/basics/IOUAmount.h>
#include <ripple/basics/Log.h>
#include <ripple/ledger/PaymentSandbox.h>
#include <ripple/protocol/IOUAmount.h>
#include <ripple/protocol/Quality.h>

#include <boost/container/flat_set.hpp>
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/app/paths/impl/FlowDebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#define RIPPLE_PATH_IMPL_FLOWDEBUGINFO_H_INCLUDED

#include <ripple/app/paths/impl/AmountSpec.h>
#include <ripple/ledger/PaymentSandbox.h>
#include <ripple/protocol/IOUAmount.h>
#include <ripple/basics/IOUAmount.h>
#include <ripple/basics/XRPAmount.h>
#include <ripple/ledger/PaymentSandbox.h>

#include <boost/container/flat_map.hpp>
#include <boost/optional.hpp>
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/app/paths/impl/PaySteps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

#include <ripple/app/paths/impl/Steps.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/IOUAmount.h>
#include <ripple/basics/XRPAmount.h>
#include <ripple/json/json_writer.h>
#include <ripple/ledger/ReadView.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/IOUAmount.h>
#include <ripple/basics/XRPAmount.h>

#include <algorithm>
#include <numeric>
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/app/paths/impl/StrandFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <ripple/app/paths/impl/FlatSets.h>
#include <ripple/app/paths/impl/FlowDebugInfo.h>
#include <ripple/app/paths/impl/Steps.h>
#include <ripple/basics/Log.h>
#include <ripple/protocol/IOUAmount.h>
#include <ripple/basics/IOUAmount.h>
#include <ripple/basics/XRPAmount.h>
#include <ripple/basics/Log.h>

#include <boost/container/flat_set.hpp>

Expand Down
4 changes: 2 additions & 2 deletions src/ripple/app/paths/impl/XRPEndpointStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include <ripple/app/paths/impl/AmountSpec.h>
#include <ripple/app/paths/impl/Steps.h>
#include <ripple/app/paths/impl/StepChecks.h>
#include <ripple/basics/IOUAmount.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/XRPAmount.h>
#include <ripple/ledger/PaymentSandbox.h>
#include <ripple/protocol/IOUAmount.h>
#include <ripple/protocol/Quality.h>
#include <ripple/basics/XRPAmount.h>

#include <boost/container/flat_set.hpp>

Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/tx/impl/ApplyContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

#include <ripple/app/main/Application.h>
#include <ripple/ledger/ApplyViewImpl.h>
#include <ripple/basics/XRPAmount.h>
#include <ripple/core/Config.h>
#include <ripple/protocol/STTx.h>
#include <ripple/basics/XRPAmount.h>
#include <ripple/beast/utility/Journal.h>
#include <boost/optional.hpp>
#include <utility>
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/tx/impl/Escrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <ripple/basics/chrono.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/safe_cast.h>
#include <ripple/basics/XRPAmount.h>
#include <ripple/conditions/Condition.h>
#include <ripple/conditions/Fulfillment.h>
#include <ripple/ledger/ApplyView.h>
Expand All @@ -32,7 +33,6 @@
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/Indexes.h>
#include <ripple/protocol/TxFlags.h>
#include <ripple/basics/XRPAmount.h>

// During an EscrowFinish, the transaction must specify both
// a condition and a fulfillment. We track whether that
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/tx/impl/PayChan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <ripple/app/tx/impl/PayChan.h>
#include <ripple/basics/chrono.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/XRPAmount.h>
#include <ripple/ledger/ApplyView.h>
#include <ripple/ledger/View.h>
#include <ripple/protocol/digest.h>
Expand All @@ -29,7 +30,6 @@
#include <ripple/protocol/PublicKey.h>
#include <ripple/protocol/st.h>
#include <ripple/protocol/TxFlags.h>
#include <ripple/basics/XRPAmount.h>

namespace ripple {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
//==============================================================================

#ifndef RIPPLE_PROTOCOL_IOUAMOUNT_H_INCLUDED
#define RIPPLE_PROTOCOL_IOUAMOUNT_H_INCLUDED
#ifndef RIPPLE_BASICS_IOUAMOUNT_H_INCLUDED
#define RIPPLE_BASICS_IOUAMOUNT_H_INCLUDED

#include <ripple/beast/utility/Zero.h>
#include <boost/operators.hpp>
Expand Down
Loading

0 comments on commit 8329af6

Please sign in to comment.