mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 11:15:56 +00:00
Make code self-documenting by using symbolic constants
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include <ripple/protocol/Feature.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/types.h>
|
||||
#include <ripple/protocol/Protocol.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -557,12 +558,11 @@ void removeUnfundedOffers (ApplyView& view, std::vector<uint256> const& offers,
|
||||
|
||||
for (auto const& index : offers)
|
||||
{
|
||||
auto const sleOffer = view.peek (keylet::offer (index));
|
||||
if (sleOffer)
|
||||
if (auto const sleOffer = view.peek (keylet::offer (index)))
|
||||
{
|
||||
// offer is unfunded
|
||||
offerDelete (view, sleOffer, viewJ);
|
||||
if (++removed == 1000)
|
||||
if (++removed == unfundedOfferRemoveLimit)
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -648,7 +648,7 @@ Transactor::operator()()
|
||||
bool didApply = isTesSuccess (terResult);
|
||||
auto fee = ctx_.tx.getFieldAmount(sfFee).xrp ();
|
||||
|
||||
if (ctx_.size() > 5200)
|
||||
if (ctx_.size() > oversizeMetaDataCap)
|
||||
terResult = tecOVERSIZE;
|
||||
|
||||
if ((terResult == tecOVERSIZE) ||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/protocol/st.h>
|
||||
#include <ripple/protocol/Protocol.h>
|
||||
#include <ripple/protocol/Quality.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <cassert>
|
||||
@@ -100,14 +101,6 @@ bool fix1449 (NetClock::time_point const closeTime)
|
||||
return closeTime > fix1449Time();
|
||||
}
|
||||
|
||||
// VFALCO NOTE A copy of the other one for now
|
||||
/** Maximum number of entries in a directory page
|
||||
A change would be protocol-breaking.
|
||||
*/
|
||||
#ifndef DIR_NODE_MAX
|
||||
#define DIR_NODE_MAX 32
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Observers
|
||||
@@ -864,7 +857,7 @@ dirAdd (ApplyView& view,
|
||||
|
||||
svIndexes = sleNode->getFieldV256 (sfIndexes);
|
||||
|
||||
if (DIR_NODE_MAX != svIndexes.size ())
|
||||
if (dirNodeMaxEntries != svIndexes.size ())
|
||||
{
|
||||
// Add to current node.
|
||||
view.update(sleNode);
|
||||
|
||||
@@ -27,24 +27,27 @@ namespace ripple {
|
||||
|
||||
/** Protocol specific constants, types, and data.
|
||||
|
||||
This information is part of the Ripple protocol. Specifically,
|
||||
it is required for peers to be able to communicate with each other.
|
||||
This information is, implicitly, part of the Ripple
|
||||
protocol.
|
||||
|
||||
@note Changing these will create a hard fork.
|
||||
|
||||
@ingroup protocol
|
||||
@defgroup protocol
|
||||
@note Changing these values without adding code to the
|
||||
server to detect "pre-change" and "post-change"
|
||||
will result in a hard fork.
|
||||
*/
|
||||
struct Protocol
|
||||
{
|
||||
/** Smallest legal byte size of a transaction.
|
||||
*/
|
||||
static int const txMinSizeBytes = 32;
|
||||
/** Smallest legal byte size of a transaction. */
|
||||
std::size_t constexpr txMinSizeBytes = 32;
|
||||
|
||||
/** Largest legal byte size of a transaction.
|
||||
*/
|
||||
static int const txMaxSizeBytes = 1024 * 1024; // 1048576
|
||||
};
|
||||
/** Largest legal byte size of a transaction. */
|
||||
std::size_t constexpr txMaxSizeBytes = 1024 * 1024;
|
||||
|
||||
/** The maximum number of unfunded offers to delete at once */
|
||||
std::size_t constexpr unfundedOfferRemoveLimit = 1000;
|
||||
|
||||
/** The maximum number of metadata entries allowed in one transaction */
|
||||
std::size_t constexpr oversizeMetaDataCap = 5200;
|
||||
|
||||
/** The maximum number of entries per directory page */
|
||||
std::size_t constexpr dirNodeMaxEntries = 32;
|
||||
|
||||
/** A ledger index. */
|
||||
using LedgerIndex = std::uint32_t;
|
||||
@@ -59,4 +62,4 @@ using TxSeq = std::uint32_t;
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -72,7 +72,7 @@ STTx::STTx (SerialIter& sit)
|
||||
{
|
||||
int length = sit.getBytesLeft ();
|
||||
|
||||
if ((length < Protocol::txMinSizeBytes) || (length > Protocol::txMaxSizeBytes))
|
||||
if ((length < txMinSizeBytes) || (length > txMaxSizeBytes))
|
||||
Throw<std::runtime_error> ("Transaction length invalid");
|
||||
|
||||
set (sit);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <ripple/ledger/Sandbox.h>
|
||||
#include <ripple/core/ConfigSections.h>
|
||||
#include <ripple/protocol/Feature.h>
|
||||
#include <ripple/protocol/Protocol.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace ripple {
|
||||
@@ -873,9 +874,7 @@ class DirIsEmpty_test
|
||||
env.fund(XRP(10000), becky, gw);
|
||||
env.close();
|
||||
|
||||
// The DIR_NODE_MAX constant is hidden in View.cpp (Feb 2016). But,
|
||||
// ideally, we'd verify we're doing a good test with the following:
|
||||
// static_assert (64 >= (2 * DIR_NODE_MAX), "");
|
||||
static_assert (64 >= (2 * dirNodeMaxEntries), "");
|
||||
|
||||
// Generate 64 currencies named AAA -> AAP and ADA -> ADP.
|
||||
std::vector<IOU> currencies;
|
||||
|
||||
Reference in New Issue
Block a user