Compare commits

...

15 Commits

Author SHA1 Message Date
Denis Angell
f80e72c6f7 fix: address clang-tidy findings and review feedback 2026-08-06 15:08:42 -04:00
Denis Angell
c16f18f79b fix: harden cgroup detection and rename ledger_fetch_size 2026-08-06 12:37:30 -04:00
Denis Angell
a40b88436d feat: add overrides for fixed cache policy values 2026-08-06 12:20:44 -04:00
Denis Angell
c65e4539f5 feat: resolve the process cgroup path for nested memory limits 2026-08-06 12:18:39 -04:00
Denis Angell
45ed9e4de7 feat: replace node_size with memory_limit 2026-08-06 11:06:51 -04:00
Ayaz Salikhov
5bf24c4045 ci: Use a separate benchmark filter (#7919) 2026-08-06 11:04:41 +00:00
Gregory Tsipenyuk
8d7524f03b fix: Use consistent endianness serializing MPT STIssue sequence (#7429)
Co-authored-by: Ed Hennis <ed@ripple.com>
Co-authored-by: David Fuelling <sappenin@gmail.com>
2026-08-05 17:54:44 +00:00
Ayaz Salikhov
41d6bb5f73 build: Fix build on macOS 15 and Nix environment (#7953) 2026-08-04 23:27:23 +00:00
Ayaz Salikhov
a75488e5ff docs: Add a fix for command not found: nix on macOS (#7951) 2026-08-04 16:17:41 +00:00
Vito Tumas
c3ee602002 test: Split Loan_test.cpp into topical suites (#7864)
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
2026-08-04 15:43:59 +00:00
Vito Tumas
e0de716ee6 fix: Watch nix/*.nix files for direnv cache invalidation (#7948) 2026-08-04 13:49:18 +00:00
Alex Kremer
06488c1318 chore: Rename CamelCase namespaces to snake_case (#7933)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-08-04 13:46:55 +00:00
Luc des Trois Maisons
b8451ffa32 fix: Add missing value_type to JSON iterators (#7907) 2026-08-03 21:17:23 +00:00
Timur Yalymov
765babb20d fix: Add VaultInvariant check that lossUnrealized is non-negative (#7863)
Co-authored-by: Vito Tumas <5780819+Tapanito@users.noreply.github.com>
2026-08-03 21:11:33 +00:00
Braedon Klock
97f35add2e fix: Add null check for account object reads (#7717)
Co-authored-by: Mayukha Vadari <mvadari@ripple.com>
2026-08-03 21:08:42 +00:00
335 changed files with 13314 additions and 12031 deletions

View File

@@ -85,6 +85,8 @@ CheckOptions:
readability-braces-around-statements.ShortStatementLines: 2
readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
readability-identifier-naming.NamespaceCase: lower_case
readability-identifier-naming.InlineNamespaceCase: lower_case
readability-identifier-naming.ClassCase: CamelCase
readability-identifier-naming.StructCase: CamelCase
readability-identifier-naming.UnionCase: CamelCase

2
.envrc
View File

@@ -1 +1,3 @@
watch_file nix/*.nix
use flake

View File

@@ -33,6 +33,10 @@ def get_cmake_args(build_type: str, extra_args: str) -> str:
# Every config must declare 'minimal'. Minimal configs form the reduced matrix
# built for pull requests by default; the full matrix adds the rest. Packaging
# configs declare it too, but packaging is gated in the workflow, not by it.
#
# Configs may also opt into 'benchmark' to smoke-run the benchmarks. Note that
# the flag applies to every entry a config expands into, so only set it on
# configs that expand to a single combination.
@dataclasses.dataclass
@@ -43,6 +47,7 @@ class LinuxConfig:
build_type: list[str]
arch: list[str]
minimal: bool
benchmark: bool = False # if true, smoke-run the benchmarks after testing
sanitizers: list[str] = dataclasses.field(default_factory=list)
suffix: str = ""
extra_cmake_args: str = ""
@@ -81,6 +86,7 @@ class PlatformConfig:
build_type: list[str]
minimal: bool
build_only: bool = False # if true, skip tests (e.g. macos/Windows Debug)
benchmark: bool = False # if true, smoke-run the benchmarks after testing
extra_cmake_args: str = ""
def __post_init__(self) -> None:
@@ -125,6 +131,7 @@ class MatrixEntry:
cmake_args: str
cmake_target: str
build_only: bool
benchmark: bool
build_type: str
architecture: Architecture
sanitizers: str
@@ -193,6 +200,7 @@ def expand_linux_matrix(linux: LinuxFile, minimal: bool) -> list[MatrixEntry]:
cmake_args=get_cmake_args(build_type, cfg.extra_cmake_args),
cmake_target="all",
build_only=False,
benchmark=cfg.benchmark,
build_type=build_type,
architecture=arch_info,
sanitizers=sanitizer,
@@ -245,6 +253,7 @@ def expand_platform_matrix(pf: PlatformFile, minimal: bool) -> list[MatrixEntry]
cmake_args=get_cmake_args(build_type, cfg.extra_cmake_args),
cmake_target="install" if is_windows else "all",
build_only=cfg.build_only,
benchmark=cfg.benchmark,
build_type=build_type,
architecture=Architecture(platform=pf.platform, runner=pf.runner),
sanitizers="",

View File

@@ -14,7 +14,8 @@
"compiler": ["clang"],
"build_type": ["Release"],
"arch": ["amd64"],
"minimal": true
"minimal": true,
"benchmark": true
},
{

View File

@@ -3,6 +3,12 @@ name: Build and test configuration
on:
workflow_call:
inputs:
benchmark:
description: "Whether to smoke-run the benchmarks after testing."
required: false
type: boolean
default: false
build_only:
description: 'Whether to only build or to build and test the code ("true", "false").'
required: true
@@ -328,11 +334,14 @@ jobs:
# Smoke-run every benchmark module with a single repetition to confirm the
# benchmarks still build and execute. This is a correctness check, not a
# performance measurement, so it is skipped for instrumented builds
# (sanitizers/coverage/voidstar), where it would be slow and meaningless,
# and on Windows, where the `install` target does not build them.
# performance measurement, so there is nothing to gain from repeating it
# across configurations: it is opted into by a single config in the
# strategy matrix (see the 'benchmark' flag in the JSON files), which
# keeps it off instrumented builds (sanitizers/coverage/voidstar), where
# it would be slow and meaningless, off Debug builds, where it is much
# slower, and off Windows, where the `install` target does not build them.
- name: Run the benchmarks
if: ${{ !inputs.build_only && runner.os != 'Windows' && env.SANITIZERS_ENABLED == 'false' && env.COVERAGE_ENABLED != 'true' && env.VOIDSTAR_ENABLED != 'true' }}
if: ${{ inputs.benchmark }}
working-directory: ${{ env.BUILD_DIR }}
run: |
rc=0

View File

@@ -40,6 +40,7 @@ jobs:
fail-fast: ${{ github.event_name == 'merge_group' }}
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
with:
benchmark: ${{ matrix.benchmark }}
build_only: ${{ matrix.build_only }}
build_type: ${{ matrix.build_type }}
ccache_enabled: ${{ inputs.ccache_enabled }}

View File

@@ -28,6 +28,8 @@ This section contains changes targeting a future version.
### Additions
- `server_info` (admin): The `node_size` field has been removed along with the deprecated `[node_size]` config setting it reported. Admin responses now include `memory_limit`, the cache memory budget in gigabytes (0 when enforcement is disabled).
- `account_tx`: Added an optional `delegate` request object to filter delegated transactions. The object requires `delegate_filter`, which must be either `actor` for transactions owned by the requested account but signed by another account, or `authorizer` for transactions signed by the requested account on behalf of another account. The optional `counter_party` account narrows the results to a specific signer/delegate for `actor` or a specific owner/delegator for `authorizer`. Malformed `delegate`, `delegate_filter`, and `counter_party` values return standard invalid field errors, and invalid account IDs return `actMalformed`.
When paginating delegate-filtered queries, a marker from a delegate-filtered query includes a `delegate` flag and is only valid for follow-up requests that also supply `delegate` (mixing marker conventions returns `invalidParams`). Because filtering is applied after the ledger scan, a page may contain fewer results than `limit` (possibly zero) while still returning a marker, so callers must continue until no marker is present.

View File

@@ -42,6 +42,8 @@ Our Linux CI tooling is distro-independent and uses a Nix-based environment, so
### macOS
Many `xrpld` engineers use macOS for development.
The minimum supported version is macOS 15 (Sequoia).
CI testing is done in macOS 26 (Tahoe), but the build defaults `CMAKE_OSX_DEPLOYMENT_TARGET` to 15.
### Windows

View File

@@ -13,6 +13,23 @@ if(DEFINED CMAKE_MODULE_PATH)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Must be set before project() because project() consumes it when configuring the compiler and SDK.
# A user-provided -DCMAKE_OSX_DEPLOYMENT_TARGET still takes precedence.
#
# CMAKE_SYSTEM_NAME can't be used before project(), so CMAKE_HOST_SYSTEM_NAME is used instead.
#
# When CMAKE_OSX_DEPLOYMENT_TARGET is bumped to >=26.0, FastFloat dependency won't be needed anymore
if(
CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin"
AND NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET
)
set(CMAKE_OSX_DEPLOYMENT_TARGET
"15.0"
CACHE STRING
"Minimum macOS deployment version"
)
endif()
project(xrpl)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 23)
@@ -87,6 +104,7 @@ include(deps/Boost)
add_subdirectory(external/antithesis-sdk)
find_package(date REQUIRED)
find_package(ed25519 REQUIRED)
find_package(FastFloat REQUIRED)
find_package(gRPC REQUIRED)
find_package(LibArchive REQUIRED)
find_package(lz4 REQUIRED)
@@ -102,6 +120,7 @@ target_link_libraries(
xrpl_libs
INTERFACE
ed25519::ed25519
FastFloat::fast_float
lz4::lz4
mpt-crypto::mpt-crypto
OpenSSL::Crypto

View File

@@ -1306,23 +1306,40 @@
#
# [node_size]
#
# Tunes the servers based on the expected load and available memory. Legal
# sizes are "tiny", "small", "medium", "large", and "huge". We recommend
# you start at the default and raise the setting if you have extra memory.
# DEPRECATED. Each size is now an alias for a [memory_limit] value:
# tiny = 4, small = 8, medium = 32, large = 64, huge = 128. Set
# [memory_limit] instead; setting this logs a warning at startup.
#
# The code attempts to automatically determine the appropriate size for
# this parameter based on the amount of RAM and the number of execution
# cores available to the server. The current decision matrix is:
# [memory_limit]
#
# | | Cores |
# |---------|------------------------|
# | RAM | 1 | 2 or 3 | ≥ 4 |
# |---------|------|--------|--------|
# | < ~8GB | tiny | tiny | tiny |
# | < ~12GB | tiny | small | small |
# | < ~16GB | tiny | small | medium |
# | < ~24GB | tiny | small | large |
# | < ~32GB | tiny | small | huge |
# The memory budget, in gigabytes, that the server sizes its caches
# within. Cache sizes scale with the budget; the SHAMap tree node cache
# is capped to fit within half of it, enforced as it grows. Defaults to
# detected physical RAM (capped by the container limit when one is set);
# 0 selects minimal sizes with no enforcement. Values above 1024 are
# rejected, and a value above detected RAM logs a warning.
# Set this when xrpld shares the machine with other services or runs in
# a container with a memory limit below the host's RAM. Thread counts
# are unrelated: they come from the core count and the [workers] /
# [io_workers] overrides.
#
# Example:
# memory_limit = 16
#
# [tree_cache_age]
#
# Seconds a SHAMap tree node stays cached after its last use. The default
# is 300. Accepted values are 10 to 3600.
#
# [ledger_cache_age]
#
# Seconds a full ledger stays in the ledger cache after its last use. The
# default is 180. Accepted values are 10 to 3600.
#
# [ledger_fetch_size]
#
# How many historical ledgers to acquire per fetch pass while backfilling.
# The default is 4. Accepted values are 1 to 16.
#
# [signing_support]
#

View File

@@ -20,6 +20,7 @@
"jemalloc/5.3.1#1fc58d55316041f10fbc1e8a2eae632a%1776700028.228",
"gtest/1.17.0#5224b3b3ff3b4ce1133cbdd27d53ee7d%1782392402.791979",
"grpc/1.81.1#f729f6d75992d20f9c72828e9142d62f%1783945160.094135",
"fast_float/8.2.10#f6f28d6bb22112078e7dbda611caf681%1782494504.298",
"ed25519/2015.03#ae761bdc52730a843f0809bdf6c1b1f6%1782307148.15562",
"date/3.0.4#862e11e80030356b53c2c38599ceb32b%1782392402.538492",
"c-ares/1.34.6#545240bb1c40e2cacd4362d6b8967650%1782392402.681654",
@@ -34,7 +35,7 @@
"protobuf/6.33.5#ff253ead763bd8d9904a52979cd21e81%1782392410.233933",
"nasm/2.16.01#31e26f2ee3c4346ecd347911bd126904%1782395690.33162",
"msys2/cci.latest#d22fe7b2808f5fd34d0a7923ace9c54f%1770657326.649",
"m4/1.4.19#34c4bbc3eeebe98ca6edf2f52d602e7d%1777282960.259",
"m4/1.4.19#1727f439cf74e83826ec96d0b4904eee%1784541921.659",
"cmake/4.3.3#840cf00ea09777e05c2050a50a82c722%1782392418.696091",
"b2/5.4.2#ffd6084a119587e70f11cd45d1a386e2%1782392402.624226",
"automake/1.16.5#b91b7c384c3deaa9d535be02da14d04f%1755524470.56",

View File

@@ -5,6 +5,13 @@
{% if os == "Linux" %}
{% set compiler_version = detect_api.default_compiler_version(compiler, version) %}
{% endif %}
{% if os == "Macos" %}
{# Minimum macOS the dependencies target. #}
{# Without this, Conan builds each dependency against the (possibly newer) host SDK, so the #}
{# dependency objects target a newer macOS than the binary and the linker warns. #}
{# Keep at or below CMAKE_OSX_DEPLOYMENT_TARGET in CMakeLists.txt. #}
{% set min_macos_version = "15.0" %}
{% endif %}
[settings]
os={{ os }}
@@ -18,6 +25,9 @@ compiler.runtime=static
{% else %}
compiler.libcxx={{ detect_api.detect_libcxx(compiler, version, compiler_exe) }}
{% endif %}
{% if os == "Macos" %}
os.version={{ min_macos_version }}
{% endif %}
[conf]
{# The Boost recipe builds with b2, which doesn't use Conan's toolchain files. #}
@@ -41,3 +51,13 @@ tools.build:compiler_executables={'c':'{{ cc_exe }}','cpp':'{{ cxx_exe }}'}
{# More info: https://docs.conan.io/2/reference/extensions/binary_compatibility.html #}
user.package:cppstd_version=23
tools.info.package_id:confs+=["user.package:cppstd_version"]
{% if os == "Macos" %}
[buildenv]
{# os.version adds -mmacosx-version-min to compiler command lines, #}
{# but Boost.Context's b2 assembly (.S) rule ignores it, #}
{# so those objects keep the host SDK version and still warn at link time. #}
{# clang's assembler honors this env var regardless, pinning them. #}
{# Scoped to boost/* since it is the only gap. #}
boost/*:MACOSX_DEPLOYMENT_TARGET={{ min_macos_version }}
{% endif %}

View File

@@ -29,6 +29,7 @@ class Xrpl(ConanFile):
requires = [
"ed25519/2015.03",
"fast_float/8.2.10",
"grpc/1.81.1",
"libarchive/3.8.7",
"nudb/2.0.9",
@@ -211,6 +212,7 @@ class Xrpl(ConanFile):
"boost::thread",
"date::date",
"ed25519::ed25519",
"fast_float::fast_float",
"grpc::grpc++",
"libarchive::libarchive",
"lz4::lz4",

View File

@@ -3,6 +3,78 @@
Common issues encountered when using the [Nix development shell](./nix.md), and
how to resolve them.
## `command not found: nix` after a macOS update
If a shell suddenly can't find `nix` at all:
```
$ nix develop
zsh: command not found: nix
```
then Nix is almost certainly still installed — only the shell hook that puts it
on your `PATH` is gone. Confirm that first:
```bash
ls -l /nix/var/nix/profiles/default/bin/nix
```
If that exists, the installation is fine and this is purely a `PATH` problem.
### Why it happens
The installer does not touch your dotfiles. Instead it sources a setup script
from the Nix store by editing **system-wide** rc files:
| Shell | File the installer edits |
| ----- | ------------------------------------- |
| bash | `/etc/bashrc`, `/etc/bash.bashrc` |
| zsh | `/etc/zshrc` |
| fish | `$__fish_sysconf_dir/conf.d/nix.fish` |
macOS manages `/etc/zshrc`, so an OS update can replace it with the vendor copy
and silently drop the Nix block. `/etc/bashrc` and the fish file usually survive,
which is why the breakage often shows up in zsh only. You can verify this by
diffing against the backup the installer left behind:
```bash
diff /etc/zshrc /etc/zshrc.backup-before-nix
```
If they are identical, the Nix snippet was wiped. This is upstream issue
[NixOS/nix#3616](https://github.com/NixOS/nix/issues/3616).
### Fix
To unblock the current shell:
```bash
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
```
For a permanent fix, add the snippet to your **user** rc file rather than
restoring `/etc/zshrc` — user dotfiles are not clobbered by OS updates:
```bash
cat >>~/.zshrc <<'EOF'
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
EOF
```
The scripts guard against double-sourcing via `__ETC_PROFILE_NIX_SOURCED`, so
this is safe even if a system-wide hook is later restored.
> [!NOTE]
> `/etc/zshrc` and `~/.zshrc` are only read by **interactive** zsh. If the
> snippet is present but `zsh -c '…'`, a script, or an IDE terminal still can't
> find `nix`, that shell is non-interactive — put the snippet in `~/.zshenv`
> instead.
## Git worktrees
If `nix develop` fails with an error like:

View File

@@ -11,7 +11,7 @@ namespace xrpl {
class Resolver
{
public:
using HandlerType = std::function<void(std::string, std::vector<beast::IP::Endpoint>)>;
using HandlerType = std::function<void(std::string, std::vector<beast::ip::Endpoint>)>;
virtual ~Resolver() = 0;

View File

@@ -74,13 +74,20 @@ public:
using shared_pointer_type = SharedPointerType;
public:
/**
* @param cacheHardCap When positive, a hard upper bound on the number of
* strongly-cached entries, enforced by demoting the approximately
* oldest entry whenever growth would exceed it. 0 disables the cap
* (the periodic sweep alone bounds the cache).
*/
TaggedCache(
std::string const& name,
int size,
clock_type::duration expiration,
clock_type& clock,
beast::Journal journal,
beast::insight::Collector::ptr const& collector = beast::insight::NullCollector::make());
beast::insight::Collector::ptr const& collector = beast::insight::NullCollector::make(),
int cacheHardCap = 0);
public:
/**
@@ -357,6 +364,13 @@ private:
using cache_type = hardened_partitioned_hash_map<key_type, Entry, Hash, KeyEqual>;
// Bounded approximate-LRU eviction from a single partition. Keeps the
// strong-entry count at/below cacheHardCap_ as new entries are inserted, so
// a burst can't drive the cache past its RAM budget between timer sweeps.
// No-op unless cacheHardCap_ > 0 (opt-in); caller holds mutex_.
void
evictForHardCap(cache_type::map_type& partition, cache_type::map_type::iterator const& keep);
[[nodiscard]] std::thread
sweepHelper(
clock_type::time_point const& whenExpire,
@@ -390,8 +404,23 @@ private:
// Desired maximum cache age
clock_type::duration const targetAge_;
// Hard upper bound on strongly-cached entries, enforced by
// evictForHardCap whenever the strong count grows (fresh inserts and
// weak-to-strong revivals). 0 disables it (sweep-only sizing).
int const cacheHardCap_;
// Total hard-cap evictions (under mutex_); the first marks saturation
// onset for logging.
std::uint64_t hardCapEvictions_{0};
// Number of items cached
int cacheCount_{0};
// Rotating bucket cursor for evictForHardCap so successive over-cap
// evictions sweep the whole partition (CLOCK hand) instead of repeatedly
// sampling the head buckets. Advanced under mutex_.
std::size_t evictHand_{0};
cache_type cache_; // Hold strong reference to recent objects
std::uint64_t hits_{0};
std::uint64_t misses_{0};

View File

@@ -57,7 +57,8 @@ inline TaggedCache<
clock_type::duration expiration,
clock_type& clock,
beast::Journal journal,
beast::insight::Collector::ptr const& collector)
beast::insight::Collector::ptr const& collector,
int cacheHardCap)
: journal_(journal)
, clock_(clock)
, stats_(
@@ -67,6 +68,7 @@ inline TaggedCache<
, name_(name)
, targetSize_(size)
, targetAge_(expiration)
, cacheHardCap_(cacheHardCap)
{
}
@@ -219,6 +221,102 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
return true;
}
template <
class Key,
class T,
bool IsKeyCache,
class SharedWeakUnionPointer,
class SharedPointerType,
class Hash,
class KeyEqual,
class Mutex>
inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
evictForHardCap(cache_type::map_type& partition, cache_type::map_type::iterator const& keep)
{
// Caller holds mutex_. Only value caches carry strong/weak entries; key
// caches never enable the hard cap, so this is a no-op for them.
if constexpr (!IsKeyCache)
{
std::size_t const bucketCount = partition.bucket_count();
if (bucketCount == 0)
return;
// Approximate LRU with bounded work per call: sample a window of
// strong entries starting at the rotating bucket cursor and demote
// the oldest, repeating until the count is back under the cap or the
// demotion budget is spent. Growth paths raise the count by one at a
// time, so the budget lets eviction catch up without stalling them.
constexpr int kEvictSampleBudget = 64;
constexpr int kMaxDemotionsPerCall = 8;
std::size_t const maxBuckets = std::min<std::size_t>(bucketCount, 4 * kEvictSampleBudget);
for (int demotions = 0; cacheCount_ > cacheHardCap_ && demotions < kMaxDemotionsPerCall;
++demotions)
{
int sampled = 0;
std::size_t bucketsWalked = 0;
key_type oldestKey{};
bool haveOldest = false;
clock_type::time_point oldestAccess{};
std::size_t b = evictHand_ % bucketCount;
while (sampled < kEvictSampleBudget && bucketsWalked < maxBuckets)
{
for (auto lit = partition.begin(b); lit != partition.end(b); ++lit)
{
if (lit->first == keep->first || lit->second.isWeak())
continue;
if (!haveOldest || lit->second.lastAccess < oldestAccess)
{
oldestAccess = lit->second.lastAccess;
oldestKey = lit->first;
haveOldest = true;
}
if (++sampled >= kEvictSampleBudget)
break;
}
b = (b + 1) % bucketCount;
++bucketsWalked;
}
evictHand_ = b; // resume the scan here on the next over-cap call
if (!haveOldest)
{
JLOG(journal_.debug()) << name_ << ": over hard cap " << cacheHardCap_
<< " but eviction sample found no strong entry to demote";
return;
}
auto oldest = partition.find(oldestKey);
if (oldest == partition.end() || oldest == keep || oldest->second.isWeak())
return;
if (oldest->second.ptr.useCount() == 1)
{
// Sole owner: release entirely.
partition.erase(oldest);
}
else
{
// Others hold it: keep it weakly tracked.
oldest->second.ptr.convertToWeak();
}
--cacheCount_;
// First eviction marks saturation onset; then a heartbeat every
// 100k to avoid flooding.
++hardCapEvictions_;
if (hardCapEvictions_ == 1 || hardCapEvictions_ % 100000 == 0)
{
JLOG(journal_.warn()) << name_ << ": hard-cap eviction #" << hardCapEvictions_
<< " (cap " << cacheHardCap_ << ", strong " << cacheCount_
<< ") - cache saturated, growth now evicts";
}
}
}
}
template <
class Key,
class T,
@@ -360,11 +458,17 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (cit == cache_.end())
{
cache_.emplace(
std::piecewise_construct,
std::forward_as_tuple(key),
std::forward_as_tuple(clock_.now(), data));
auto const emplacedIt = cache_
.emplace(
std::piecewise_construct,
std::forward_as_tuple(key),
std::forward_as_tuple(clock_.now(), data))
.first;
++cacheCount_;
// The just-inserted entry is the newest; evictForHardCap skips it
// and drops the oldest in its partition.
if (cacheHardCap_ > 0 && cacheCount_ > cacheHardCap_)
evictForHardCap(*emplacedIt.ait, emplacedIt.mit);
return false;
}
@@ -415,11 +519,15 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
}
++cacheCount_;
if (cacheHardCap_ > 0 && cacheCount_ > cacheHardCap_)
evictForHardCap(*cit.ait, cit.mit);
return true;
}
entry.ptr = data;
++cacheCount_;
if (cacheHardCap_ > 0 && cacheCount_ > cacheHardCap_)
evictForHardCap(*cit.ait, cit.mit);
return false;
}
@@ -729,6 +837,8 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
{
// independent of cache size, so not counted as a hit
++cacheCount_;
if (cacheHardCap_ > 0 && cacheCount_ > cacheHardCap_)
evictForHardCap(*cit.ait, cit.mit);
entry.touch(clock_.now());
return entry.ptr.getStrong();
}

View File

@@ -26,7 +26,7 @@ public:
* @param journal Destination for logging output.
*/
static std::shared_ptr<StatsDCollector>
make(IP::Endpoint const& address, std::string const& prefix, Journal journal);
make(ip::Endpoint const& address, std::string const& prefix, Journal journal);
};
} // namespace beast::insight

View File

@@ -15,7 +15,7 @@
//------------------------------------------------------------------------------
namespace beast {
namespace IP {
namespace ip {
using Address = boost::asio::ip::address;
@@ -73,13 +73,13 @@ isPublic(Address const& addr)
return (addr.is_v4()) ? isPublic(addr.to_v4()) : isPublic(addr.to_v6());
}
} // namespace IP
} // namespace ip
//------------------------------------------------------------------------------
template <class Hasher>
void
hash_append(Hasher& h, beast::IP::Address const& addr) noexcept
hash_append(Hasher& h, beast::ip::Address const& addr) noexcept
{
using beast::hash_append;
if (addr.is_v4())
@@ -101,12 +101,12 @@ hash_append(Hasher& h, beast::IP::Address const& addr) noexcept
namespace boost {
template <>
struct hash<::beast::IP::Address>
struct hash<::beast::ip::Address>
{
explicit hash() = default;
std::size_t
operator()(::beast::IP::Address const& addr) const
operator()(::beast::ip::Address const& addr) const
{
return ::beast::Uhash<>{}(addr);
}

View File

@@ -4,7 +4,7 @@
#include <boost/asio.hpp>
namespace beast::IP {
namespace beast::ip {
/**
* Convert to Endpoint.
@@ -32,7 +32,7 @@ toAsioAddress(Endpoint const& endpoint);
boost::asio::ip::tcp::endpoint
toAsioEndpoint(Endpoint const& endpoint);
} // namespace beast::IP
} // namespace beast::ip
namespace beast {
@@ -41,25 +41,25 @@ struct IPAddressConversion
{
explicit IPAddressConversion() = default;
static IP::Endpoint
static ip::Endpoint
fromAsio(boost::asio::ip::address const& address)
{
return IP::fromAsio(address);
return ip::fromAsio(address);
}
static IP::Endpoint
static ip::Endpoint
fromAsio(boost::asio::ip::tcp::endpoint const& endpoint)
{
return IP::fromAsio(endpoint);
return ip::fromAsio(endpoint);
}
static boost::asio::ip::address
toAsioAddress(IP::Endpoint const& address)
toAsioAddress(ip::Endpoint const& address)
{
return IP::toAsioAddress(address);
return ip::toAsioAddress(address);
}
static boost::asio::ip::tcp::endpoint
toAsioEndpoint(IP::Endpoint const& address)
toAsioEndpoint(ip::Endpoint const& address)
{
return IP::toAsioEndpoint(address);
return ip::toAsioEndpoint(address);
}
};

View File

@@ -2,7 +2,7 @@
#include <boost/asio/ip/address_v4.hpp>
namespace beast::IP {
namespace beast::ip {
using AddressV4 = boost::asio::ip::address_v4;
@@ -25,4 +25,4 @@ isPublic(AddressV4 const& addr);
char
getClass(AddressV4 const& address);
} // namespace beast::IP
} // namespace beast::ip

View File

@@ -2,7 +2,7 @@
#include <boost/asio/ip/address_v6.hpp>
namespace beast::IP {
namespace beast::ip {
using AddressV6 = boost::asio::ip::address_v6;
@@ -18,4 +18,4 @@ isPrivate(AddressV6 const& addr);
bool
isPublic(AddressV6 const& addr);
} // namespace beast::IP
} // namespace beast::ip

View File

@@ -13,7 +13,7 @@
#include <optional>
#include <string>
namespace beast::IP {
namespace beast::ip {
using Port = std::uint16_t;
@@ -223,7 +223,7 @@ operator<<(OutputStream& os, Endpoint const& endpoint)
std::istream&
operator>>(std::istream& is, Endpoint& endpoint);
} // namespace beast::IP
} // namespace beast::ip
//------------------------------------------------------------------------------
@@ -232,12 +232,12 @@ namespace std {
* std::hash support.
*/
template <>
struct hash<::beast::IP::Endpoint>
struct hash<::beast::ip::Endpoint>
{
hash() = default;
std::size_t
operator()(::beast::IP::Endpoint const& endpoint) const
operator()(::beast::ip::Endpoint const& endpoint) const
{
return ::beast::Uhash<>{}(endpoint);
}
@@ -249,12 +249,12 @@ namespace boost {
* boost::hash support.
*/
template <>
struct hash<::beast::IP::Endpoint>
struct hash<::beast::ip::Endpoint>
{
hash() = default;
std::size_t
operator()(::beast::IP::Endpoint const& endpoint) const
operator()(::beast::ip::Endpoint const& endpoint) const
{
return ::beast::Uhash<>{}(endpoint);
}

View File

@@ -295,6 +295,20 @@ public:
return runner_->arg();
}
protected:
/**
* Lets a suite compose other suites (e.g. an aggregator that reruns a
* group of related suites under its own name) via `SuiteInfo::run`.
*
* @return The runner this suite is executing under.
*/
Runner&
runner() const
{
return *runner_;
}
public:
/**
* DEPRECATED
* @return `true` if the test condition indicates success(a false value)

View File

@@ -22,10 +22,13 @@ struct Sections
static constexpr auto kIoWorkers = "io_workers";
static constexpr auto kIps = "ips";
static constexpr auto kIpsFixed = "ips_fixed";
static constexpr auto kLedgerCacheAge = "ledger_cache_age";
static constexpr auto kLedgerFetchSize = "ledger_fetch_size";
static constexpr auto kLedgerHistory = "ledger_history";
static constexpr auto kLedgerReplay = "ledger_replay";
static constexpr auto kLedgerTxTables = "ledger_tx_tables";
static constexpr auto kMaxTransactions = "max_transactions";
static constexpr auto kMemoryLimit = "memory_limit";
static constexpr auto kNetworkId = "network_id";
static constexpr auto kNetworkQuorum = "network_quorum";
static constexpr auto kNodeDatabase = "node_db";
@@ -63,6 +66,7 @@ struct Sections
static constexpr auto kSslVerifyFile = "ssl_verify_file";
static constexpr auto kSweepInterval = "sweep_interval";
static constexpr auto kTransactionQueue = "transaction_queue";
static constexpr auto kTreeCacheAge = "tree_cache_age";
static constexpr auto kValidationSeed = "validation_seed";
static constexpr auto kValidatorKeys = "validator_keys";
static constexpr auto kValidatorKeyRevocation = "validator_key_revocation";

View File

@@ -18,9 +18,9 @@ namespace xrpl {
namespace node_store {
class Database;
} // namespace node_store
namespace Resource {
namespace resource {
class Manager;
} // namespace Resource
} // namespace resource
namespace perf {
class PerfLog;
} // namespace perf
@@ -160,7 +160,7 @@ public:
virtual PeerReservationTable&
getPeerReservations() = 0;
virtual Resource::Manager&
virtual resource::Manager&
getResourceManager() = 0;
// Storage services

View File

@@ -623,6 +623,7 @@ class ValueConstIterator : public ValueIteratorBase
public:
using size_t = unsigned int;
using difference_type = int;
using value_type = Value const;
using reference = Value const&;
using pointer = Value const*;
using SelfType = ValueConstIterator;
@@ -687,6 +688,7 @@ class ValueIterator : public ValueIteratorBase
public:
using size_t = unsigned int;
using difference_type = int;
using value_type = Value;
using reference = Value&;
using pointer = Value*;
using SelfType = ValueIterator;

View File

@@ -296,7 +296,7 @@ struct AccountingDeltas
// Whole-life (pre-LendingProtocolV1_1) recognition model: interest is
// recognized into AssetsTotal/DebtTotal up front, at origination.
namespace Accrual {
namespace accrual {
// LoanSet origination: what's added to Vault.AssetsTotal and LoanBroker.DebtTotal
AccountingDeltas
@@ -318,11 +318,11 @@ loanVaultExposure(SLE::const_ref loanSle);
AccountingDeltas
loanPaymentDeltas(LoanPaymentParts const& parts);
} // namespace Accrual
} // namespace accrual
// Cash-basis (LendingProtocolV1_1) recognition model: AssetsTotal/DebtTotal
// are principal-only, interest is recognized only as it's actually paid.
namespace CashBasis {
namespace cash_basis {
AccountingDeltas
loanOriginationDeltas(Number const& principalRequested);
@@ -333,11 +333,11 @@ loanVaultExposure(SLE::const_ref loanSle);
AccountingDeltas
loanPaymentDeltas(LoanPaymentParts const& parts);
} // namespace CashBasis
} // namespace cash_basis
// Public dispatchers: pick CashBasis:: if featureLendingProtocolV1_1 is
// Public dispatchers: pick cash_basis:: if featureLendingProtocolV1_1 is
// enabled AND the Vault's LEVersion (VaultHelpers::getVaultVersion) is
// VaultVersion::CashBasis, else Accrual::. These are the only entry points
// VaultVersion::CashBasis, else accrual::. These are the only entry points
// transactors call.
AccountingDeltas
loanOriginationDeltas(

View File

@@ -67,16 +67,16 @@ public:
return socket_->next_layer();
}
beast::IP::Endpoint
beast::ip::Endpoint
localEndpoint()
{
return beast::IP::fromAsio(lowestLayer().local_endpoint());
return beast::ip::fromAsio(lowestLayer().local_endpoint());
}
beast::IP::Endpoint
beast::ip::Endpoint
remoteEndpoint()
{
return beast::IP::fromAsio(lowestLayer().remote_endpoint());
return beast::ip::fromAsio(lowestLayer().remote_endpoint());
}
lowest_layer_type&

View File

@@ -9,7 +9,7 @@
#include <string>
#include <string_view>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
struct PeerLimitConfig
{
@@ -28,7 +28,7 @@ struct Config
* This includes both inbound and outbound, but does not include
* fixed peers.
*/
std::size_t maxPeers{Tuning::kDefaultMaxPeers};
std::size_t maxPeers{tuning::kDefaultMaxPeers};
/**
* The number of automatic outbound connections to maintain.
@@ -100,7 +100,7 @@ struct Config
onWrite(beast::PropertyStream::Map& map) const;
/**
* Make PeerFinder::Config from peer limit and server mode parameters.
* Make peer_finder::Config from peer limit and server mode parameters.
*/
static Config
makeConfig(
@@ -160,4 +160,4 @@ to_string(Result result) noexcept
return "unknown";
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -15,7 +15,7 @@
#include <utility>
#include <vector>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* Maintains a set of IP addresses used for getting into the network.
@@ -68,17 +68,17 @@ public:
* file, along with the set of corresponding IP addresses.
*/
virtual void
addFixedPeer(std::string_view name, std::vector<beast::IP::Endpoint> const& addresses) = 0;
addFixedPeer(std::string_view name, std::vector<beast::ip::Endpoint> const& addresses) = 0;
/**
* Add a set of strings as fallback IP::Endpoint sources.
* Add a set of strings as fallback ip::Endpoint sources.
* @param name A label used for diagnostics.
*/
virtual void
addFallbackStrings(std::string const& name, std::vector<std::string> const& strings) = 0;
/**
* Add a URL as a fallback location to obtain IP::Endpoint sources.
* Add a URL as a fallback location to obtain ip::Endpoint sources.
* @param name A label used for diagnostics.
*/
/* VFALCO NOTE Unimplemented
@@ -95,8 +95,8 @@ public:
*/
virtual std::pair<std::shared_ptr<Slot>, Result>
newInboundSlot(
beast::IP::Endpoint const& localEndpoint,
beast::IP::Endpoint const& remoteEndpoint) = 0;
beast::ip::Endpoint const& localEndpoint,
beast::ip::Endpoint const& remoteEndpoint) = 0;
/**
* Create a new outbound slot with the specified remote endpoint.
@@ -104,7 +104,7 @@ public:
* Usually this is because of a duplicate connection.
*/
virtual std::pair<std::shared_ptr<Slot>, Result>
newOutboundSlot(beast::IP::Endpoint const& remoteEndpoint) = 0;
newOutboundSlot(beast::ip::Endpoint const& remoteEndpoint) = 0;
/**
* Called when mtENDPOINTS is received.
@@ -145,7 +145,7 @@ public:
* @return `true` if the connection should be kept
*/
virtual bool
onConnected(std::shared_ptr<Slot> const& slot, beast::IP::Endpoint const& localEndpoint) = 0;
onConnected(std::shared_ptr<Slot> const& slot, beast::ip::Endpoint const& localEndpoint) = 0;
/**
* Request an active slot type.
@@ -162,7 +162,7 @@ public:
/**
* Return a set of addresses we should connect to.
*/
virtual std::vector<beast::IP::Endpoint>
virtual std::vector<beast::ip::Endpoint>
autoconnect() = 0;
virtual std::vector<std::pair<std::shared_ptr<Slot>, std::vector<Endpoint>>>
@@ -176,4 +176,4 @@ public:
oncePerSecond() = 0;
};
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -7,7 +7,7 @@
#include <memory>
#include <optional>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* Properties and state associated with a peer to peer overlay connection.
@@ -52,13 +52,13 @@ public:
/**
* The remote endpoint of socket.
*/
[[nodiscard]] virtual beast::IP::Endpoint const&
[[nodiscard]] virtual beast::ip::Endpoint const&
remoteEndpoint() const = 0;
/**
* The local endpoint of the socket, when known.
*/
[[nodiscard]] virtual std::optional<beast::IP::Endpoint> const&
[[nodiscard]] virtual std::optional<beast::ip::Endpoint> const&
localEndpoint() const = 0;
[[nodiscard]] virtual std::optional<std::uint16_t>
@@ -72,4 +72,4 @@ public:
publicKey() const = 0;
};
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -8,14 +8,14 @@
#include <cstdint>
#include <vector>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
using clock_type = beast::AbstractClock<std::chrono::steady_clock>;
/**
* Represents a set of addresses.
*/
using IPAddresses = std::vector<beast::IP::Endpoint>;
using IPAddresses = std::vector<beast::ip::Endpoint>;
//------------------------------------------------------------------------------
@@ -26,10 +26,10 @@ struct Endpoint
{
Endpoint() = default;
Endpoint(beast::IP::Endpoint ep, std::uint32_t hops);
Endpoint(beast::ip::Endpoint ep, std::uint32_t hops);
std::uint32_t hops = 0;
beast::IP::Endpoint address;
beast::ip::Endpoint address;
};
inline bool
@@ -43,4 +43,4 @@ operator<(Endpoint const& lhs, Endpoint const& rhs)
*/
using Endpoints = std::vector<Endpoint>;
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -14,7 +14,7 @@
#include <functional>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* Stores IP addresses useful for gaining initial connections.
@@ -65,7 +65,7 @@ private:
};
using left_t = boost::bimaps::
unordered_set_of<beast::IP::Endpoint, boost::hash<beast::IP::Endpoint>, std::equal_to<>>;
unordered_set_of<beast::ip::Endpoint, boost::hash<beast::ip::Endpoint>, std::equal_to<>>;
using right_t = boost::bimaps::multiset_of<Entry, std::less<>>;
using map_type = boost::bimap<left_t, right_t>;
using value_type = map_type::value_type;
@@ -73,11 +73,11 @@ private:
struct Transform
{
using first_argument_type = map_type::right_map::const_iterator::value_type const&;
using result_type = beast::IP::Endpoint const&;
using result_type = beast::ip::Endpoint const&;
explicit Transform() = default;
beast::IP::Endpoint const&
beast::ip::Endpoint const&
operator()(map_type::right_map::const_iterator::value_type const& v) const
{
return v.get_left();
@@ -121,7 +121,7 @@ public:
size() const;
/**
* IP::Endpoint iterators that traverse in decreasing valence.
* ip::Endpoint iterators that traverse in decreasing valence.
*/
/** @{ */
[[nodiscard]] const_iterator
@@ -146,25 +146,25 @@ public:
* Add a newly-learned address to the cache.
*/
bool
insert(beast::IP::Endpoint const& endpoint);
insert(beast::ip::Endpoint const& endpoint);
/**
* Add a staticallyconfigured address to the cache.
*/
bool
insertStatic(beast::IP::Endpoint const& endpoint);
insertStatic(beast::ip::Endpoint const& endpoint);
/**
* Called when an outbound connection handshake completes.
*/
void
onSuccess(beast::IP::Endpoint const& endpoint);
onSuccess(beast::ip::Endpoint const& endpoint);
/**
* Called when an outbound connection attempt fails to handshake.
*/
void
onFailure(beast::IP::Endpoint const& endpoint);
onFailure(beast::ip::Endpoint const& endpoint);
/**
* Stores the cache in the persistent database on a timer.
@@ -189,4 +189,4 @@ private:
flagForUpdate();
};
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -11,7 +11,7 @@
#include <memory>
#include <mutex>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* Tests remote listening sockets to make sure they are connectable.
@@ -104,7 +104,7 @@ public:
*/
template <class Handler>
void
asyncConnect(beast::IP::Endpoint const& endpoint, Handler&& handler);
asyncConnect(beast::ip::Endpoint const& endpoint, Handler&& handler);
private:
void
@@ -179,7 +179,7 @@ Checker<Protocol>::wait()
template <class Protocol>
template <class Handler>
void
Checker<Protocol>::asyncConnect(beast::IP::Endpoint const& endpoint, Handler&& handler)
Checker<Protocol>::asyncConnect(beast::ip::Endpoint const& endpoint, Handler&& handler)
{
auto const op =
std::make_shared<AsyncOp<Handler>>(*this, ioContext_, std::forward<Handler>(handler));
@@ -202,4 +202,4 @@ Checker<Protocol>::remove(BasicAsyncOp& op)
cond_.notify_all();
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -10,7 +10,7 @@
#include <sstream>
#include <string>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* Direction of a slot count adjustment.
@@ -50,7 +50,7 @@ public:
// Must be handshaked and in the right state
XRPL_ASSERT(
s.state() == Slot::State::Connected || s.state() == Slot::State::Accept,
"xrpl::PeerFinder::Counts::can_activate : valid input state");
"xrpl::peer_finder::Counts::can_activate : valid input state");
if (s.fixed() || s.reserved())
return true;
@@ -67,9 +67,9 @@ public:
[[nodiscard]] std::size_t
attemptsNeeded() const
{
if (attempts_ >= Tuning::kMaxConnectAttempts)
if (attempts_ >= tuning::kMaxConnectAttempts)
return 0;
return Tuning::kMaxConnectAttempts - attempts_;
return tuning::kMaxConnectAttempts - attempts_;
}
/**
@@ -295,7 +295,7 @@ private:
switch (s.state())
{
case Slot::State::Accept:
XRPL_ASSERT(s.inbound(), "xrpl::PeerFinder::Counts::adjust : input is inbound");
XRPL_ASSERT(s.inbound(), "xrpl::peer_finder::Counts::adjust : input is inbound");
acceptCount_ += n;
break;
@@ -303,7 +303,7 @@ private:
case Slot::State::Connected:
XRPL_ASSERT(
!s.inbound(),
"xrpl::PeerFinder::Counts::adjust : input is not "
"xrpl::peer_finder::Counts::adjust : input is not "
"inbound");
attempts_ += n;
break;
@@ -331,7 +331,7 @@ private:
// LCOV_EXCL_START
default:
UNREACHABLE("xrpl::PeerFinder::Counts::adjust : invalid input state");
UNREACHABLE("xrpl::peer_finder::Counts::adjust : invalid input state");
break;
// LCOV_EXCL_STOP
};
@@ -391,4 +391,4 @@ private:
int closingCount_{0};
};
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -7,7 +7,7 @@
#include <chrono>
#include <cstddef>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* Metadata for a Fixed slot.
@@ -36,8 +36,8 @@ public:
void
failure(clock_type::time_point const& now)
{
failures_ = std::min(failures_ + 1, Tuning::kConnectionBackoff.size() - 1);
when_ = now + std::chrono::minutes(Tuning::kConnectionBackoff[failures_]);
failures_ = std::min(failures_ + 1, tuning::kConnectionBackoff.size() - 1);
when_ = now + std::chrono::minutes(tuning::kConnectionBackoff[failures_]);
}
/**
@@ -55,4 +55,4 @@ private:
std::size_t failures_{0};
};
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -12,7 +12,7 @@
#include <utility>
#include <vector>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
namespace detail {
@@ -28,7 +28,7 @@ template <class Target, class HopContainer>
std::size_t
handoutOne(Target& t, HopContainer& h)
{
XRPL_ASSERT(!t.full(), "xrpl::PeerFinder::detail::handoutOne : target is not full");
XRPL_ASSERT(!t.full(), "xrpl::peer_finder::detail::handoutOne : target is not full");
for (auto it = h.begin(); it != h.end(); ++it)
{
auto const& e = *it;
@@ -95,7 +95,7 @@ public:
[[nodiscard]] bool
full() const
{
return list_.size() >= Tuning::kRedirectEndpointCount;
return list_.size() >= tuning::kRedirectEndpointCount;
}
[[nodiscard]] SlotImp::ptr const&
@@ -124,7 +124,7 @@ private:
template <class>
RedirectHandouts::RedirectHandouts(SlotImp::ptr slot) : slot_(std::move(slot))
{
list_.reserve(Tuning::kRedirectEndpointCount);
list_.reserve(tuning::kRedirectEndpointCount);
}
template <class>
@@ -138,7 +138,7 @@ RedirectHandouts::tryInsert(Endpoint const& ep)
// addresses in a peer HTTP handshake instead of
// the tmENDPOINTS message.
//
if (ep.hops > Tuning::kMaxHops)
if (ep.hops > tuning::kMaxHops)
return false;
// Don't send them our address
@@ -181,7 +181,7 @@ public:
[[nodiscard]] bool
full() const
{
return list_.size() >= Tuning::kNumberOfEndpoints;
return list_.size() >= tuning::kNumberOfEndpoints;
}
void
@@ -210,7 +210,7 @@ private:
template <class>
SlotHandouts::SlotHandouts(SlotImp::ptr slot) : slot_(std::move(slot))
{
list_.reserve(Tuning::kNumberOfEndpoints);
list_.reserve(tuning::kNumberOfEndpoints);
}
template <class>
@@ -220,7 +220,7 @@ SlotHandouts::tryInsert(Endpoint const& ep)
if (full())
return false;
if (ep.hops > Tuning::kMaxHops)
if (ep.hops > tuning::kMaxHops)
return false;
if (slot_->recent.filter(ep.address, ep.hops))
@@ -259,9 +259,9 @@ class ConnectHandouts
public:
// Keeps track of addresses we have made outgoing connections
// to, for the purposes of not connecting to them too frequently.
using Squelches = beast::aged_set<beast::IP::Address>;
using Squelches = beast::aged_set<beast::ip::Address>;
using list_type = std::vector<beast::IP::Endpoint>;
using list_type = std::vector<beast::ip::Endpoint>;
private:
std::size_t needed_;
@@ -274,7 +274,7 @@ public:
template <class = void>
bool
tryInsert(beast::IP::Endpoint const& endpoint);
tryInsert(beast::ip::Endpoint const& endpoint);
[[nodiscard]] bool
empty() const
@@ -316,13 +316,13 @@ ConnectHandouts::ConnectHandouts(std::size_t needed, Squelches& squelches)
template <class>
bool
ConnectHandouts::tryInsert(beast::IP::Endpoint const& endpoint)
ConnectHandouts::tryInsert(beast::ip::Endpoint const& endpoint)
{
if (full())
return false;
// Make sure the address isn't already in our list
if (std::ranges::any_of(list_, [&endpoint](beast::IP::Endpoint const& other) {
if (std::ranges::any_of(list_, [&endpoint](beast::ip::Endpoint const& other) {
// Ignore port for security reasons
return other.address() == endpoint.address();
}))
@@ -341,4 +341,4 @@ ConnectHandouts::tryInsert(beast::IP::Endpoint const& endpoint)
return true;
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -29,7 +29,7 @@
#include <utility>
#include <vector>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
template <class>
class Livecache;
@@ -188,10 +188,10 @@ class Livecache : protected detail::LivecacheBase
{
private:
using cache_type = beast::aged_map<
beast::IP::Endpoint,
beast::ip::Endpoint,
Element,
std::chrono::steady_clock,
std::less<beast::IP::Endpoint>,
std::less<beast::ip::Endpoint>,
Allocator>;
beast::Journal journal_;
@@ -220,8 +220,8 @@ public:
// but not given out (since they would exceed maxHops). They
// are used for automatic connection attempts.
//
using Histogram = std::array<int, 1 + Tuning::kMaxHops + 1>;
using lists_type = std::array<list_type, 1 + Tuning::kMaxHops + 1>;
using Histogram = std::array<int, 1 + tuning::kMaxHops + 1>;
using lists_type = std::array<list_type, 1 + tuning::kMaxHops + 1>;
template <bool IsConst>
struct Transform
@@ -400,7 +400,7 @@ Livecache<Allocator>::expire()
{
std::size_t n(0);
typename cache_type::time_point const expired(
cache_.clock().now() - Tuning::kLiveCacheSecondsToLive);
cache_.clock().now() - tuning::kLiveCacheSecondsToLive);
for (auto iter(cache_.chronological.begin());
iter != cache_.chronological.end() && iter.when() <= expired;)
{
@@ -427,8 +427,8 @@ Livecache<Allocator>::insert(Endpoint const& ep)
// when redirecting.
//
XRPL_ASSERT(
ep.hops <= (Tuning::kMaxHops + 1),
"xrpl::PeerFinder::Livecache::insert : maximum input hops");
ep.hops <= (tuning::kMaxHops + 1),
"xrpl::peer_finder::Livecache::insert : maximum input hops");
auto result = cache_.emplace(ep.address, ep);
Element& e(result.first->second);
if (result.second)
@@ -468,7 +468,7 @@ void
Livecache<Allocator>::onWrite(beast::PropertyStream::Map& map)
{
typename cache_type::time_point const expired(
cache_.clock().now() - Tuning::kLiveCacheSecondsToLive);
cache_.clock().now() - tuning::kLiveCacheSecondsToLive);
map["size"] = size();
map["hist"] = hops.histogram();
beast::PropertyStream::Set set("entries", map);
@@ -527,8 +527,8 @@ void
Livecache<Allocator>::HopsT::insert(Element& e)
{
XRPL_ASSERT(
e.endpoint.hops <= Tuning::kMaxHops + 1,
"xrpl::PeerFinder::Livecache::HopsT::insert : maximum input hops");
e.endpoint.hops <= tuning::kMaxHops + 1,
"xrpl::peer_finder::Livecache::HopsT::insert : maximum input hops");
// This has security implications without a shuffle
lists_[e.endpoint.hops].push_front(e);
++hist_[e.endpoint.hops];
@@ -539,8 +539,8 @@ void
Livecache<Allocator>::HopsT::reinsert(Element& e, std::uint32_t numHops)
{
XRPL_ASSERT(
numHops <= Tuning::kMaxHops + 1,
"xrpl::PeerFinder::Livecache::HopsT::reinsert : maximum hops input");
numHops <= tuning::kMaxHops + 1,
"xrpl::peer_finder::Livecache::HopsT::reinsert : maximum hops input");
auto& list = lists_[e.endpoint.hops];
list.erase(list.iterator_to(e));
@@ -561,4 +561,4 @@ Livecache<Allocator>::HopsT::remove(Element& e)
list.erase(list.iterator_to(e));
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -43,7 +43,7 @@
#include <utility>
#include <vector>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* The Logic for maintaining the list of Slot addresses.
@@ -57,7 +57,7 @@ public:
// Maps remote endpoints to slots. Since a slot has a
// remote endpoint upon construction, this holds all counts_.
//
using Slots = std::map<beast::IP::Endpoint, std::shared_ptr<SlotImp>>;
using Slots = std::map<beast::ip::Endpoint, std::shared_ptr<SlotImp>>;
beast::Journal journal;
clock_type& clock;
@@ -81,7 +81,7 @@ private:
Counts counts_;
// A list of slots that should always be connected
std::map<beast::IP::Endpoint, Fixed> fixed_;
std::map<beast::ip::Endpoint, Fixed> fixed_;
public:
// Live livecache from mtENDPOINTS messages
@@ -96,7 +96,7 @@ public:
// The addresses (but not port) we are connected to. This includes
// outgoing connection attempts. Note that this set can contain
// duplicates (since the port is not set)
std::multiset<beast::IP::Address> connectedAddresses;
std::multiset<beast::ip::Address> connectedAddresses;
// Set of public keys belonging to active peers
std::set<PublicKey> keys;
@@ -170,13 +170,13 @@ public:
}
void
addFixedPeer(std::string_view name, beast::IP::Endpoint const& ep)
addFixedPeer(std::string_view name, beast::ip::Endpoint const& ep)
{
addFixedPeer(name, std::vector<beast::IP::Endpoint>{ep});
addFixedPeer(name, std::vector<beast::ip::Endpoint>{ep});
}
void
addFixedPeer(std::string_view name, std::vector<beast::IP::Endpoint> const& addresses)
addFixedPeer(std::string_view name, std::vector<beast::ip::Endpoint> const& addresses)
{
std::scoped_lock const _(lock);
@@ -213,8 +213,8 @@ public:
// Called when the Checker completes a connectivity test
void
checkComplete(
beast::IP::Endpoint const& remoteAddress,
beast::IP::Endpoint const& checkedAddress,
beast::ip::Endpoint const& remoteAddress,
beast::ip::Endpoint const& checkedAddress,
boost::system::error_code ec)
{
if (ec == boost::asio::error::operation_aborted)
@@ -256,8 +256,8 @@ public:
std::pair<SlotImp::ptr, Result>
newInboundSlot(
beast::IP::Endpoint const& localEndpoint,
beast::IP::Endpoint const& remoteEndpoint)
beast::ip::Endpoint const& localEndpoint,
beast::ip::Endpoint const& remoteEndpoint)
{
JLOG(journal.debug()) << std::left << std::setw(18) << "Logic accept" << remoteEndpoint
<< " on local " << localEndpoint;
@@ -293,7 +293,7 @@ public:
// Remote address must not already exist
XRPL_ASSERT(
result.second,
"xrpl::PeerFinder::Logic::new_inbound_slot : remote endpoint "
"xrpl::peer_finder::Logic::new_inbound_slot : remote endpoint "
"inserted");
// Add to the connected address list
connectedAddresses.emplace(remoteEndpoint.address());
@@ -306,7 +306,7 @@ public:
// Can't check for self-connect because we don't know the local endpoint
std::pair<SlotImp::ptr, Result>
newOutboundSlot(beast::IP::Endpoint const& remoteEndpoint)
newOutboundSlot(beast::ip::Endpoint const& remoteEndpoint)
{
JLOG(journal.debug()) << std::left << std::setw(18) << "Logic connect " << remoteEndpoint;
@@ -329,7 +329,7 @@ public:
// Remote address must not already exist
XRPL_ASSERT(
result.second,
"xrpl::PeerFinder::Logic::new_outbound_slot : remote endpoint "
"xrpl::peer_finder::Logic::new_outbound_slot : remote endpoint "
"inserted");
// Add to the connected address list
@@ -342,7 +342,7 @@ public:
}
bool
onConnected(SlotImp::ptr const& slot, beast::IP::Endpoint const& localEndpoint)
onConnected(SlotImp::ptr const& slot, beast::ip::Endpoint const& localEndpoint)
{
beast::WrappedSink sink{journal.sink(), slot->prefix()};
beast::Journal const journal{sink};
@@ -354,7 +354,7 @@ public:
// The object must exist in our table
XRPL_ASSERT(
slots.contains(slot->remoteEndpoint()),
"xrpl::PeerFinder::Logic::onConnected : valid slot input");
"xrpl::peer_finder::Logic::onConnected : valid slot input");
// Assign the local endpoint now that it's known
slot->localEndpoint(localEndpoint);
@@ -365,7 +365,7 @@ public:
{
XRPL_ASSERT(
iter->second->localEndpoint() == slot->remoteEndpoint(),
"xrpl::PeerFinder::Logic::onConnected : local and remote "
"xrpl::peer_finder::Logic::onConnected : local and remote "
"endpoints do match");
JLOG(journal.warn()) << "Logic dropping as self connect";
return false;
@@ -393,11 +393,11 @@ public:
// The object must exist in our table
XRPL_ASSERT(
slots.contains(slot->remoteEndpoint()),
"xrpl::PeerFinder::Logic::activate : valid slot input");
"xrpl::peer_finder::Logic::activate : valid slot input");
// Must be accepted or connected
XRPL_ASSERT(
slot->state() == Slot::State::Accept || slot->state() == Slot::State::Connected,
"xrpl::PeerFinder::Logic::activate : valid slot state");
"xrpl::peer_finder::Logic::activate : valid slot state");
// Check for duplicate connection by key
if (keys.contains(key))
@@ -425,7 +425,7 @@ public:
{
[[maybe_unused]] bool const inserted = keys.insert(key).second;
// Public key must not already exist
XRPL_ASSERT(inserted, "xrpl::PeerFinder::Logic::activate : public key inserted");
XRPL_ASSERT(inserted, "xrpl::peer_finder::Logic::activate : public key inserted");
}
// Change state and update counts
@@ -443,7 +443,7 @@ public:
if (iter == fixed_.end())
{
logicError(
"PeerFinder::Logic::activate(): remote_endpoint "
"peer_finder::Logic::activate(): remote_endpoint "
"missing from fixed_");
}
@@ -476,10 +476,10 @@ public:
// VFALCO TODO This should add the returned addresses to the
// squelch list in one go once the list is built,
// rather than having each module add to the squelch list.
std::vector<beast::IP::Endpoint>
std::vector<beast::ip::Endpoint>
autoconnect()
{
std::vector<beast::IP::Endpoint> none;
std::vector<beast::ip::Endpoint> none;
std::scoped_lock const _(lock);
@@ -635,7 +635,7 @@ public:
// either. ipv6 has a slightly more compact string
// representation of 0, so use that for self entries.
ep.address =
beast::IP::Endpoint(beast::IP::AddressV6()).atPort(config_.listeningPort);
beast::ip::Endpoint(beast::ip::AddressV6()).atPort(config_.listeningPort);
for (auto& t : targets)
t.insert(ep);
}
@@ -656,7 +656,7 @@ public:
result.emplace_back(slot, list);
}
whenBroadcast = now + Tuning::kSecondsPerMessage;
whenBroadcast = now + tuning::kSecondsPerMessage;
}
return result;
@@ -675,7 +675,7 @@ public:
entry.second->expire();
// Expire the recent attempts table
beast::expire(squelches, Tuning::kRecentAttemptDuration);
beast::expire(squelches, tuning::kRecentAttemptDuration);
bootcache.periodicActivity();
}
@@ -692,7 +692,7 @@ public:
Endpoint& ep(*iter);
// Enforce hop limit
if (ep.hops > Tuning::kMaxHops)
if (ep.hops > tuning::kMaxHops)
{
JLOG(journal.debug()) << std::left << std::setw(18) << "Endpoints drop "
<< ep.address << " for excess hops " << ep.hops;
@@ -754,10 +754,10 @@ public:
beast::Journal const journal{sink};
// If we're sent too many endpoints, sample them at random:
if (list.size() > Tuning::kNumberOfEndpointsMax)
if (list.size() > tuning::kNumberOfEndpointsMax)
{
std::shuffle(list.begin(), list.end(), defaultPrng());
list.resize(Tuning::kNumberOfEndpointsMax);
list.resize(tuning::kNumberOfEndpointsMax);
}
JLOG(journal.trace()) << "Endpoints contained " << list.size()
@@ -768,12 +768,12 @@ public:
// The object must exist in our table
XRPL_ASSERT(
slots.contains(slot->remoteEndpoint()),
"xrpl::PeerFinder::Logic::onEndpoints : valid slot input");
"xrpl::peer_finder::Logic::onEndpoints : valid slot input");
// Must be handshaked!
XRPL_ASSERT(
slot->state() == Slot::State::Active,
"xrpl::PeerFinder::Logic::onEndpoints : valid slot state");
"xrpl::peer_finder::Logic::onEndpoints : valid slot state");
clock_type::time_point const now(clock.now());
@@ -785,7 +785,7 @@ public:
for (auto const& ep : list)
{
XRPL_ASSERT(ep.hops, "xrpl::PeerFinder::Logic::onEndpoints : nonzero hops");
XRPL_ASSERT(ep.hops, "xrpl::peer_finder::Logic::onEndpoints : nonzero hops");
slot->recent.insert(ep.address, ep.hops);
@@ -837,7 +837,7 @@ public:
bootcache.insert(ep.address);
}
slot->whenAcceptEndpoints = now + Tuning::kSecondsPerMessage;
slot->whenAcceptEndpoints = now + tuning::kSecondsPerMessage;
}
//--------------------------------------------------------------------------
@@ -851,7 +851,7 @@ public:
if (iter == slots.end())
{
logicError(
"PeerFinder::Logic::remove(): remote_endpoint "
"peer_finder::Logic::remove(): remote_endpoint "
"missing from slots_");
}
@@ -866,7 +866,7 @@ public:
if (iter == keys.end())
{
logicError(
"PeerFinder::Logic::remove(): public_key missing "
"peer_finder::Logic::remove(): public_key missing "
"from keys_");
}
@@ -879,7 +879,7 @@ public:
if (iter == connectedAddresses.end())
{
logicError(
"PeerFinder::Logic::remove(): remote_endpoint "
"peer_finder::Logic::remove(): remote_endpoint "
"address missing from connectedAddresses_");
}
@@ -907,7 +907,7 @@ public:
if (iter == fixed_.end())
{
logicError(
"PeerFinder::Logic::on_closed(): remote_endpoint "
"peer_finder::Logic::on_closed(): remote_endpoint "
"missing from fixed_");
}
@@ -943,7 +943,7 @@ public:
// LCOV_EXCL_START
default:
UNREACHABLE(
"xrpl::PeerFinder::Logic::on_closed : invalid slot "
"xrpl::peer_finder::Logic::on_closed : invalid slot "
"state");
break;
// LCOV_EXCL_STOP
@@ -968,17 +968,17 @@ public:
// Returns `true` if the address matches a fixed slot address
// Must have the lock held
bool
fixed(beast::IP::Endpoint const& endpoint) const
fixed(beast::ip::Endpoint const& endpoint) const
{
return std::ranges::any_of(
fixed_, [&endpoint](auto const& entry) { return entry.first == endpoint; });
}
// Returns `true` if the address matches a fixed slot address
// Note that this does not use the port information in the IP::Endpoint
// Note that this does not use the port information in the ip::Endpoint
// Must have the lock held
bool
fixed(beast::IP::Address const& address) const
fixed(beast::ip::Address const& address) const
{
return std::ranges::any_of(
fixed_, [&address](auto const& entry) { return entry.first.address() == address; });
@@ -1097,9 +1097,9 @@ public:
//
//--------------------------------------------------------------------------
// Returns true if the IP::Endpoint contains no invalid data.
// Returns true if the ip::Endpoint contains no invalid data.
bool
isValidAddress(beast::IP::Endpoint const& address)
isValidAddress(beast::ip::Endpoint const& address)
{
if (isUnspecified(address))
return false;
@@ -1220,7 +1220,7 @@ Logic<Checker>::onRedirects(
{
std::scoped_lock const _(lock);
std::size_t n = 0;
for (; first != last && n < Tuning::kMaxRedirects; ++first, ++n)
for (; first != last && n < tuning::kMaxRedirects; ++first, ++n)
bootcache.insert(beast::IPAddressConversion::fromAsio(*first));
if (n > 0)
{
@@ -1229,4 +1229,4 @@ Logic<Checker>::onRedirects(
}
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -12,7 +12,7 @@
#include <optional>
#include <string>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
class SlotImp : public Slot
{
@@ -21,13 +21,13 @@ public:
// inbound
SlotImp(
beast::IP::Endpoint const& localEndpoint,
beast::IP::Endpoint remoteEndpoint,
beast::ip::Endpoint const& localEndpoint,
beast::ip::Endpoint remoteEndpoint,
bool fixed,
clock_type& clock);
// outbound
SlotImp(beast::IP::Endpoint remoteEndpoint, bool fixed, clock_type& clock);
SlotImp(beast::ip::Endpoint remoteEndpoint, bool fixed, clock_type& clock);
bool
inbound() const override
@@ -53,13 +53,13 @@ public:
return state_;
}
beast::IP::Endpoint const&
beast::ip::Endpoint const&
remoteEndpoint() const override
{
return remoteEndpoint_;
}
std::optional<beast::IP::Endpoint> const&
std::optional<beast::ip::Endpoint> const&
localEndpoint() const override
{
return localEndpoint_;
@@ -93,13 +93,13 @@ public:
}
void
localEndpoint(beast::IP::Endpoint const& endpoint)
localEndpoint(beast::ip::Endpoint const& endpoint)
{
localEndpoint_ = endpoint;
}
void
remoteEndpoint(beast::IP::Endpoint const& endpoint)
remoteEndpoint(beast::ip::Endpoint const& endpoint)
{
remoteEndpoint_ = endpoint;
}
@@ -140,20 +140,20 @@ public:
* sending a slot the same address too frequently.
*/
void
insert(beast::IP::Endpoint const& ep, std::uint32_t hops);
insert(beast::ip::Endpoint const& ep, std::uint32_t hops);
/**
* Returns `true` if we should not send endpoint to the slot.
*/
bool
filter(beast::IP::Endpoint const& ep, std::uint32_t hops);
filter(beast::ip::Endpoint const& ep, std::uint32_t hops);
private:
void
expire();
friend class SlotImp;
beast::aged_unordered_map<beast::IP::Endpoint, std::uint32_t> cache_;
beast::aged_unordered_map<beast::ip::Endpoint, std::uint32_t> cache_;
} recent;
void
@@ -167,8 +167,8 @@ private:
bool const fixed_;
bool reserved_;
State state_;
beast::IP::Endpoint remoteEndpoint_;
std::optional<beast::IP::Endpoint> localEndpoint_;
beast::ip::Endpoint remoteEndpoint_;
std::optional<beast::ip::Endpoint> localEndpoint_;
std::optional<PublicKey> publicKey_;
static std::int32_t constexpr kUnknownPort = -1;
@@ -196,4 +196,4 @@ public:
clock_type::time_point whenAcceptEndpoints;
};
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -7,7 +7,7 @@
#include <string>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* A static or dynamic source of peer addresses.
@@ -46,4 +46,4 @@ public:
fetch(Results& results, beast::Journal journal) = 0;
};
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -6,7 +6,7 @@
#include <string>
#include <vector>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* Provides addresses from a static set of strings.
@@ -22,4 +22,4 @@ public:
make(std::string const& name, Strings const& strings);
};
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -6,7 +6,7 @@
#include <functional>
#include <vector>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* Abstract persistence for PeerFinder data.
@@ -17,7 +17,7 @@ public:
virtual ~Store() = default;
// load the bootstrap cache
using load_callback = std::function<void(beast::IP::Endpoint, int)>;
using load_callback = std::function<void(beast::ip::Endpoint, int)>;
virtual std::size_t
load(load_callback const& cb) = 0;
@@ -26,11 +26,11 @@ public:
{
explicit Entry() = default;
beast::IP::Endpoint endpoint;
beast::ip::Endpoint endpoint;
int valence{};
};
virtual void
save(std::vector<Entry> const& v) = 0;
};
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -9,7 +9,7 @@
* Heuristically tuned constants.
*/
/** @{ */
namespace xrpl::PeerFinder::Tuning {
namespace xrpl::peer_finder::tuning {
//---------------------------------------------------------
//
@@ -111,5 +111,5 @@ constexpr std::chrono::seconds kLiveCacheSecondsToLive(30);
// Note that we ignore the port for purposes of comparison.
constexpr std::chrono::seconds kRecentAttemptDuration(60);
} // namespace xrpl::PeerFinder::Tuning
} // namespace xrpl::peer_finder::tuning
/** @} */

View File

@@ -10,7 +10,7 @@
#include <memory>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
/**
* @brief Create a new Manager.
@@ -33,4 +33,4 @@ makeManager(
Store& store,
beast::insight::Collector::ptr const& collector);
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -33,7 +33,7 @@ namespace xrpl {
* Command line Requests use apiCommandLineVersion.
*/
namespace RPC {
namespace rpc {
template <unsigned int Version>
static constexpr std::integral_constant<unsigned, Version> kApiVersion = {};
@@ -60,7 +60,7 @@ static_assert(kApiMaximumValidVersion >= kApiMaximumSupportedVersion);
inline void
setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled)
{
XRPL_ASSERT(apiVersion != kApiInvalidVersion, "xrpl::RPC::setVersion : input is valid");
XRPL_ASSERT(apiVersion != kApiInvalidVersion, "xrpl::rpc::setVersion : input is valid");
auto& retObj = parent[jss::version] = json::ValueType::Object;
@@ -99,12 +99,12 @@ setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled)
inline unsigned int
getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
{
static json::Value const kMinVersion(RPC::kApiMinimumSupportedVersion);
static json::Value const kMinVersion(rpc::kApiMinimumSupportedVersion);
json::Value const maxVersion(
betaEnabled ? RPC::kApiBetaVersion : RPC::kApiMaximumSupportedVersion);
betaEnabled ? rpc::kApiBetaVersion : rpc::kApiMaximumSupportedVersion);
if (!jv.isObject() || !jv.isMember(jss::api_version))
return RPC::kApiVersionIfUnspecified;
return rpc::kApiVersionIfUnspecified;
try
{
@@ -113,33 +113,33 @@ getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
{
case json::ValueType::Int:
if (rawVersion.asInt() < 0)
return RPC::kApiInvalidVersion;
return rpc::kApiInvalidVersion;
[[fallthrough]];
case json::ValueType::UInt: {
auto const apiVersion = rawVersion.asUInt();
if (apiVersion < kMinVersion || apiVersion > maxVersion)
return RPC::kApiInvalidVersion;
return rpc::kApiInvalidVersion;
return apiVersion;
}
default:
return RPC::kApiInvalidVersion;
return rpc::kApiInvalidVersion;
}
}
catch (...)
{
return RPC::kApiInvalidVersion;
return rpc::kApiInvalidVersion;
}
}
} // namespace RPC
} // namespace rpc
template <unsigned MinVer, unsigned MaxVer, typename Fn, typename... Args>
void
forApiVersions(Fn const& fn, Args&&... args)
requires //
(MaxVer >= MinVer) && //
(MinVer >= RPC::kApiMinimumSupportedVersion) && //
(RPC::kApiMaximumValidVersion >= MaxVer) && requires {
(MinVer >= rpc::kApiMinimumSupportedVersion) && //
(rpc::kApiMaximumValidVersion >= MaxVer) && requires {
fn(std::integral_constant<unsigned int, MinVer>{}, std::forward<Args>(args)...);
fn(std::integral_constant<unsigned int, MaxVer>{}, std::forward<Args>(args)...);
}
@@ -158,11 +158,11 @@ template <typename Fn, typename... Args>
void
forAllApiVersions(Fn const& fn, Args&&... args)
requires requires {
forApiVersions<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>(
forApiVersions<rpc::kApiMinimumSupportedVersion, rpc::kApiMaximumValidVersion>(
fn, std::forward<Args>(args)...);
}
{
forApiVersions<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>(
forApiVersions<rpc::kApiMinimumSupportedVersion, rpc::kApiMaximumValidVersion>(
fn, std::forward<Args>(args)...);
}

View File

@@ -8,7 +8,7 @@
* Versioning information for this build.
*/
// VFALCO The namespace is deprecated
namespace xrpl::BuildInfo {
namespace xrpl::build_info {
/**
* Server version.
@@ -84,4 +84,4 @@ isXrpldVersion(std::uint64_t version);
bool
isNewerVersion(std::uint64_t version);
} // namespace xrpl::BuildInfo
} // namespace xrpl::build_info

View File

@@ -167,7 +167,7 @@ enum WarningCodeI {
// VFALCO NOTE these should probably not be in the RPC namespace.
namespace RPC {
namespace rpc {
/**
* Maps an rpc error code to its token, default message, and HTTP status.
@@ -337,7 +337,7 @@ containsError(json::Value const& json);
int
errorCodeHttpStatus(ErrorCodeI code);
} // namespace RPC
} // namespace rpc
/**
* Returns a single string with the contents of an RPC error.

View File

@@ -188,6 +188,6 @@ struct MultiApiJson
// Wrapper for Json for all supported API versions.
using MultiApiJson =
detail::MultiApiJson<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>;
detail::MultiApiJson<rpc::kApiMinimumSupportedVersion, rpc::kApiMaximumValidVersion>;
} // namespace xrpl

View File

@@ -6,7 +6,7 @@
#include <memory>
namespace xrpl::RPC {
namespace xrpl::rpc {
/**
* Adds common synthetic fields to transaction-related JSON responses
@@ -16,4 +16,4 @@ void
insertNFTSyntheticInJson(json::Value&, std::shared_ptr<STTx const> const&, TxMeta const&);
/** @} */
} // namespace xrpl::RPC
} // namespace xrpl::rpc

View File

@@ -139,7 +139,7 @@ tenthBipsOfValue(T value, TenthBips<TBips> bips)
return value * bips.value() / kTenthBipsPerUnity.value();
}
namespace Lending {
namespace lending {
/**
* The maximum management fee rate allowed by a loan broker in 1/10 bips.
*
@@ -236,7 +236,7 @@ static constexpr int kLoanPaymentsPerFeeIncrement = 5;
* without an amendment
*/
static constexpr int kLoanMaximumPaymentsPerTransaction = 100;
} // namespace Lending
} // namespace lending
/**
* The maximum length of a URI inside an NFT

View File

@@ -260,7 +260,7 @@ calcAccountID(PublicKey const& pk);
inline std::string
getFingerprint(
beast::IP::Endpoint const& address,
beast::ip::Endpoint const& address,
std::optional<PublicKey> const& publicKey = std::nullopt,
std::optional<std::string> const& id = std::nullopt)
{

View File

@@ -20,7 +20,7 @@
namespace xrpl {
namespace Attestations {
namespace attestations {
struct AttestationBase
{
@@ -227,7 +227,7 @@ struct CmpByCreateCount
}
};
}; // namespace Attestations
}; // namespace attestations
// Result when checking when two attestation match.
enum class AttestationMatch {
@@ -241,7 +241,7 @@ enum class AttestationMatch {
struct XChainClaimAttestation
{
using TSignedAttestation = Attestations::AttestationClaim;
using TSignedAttestation = attestations::AttestationClaim;
static SField const& arrayFieldName;
AccountID keyAccount;
@@ -297,7 +297,7 @@ struct XChainClaimAttestation
struct XChainCreateAccountAttestation
{
using TSignedAttestation = Attestations::AttestationCreateAccount;
using TSignedAttestation = attestations::AttestationCreateAccount;
static SField const& arrayFieldName;
AccountID keyAccount;

View File

@@ -395,6 +395,7 @@ JSS(mean); // out: get_aggregate_price
JSS(median); // out: get_aggregate_price
JSS(median_fee); // out: TxQ
JSS(median_level); // out: TxQ
JSS(memory_limit); // out: server_info
JSS(message); // error.
JSS(meta); // out: NetworkOPs, AccountTx*, Tx
JSS(meta_blob); // out: NetworkOPs, AccountTx*, Tx
@@ -435,7 +436,6 @@ JSS(node_read_retries); // out: GetCounts
JSS(node_reads_hit); // out: GetCounts
JSS(node_reads_total); // out: GetCounts
JSS(node_reads_duration_us); // out: GetCounts
JSS(node_size); // out: server_info
JSS(nodes); // out: VaultInfo
JSS(nodestore); // out: GetCounts
JSS(node_writes); // out: GetCounts

View File

@@ -4,7 +4,7 @@
#include <ostream>
#include <string>
namespace xrpl::Resource {
namespace xrpl::resource {
/**
* A consumption charge.
@@ -32,7 +32,7 @@ public:
label() const;
/**
* Return the cost of the charge in Resource::Manager units.
* Return the cost of the charge in resource::Manager units.
*/
[[nodiscard]] value_type
cost() const;
@@ -60,4 +60,4 @@ private:
std::ostream&
operator<<(std::ostream& os, Charge const& v);
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -8,7 +8,7 @@
#include <ostream>
#include <string>
namespace xrpl::Resource {
namespace xrpl::resource {
struct Entry;
class Logic;
@@ -96,4 +96,4 @@ private:
std::ostream&
operator<<(std::ostream& os, Consumer const& v);
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -1,6 +1,6 @@
#pragma once
namespace xrpl::Resource {
namespace xrpl::resource {
/**
* The disposition of a consumer after applying a load charge.
@@ -24,4 +24,4 @@ enum class Disposition {
Drop
};
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -2,7 +2,7 @@
#include <xrpl/resource/Charge.h>
namespace xrpl::Resource {
namespace xrpl::resource {
/**
* Schedule of fees charged for imposing load on the server.
@@ -31,4 +31,4 @@ extern Charge const kFeeWarning; // The cost of receiving a warning.
extern Charge const kFeeDrop; // The cost of being dropped for excess load.
/** @} */
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -4,7 +4,7 @@
#include <vector>
namespace xrpl::Resource {
namespace xrpl::resource {
/**
* Data format for exchanging consumption information across peers.
@@ -21,10 +21,10 @@ struct Gossip
explicit Item() = default;
int balance{};
beast::IP::Endpoint address;
beast::ip::Endpoint address;
};
std::vector<Item> items;
};
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -1,4 +1,4 @@
# Resource::Manager
# resource::Manager
The ResourceManager module has these responsibilities:
@@ -36,7 +36,7 @@ to the general public.
## Consumer Types
Consumers are placed into three classifications (as identified by the
Resource::Kind enumeration):
resource::Kind enumeration):
- InBound,
- OutBound, and
@@ -72,6 +72,6 @@ drop connections to those IP addresses that occur commonly in the gossip.
## Access
In xrpld, the Application holds a unique instance of Resource::Manager,
In xrpld, the Application holds a unique instance of resource::Manager,
which may be retrieved by calling the method
`Application::getResourceManager()`.

View File

@@ -14,7 +14,7 @@
#include <string>
#include <string_view>
namespace xrpl::Resource {
namespace xrpl::resource {
/**
* Tracks load and resource consumption.
@@ -32,10 +32,10 @@ public:
* IP if proxied.
*/
virtual Consumer
newInboundEndpoint(beast::IP::Endpoint const& address) = 0;
newInboundEndpoint(beast::ip::Endpoint const& address) = 0;
virtual Consumer
newInboundEndpoint(
beast::IP::Endpoint const& address,
beast::ip::Endpoint const& address,
bool const proxy,
std::string_view forwardedFor) = 0;
@@ -43,13 +43,13 @@ public:
* Create a new endpoint keyed by outbound IP address and port.
*/
virtual Consumer
newOutboundEndpoint(beast::IP::Endpoint const& address) = 0;
newOutboundEndpoint(beast::ip::Endpoint const& address) = 0;
/**
* Create a new unlimited endpoint keyed by forwarded IP.
*/
virtual Consumer
newUnlimitedEndpoint(beast::IP::Endpoint const& address) = 0;
newUnlimitedEndpoint(beast::ip::Endpoint const& address) = 0;
/**
* Extract packaged consumer information for export.
@@ -78,4 +78,4 @@ public:
std::unique_ptr<Manager>
makeManager(beast::insight::Collector::ptr const& collector, beast::Journal journal);
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -12,7 +12,7 @@
#include <ostream>
#include <string>
namespace xrpl::Resource {
namespace xrpl::resource {
using clock_type = beast::AbstractClock<std::chrono::steady_clock>;
@@ -91,4 +91,4 @@ operator<<(std::ostream& os, Entry const& v)
return os;
}
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -5,7 +5,7 @@
#include <vector>
namespace xrpl::Resource {
namespace xrpl::resource {
/**
* A set of imported consumer data from a gossip origin.
@@ -32,4 +32,4 @@ struct Import
std::vector<Item> items;
};
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -7,17 +7,17 @@
#include <cstddef>
#include <utility>
namespace xrpl::Resource {
namespace xrpl::resource {
// The consumer key
struct Key
{
Kind kind;
beast::IP::Endpoint address;
beast::ip::Endpoint address;
Key() = delete;
Key(Kind k, beast::IP::Endpoint addr) : kind(k), address(std::move(addr))
Key(Kind k, beast::ip::Endpoint addr) : kind(k), address(std::move(addr))
{
}
@@ -47,4 +47,4 @@ struct Key
};
};
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -1,6 +1,6 @@
#pragma once
namespace xrpl::Resource {
namespace xrpl::resource {
/**
* Kind of consumer.
@@ -12,4 +12,4 @@ namespace xrpl::Resource {
*/
enum class Kind { Inbound, Outbound, Unlimited };
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -24,7 +24,7 @@
#include <tuple>
#include <utility>
namespace xrpl::Resource {
namespace xrpl::resource {
class Logic
{
@@ -96,7 +96,7 @@ public:
}
Consumer
newInboundEndpoint(beast::IP::Endpoint const& address)
newInboundEndpoint(beast::ip::Endpoint const& address)
{
Entry* entry(nullptr);
@@ -126,7 +126,7 @@ public:
}
Consumer
newOutboundEndpoint(beast::IP::Endpoint const& address)
newOutboundEndpoint(beast::ip::Endpoint const& address)
{
Entry* entry(nullptr);
@@ -159,7 +159,7 @@ public:
* enabled.
*/
Consumer
newUnlimitedEndpoint(beast::IP::Endpoint const& address)
newUnlimitedEndpoint(beast::ip::Endpoint const& address)
{
Entry* entry(nullptr);
@@ -387,7 +387,7 @@ public:
{
std::scoped_lock const _(lock_);
Entry& entry(iter->second);
XRPL_ASSERT(entry.refcount == 0, "xrpl::Resource::Logic::erase : entry not used");
XRPL_ASSERT(entry.refcount == 0, "xrpl::resource::Logic::erase : entry not used");
inactive_.erase(inactive_.iteratorTo(entry));
table_.erase(iter);
}
@@ -421,7 +421,7 @@ public:
default:
// LCOV_EXCL_START
UNREACHABLE(
"xrpl::Resource::Logic::release : invalid entry "
"xrpl::resource::Logic::release : invalid entry "
"kind");
break;
// LCOV_EXCL_STOP
@@ -440,7 +440,7 @@ public:
static_assert(
kFeeLogAsWarn > kFeeLogAsInfo && kFeeLogAsInfo > kFeeLogAsDebug && kFeeLogAsDebug > 10);
static auto kGetStream = [](Resource::Charge::value_type cost, beast::Journal& journal) {
static auto kGetStream = [](resource::Charge::value_type cost, beast::Journal& journal) {
if (cost >= kFeeLogAsWarn)
return journal.warn();
if (cost >= kFeeLogAsInfo)
@@ -564,4 +564,4 @@ public:
}
};
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -2,7 +2,7 @@
#include <chrono>
namespace xrpl::Resource {
namespace xrpl::resource {
/**
* Tunable constants.
@@ -26,4 +26,4 @@ static constexpr std::chrono::seconds kSecondsUntilExpiration{300};
// Number of seconds until imported gossip expires
static constexpr std::chrono::seconds kGossipExpirationSeconds{30};
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -62,7 +62,7 @@ public:
using ref = std::shared_ptr<InfoSub> const&;
using Consumer = Resource::Consumer;
using Consumer = resource::Consumer;
public:
/**

View File

@@ -52,7 +52,7 @@ public:
/**
* Returns the remote address of the connection.
*/
virtual beast::IP::Endpoint
virtual beast::ip::Endpoint
remoteAddress() = 0;
/**

View File

@@ -157,7 +157,7 @@ protected:
return port_;
}
beast::IP::Endpoint
beast::ip::Endpoint
remoteAddress() override
{
return beast::IPAddressConversion::fromAsio(remoteAddress_);

View File

@@ -196,7 +196,7 @@ BaseWSPeer<Handler, Impl>::run()
startTimer();
closeOnTimer_ = true;
impl().ws_.set_option(boost::beast::websocket::stream_base::decorator([](auto& res) {
res.set(boost::beast::http::field::server, BuildInfo::getFullVersionString());
res.set(boost::beast::http::field::server, build_info::getFullVersionString());
}));
impl().ws_.async_accept(
request_, bind_executor(strand_, [self = impl().shared_from_this()](error_code const& ec) {

View File

@@ -102,6 +102,10 @@ undefined:nudb
# Snappy compression library intentional overflows
unsigned-integer-overflow:snappy.cc
# fast_float parses floats with a SWAR trick (parse_eight_digits_unrolled) that
# multiplies eight packed digits modulo 2^64; the wraparound is by design.
unsigned-integer-overflow:fast_float
# Abseil intentional overflows in hashing, RNG and time arithmetic.
# Matched at library scope (like boost above): the wraparound is by design
# across many absl files (hash mixing, raw_hash_set probing, duration math,
@@ -194,7 +198,7 @@ unsigned-integer-overflow:tests/libxrpl/basics/RangeSet.cpp
unsigned-integer-overflow:test/app/Batch_test.cpp
unsigned-integer-overflow:test/app/ConfidentialTransfer_test.cpp
unsigned-integer-overflow:test/app/Invariants_test.cpp
unsigned-integer-overflow:test/app/Loan_test.cpp
unsigned-integer-overflow:test/app/lending/LoanSecurity_test.cpp
unsigned-integer-overflow:test/app/NFToken_test.cpp
unsigned-integer-overflow:test/app/OfferMPT_test.cpp
unsigned-integer-overflow:test/app/Offer_test.cpp

View File

@@ -255,7 +255,7 @@ public:
if (ec == boost::asio::error::operation_aborted)
return;
std::vector<beast::IP::Endpoint> addresses;
std::vector<beast::ip::Endpoint> addresses;
auto iter = results.begin();
// If we get an error message back, we don't return any
@@ -283,7 +283,7 @@ public:
// first attempt to parse as an endpoint (IP addr + port).
// If that doesn't succeed, fall back to generic name + port parsing
if (auto const result = beast::IP::Endpoint::fromStringChecked(str))
if (auto const result = beast::ip::Endpoint::fromStringChecked(str))
{
return make_pair(result->address().to_string(), std::to_string(result->port()));
}

View File

@@ -74,7 +74,7 @@ parseUrl(ParsedUrl& pUrl, std::string const& strUrl)
// We need to use Endpoint to parse the domain to
// strip surrounding brackets from IPv6 addresses,
// e.g. [::1] => ::1.
auto const result = beast::IP::Endpoint::fromStringChecked(domain);
auto const result = beast::ip::Endpoint::fromStringChecked(domain);
pUrl.domain = result ? result->address().to_string() : domain;
std::string const port = smMatch[5];
if (!port.empty())

View File

@@ -207,7 +207,7 @@ private:
static constexpr auto kMaxPacketSize = 1472;
Journal journal_;
IP::Endpoint address_;
ip::Endpoint address_;
std::string prefix_;
boost::asio::io_context ioContext_;
std::optional<boost::asio::executor_work_guard<boost::asio::io_context::executor_type>> work_;
@@ -222,13 +222,13 @@ private:
std::thread thread_;
static boost::asio::ip::udp::endpoint
toEndpoint(IP::Endpoint const& ep)
toEndpoint(ip::Endpoint const& ep)
{
return boost::asio::ip::udp::endpoint(ep.address(), ep.port());
}
public:
StatsDCollectorImp(IP::Endpoint address, std::string prefix, Journal journal)
StatsDCollectorImp(ip::Endpoint address, std::string prefix, Journal journal)
: journal_(journal)
, address_(std::move(address))
, prefix_(std::move(prefix))
@@ -707,7 +707,7 @@ StatsDMeterImpl::doProcess()
//------------------------------------------------------------------------------
std::shared_ptr<StatsDCollector>
StatsDCollector::make(IP::Endpoint const& address, std::string const& prefix, Journal journal)
StatsDCollector::make(ip::Endpoint const& address, std::string const& prefix, Journal journal)
{
return std::make_shared<detail::StatsDCollectorImp>(address, prefix, journal);
}

View File

@@ -5,7 +5,7 @@
#include <boost/asio/ip/address.hpp>
#include <boost/asio/ip/tcp.hpp>
namespace beast::IP {
namespace beast::ip {
Endpoint
fromAsio(boost::asio::ip::address const& address)
@@ -31,4 +31,4 @@ toAsioEndpoint(Endpoint const& endpoint)
return boost::asio::ip::tcp::endpoint{endpoint.address(), endpoint.port()};
}
} // namespace beast::IP
} // namespace beast::ip

View File

@@ -1,6 +1,6 @@
#include <xrpl/beast/net/IPAddressV4.h>
namespace beast::IP {
namespace beast::ip {
bool
isPrivate(AddressV4 const& addr)
@@ -62,4 +62,4 @@ getClass(AddressV4 const& addr)
return kTable[(addr.to_uint() & 0xE0000000) >> 29];
}
} // namespace beast::IP
} // namespace beast::ip

View File

@@ -4,7 +4,7 @@
#include <boost/asio/ip/address_v6.hpp>
namespace beast::IP {
namespace beast::ip {
bool
isPrivate(AddressV6 const& addr)
@@ -58,4 +58,4 @@ isPublic(AddressV6 const& addr)
return true;
}
} // namespace beast::IP
} // namespace beast::ip

View File

@@ -14,7 +14,7 @@
#include <string>
#include <utility>
namespace beast::IP {
namespace beast::ip {
Endpoint::Endpoint() : port_(0)
{
@@ -176,4 +176,4 @@ operator>>(std::istream& is, Endpoint& endpoint)
return is;
}
} // namespace beast::IP
} // namespace beast::ip

View File

@@ -3,9 +3,11 @@
#include <xrpl/basics/contract.h>
#include <xrpl/json/json_value.h>
#include <fast_float/fast_float.h> // IWYU pragma: keep
#include <fast_float/parse_number.h>
#include <algorithm>
#include <cctype>
#include <charconv>
#include <cstdint>
#include <cstdio>
#include <istream>
@@ -605,8 +607,14 @@ Reader::decodeNumber(Token& token)
bool
Reader::decodeDouble(Token& token)
{
// Sanity check to avoid buffer overflow exploits.
if (token.end < token.start)
{
return addError("Unable to parse token length", token);
}
double value = 0;
auto const [ptr, ec] = std::from_chars(token.start, token.end, value);
auto const [ptr, ec] = fast_float::from_chars(token.start, token.end, value);
// Reject anything from_chars could not turn into a finite double:
// - ec != std::errc{}: no valid conversion, or an out-of-range magnitude

View File

@@ -131,7 +131,7 @@ isRounded(Asset const& asset, Number const& value, std::int32_t scale)
roundToAsset(asset, value, scale, Number::RoundingMode::Upward);
}
namespace Accrual {
namespace accrual {
AccountingDeltas
loanOriginationDeltas(Number const& principalRequested, Number const& interestDue)
@@ -169,9 +169,9 @@ loanPaymentDeltas(LoanPaymentParts const& parts)
.debtTotalDelta = (parts.principalPaid + parts.interestPaid) - parts.valueChange};
}
} // namespace Accrual
} // namespace accrual
namespace CashBasis {
namespace cash_basis {
AccountingDeltas
loanOriginationDeltas(Number const& principalRequested)
@@ -196,7 +196,7 @@ loanPaymentDeltas(LoanPaymentParts const& parts)
return {.assetsTotalDelta = parts.interestPaid, .debtTotalDelta = parts.principalPaid};
}
} // namespace CashBasis
} // namespace cash_basis
namespace {
@@ -219,8 +219,8 @@ loanOriginationDeltas(
Number const& interestDue)
{
return cashBasisEnabled(vaultSle)
? CashBasis::loanOriginationDeltas(principalRequested)
: Accrual::loanOriginationDeltas(principalRequested, interestDue);
? cash_basis::loanOriginationDeltas(principalRequested)
: accrual::loanOriginationDeltas(principalRequested, interestDue);
}
bool
@@ -235,21 +235,21 @@ loanOriginationExceedsVaultMaximum(
return false;
auto const vaultMaximum = vaultSle->at(sfAssetsMaximum);
return Accrual::loanOriginationExceedsVaultMaximum(vaultMaximum, vaultTotal, interestDue);
return accrual::loanOriginationExceedsVaultMaximum(vaultMaximum, vaultTotal, interestDue);
}
Number
loanVaultExposure(SLE::const_ref vaultSle, SLE::const_ref loanSle)
{
return cashBasisEnabled(vaultSle) ? CashBasis::loanVaultExposure(loanSle)
: Accrual::loanVaultExposure(loanSle);
return cashBasisEnabled(vaultSle) ? cash_basis::loanVaultExposure(loanSle)
: accrual::loanVaultExposure(loanSle);
}
AccountingDeltas
loanPaymentDeltas(SLE::const_ref vaultSle, LoanPaymentParts const& parts)
{
return cashBasisEnabled(vaultSle) ? CashBasis::loanPaymentDeltas(parts)
: Accrual::loanPaymentDeltas(parts);
return cashBasisEnabled(vaultSle) ? cash_basis::loanPaymentDeltas(parts)
: accrual::loanPaymentDeltas(parts);
}
namespace detail {
@@ -1617,7 +1617,7 @@ makeRegularPayment(
LoanPaymentType const paymentType,
beast::Journal j)
{
using namespace Lending;
using namespace lending;
XRPL_ASSERT_PARTS(
paymentType == LoanPaymentType::Regular || paymentType == LoanPaymentType::Overpayment,

View File

@@ -16,7 +16,7 @@
#include <ios>
#include <vector>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
Bootcache::Bootcache(Store& store, clock_type& clock, beast::Journal journal)
: store_(store), clock_(clock), journal_(journal), whenUpdate_(clock_.now())
@@ -78,7 +78,7 @@ void
Bootcache::load()
{
clear();
auto const n(store_.load([this](beast::IP::Endpoint const& endpoint, int valence) {
auto const n(store_.load([this](beast::ip::Endpoint const& endpoint, int valence) {
auto const result(this->map_.insert(value_type(endpoint, valence)));
if (!result.second)
{
@@ -96,7 +96,7 @@ Bootcache::load()
}
bool
Bootcache::insert(beast::IP::Endpoint const& endpoint)
Bootcache::insert(beast::ip::Endpoint const& endpoint)
{
auto const result(map_.insert(value_type(endpoint, 0)));
if (result.second)
@@ -109,7 +109,7 @@ Bootcache::insert(beast::IP::Endpoint const& endpoint)
}
bool
Bootcache::insertStatic(beast::IP::Endpoint const& endpoint)
Bootcache::insertStatic(beast::ip::Endpoint const& endpoint)
{
auto result(map_.insert(value_type(endpoint, kStaticValence)));
@@ -130,7 +130,7 @@ Bootcache::insertStatic(beast::IP::Endpoint const& endpoint)
}
void
Bootcache::onSuccess(beast::IP::Endpoint const& endpoint)
Bootcache::onSuccess(beast::ip::Endpoint const& endpoint)
{
auto result(map_.insert(value_type(endpoint, 1)));
if (result.second)
@@ -144,7 +144,7 @@ Bootcache::onSuccess(beast::IP::Endpoint const& endpoint)
++entry.valence();
map_.erase(result.first);
result = map_.insert(value_type(endpoint, entry));
XRPL_ASSERT(result.second, "xrpl::PeerFinder::Bootcache::onSuccess : endpoint inserted");
XRPL_ASSERT(result.second, "xrpl::peer_finder::Bootcache::onSuccess : endpoint inserted");
}
Entry const& entry(result.first->right);
JLOG(journal_.info()) << std::left << std::setw(18) << "Bootcache connect " << endpoint
@@ -154,7 +154,7 @@ Bootcache::onSuccess(beast::IP::Endpoint const& endpoint)
}
void
Bootcache::onFailure(beast::IP::Endpoint const& endpoint)
Bootcache::onFailure(beast::ip::Endpoint const& endpoint)
{
auto result(map_.insert(value_type(endpoint, -1)));
if (result.second)
@@ -168,7 +168,7 @@ Bootcache::onFailure(beast::IP::Endpoint const& endpoint)
--entry.valence();
map_.erase(result.first);
result = map_.insert(value_type(endpoint, entry));
XRPL_ASSERT(result.second, "xrpl::PeerFinder::Bootcache::onFailure : endpoint inserted");
XRPL_ASSERT(result.second, "xrpl::peer_finder::Bootcache::onFailure : endpoint inserted");
}
Entry const& entry(result.first->right);
auto const n(std::abs(entry.valence()));
@@ -201,11 +201,11 @@ Bootcache::onWrite(beast::PropertyStream::Map& map)
void
Bootcache::prune()
{
if (size() <= Tuning::kBootcacheSize)
if (size() <= tuning::kBootcacheSize)
return;
// Calculate the amount to remove
auto count((size() * Tuning::kBootcachePrunePercent) / 100);
auto count((size() * tuning::kBootcachePrunePercent) / 100);
decltype(count) pruned(0);
// Work backwards because bimap doesn't handle
@@ -215,7 +215,7 @@ Bootcache::prune()
{
--count;
--iter;
beast::IP::Endpoint const& endpoint(iter->get_left());
beast::ip::Endpoint const& endpoint(iter->get_left());
Entry const& entry(iter->get_right());
JLOG(journal_.trace()) << std::left << std::setw(18) << "Bootcache pruned" << endpoint
<< " at valence " << entry.valence();
@@ -244,7 +244,7 @@ Bootcache::update()
store_.save(list);
// Reset the flag and cooldown timer
needsUpdate_ = false;
whenUpdate_ = clock_.now() + Tuning::kBootcacheCooldownTime;
whenUpdate_ = clock_.now() + tuning::kBootcacheCooldownTime;
}
// Checks the clock and calls update if we are off the cooldown.
@@ -263,4 +263,4 @@ Bootcache::flagForUpdate()
checkUpdate();
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -7,13 +7,13 @@
#include <cstdint>
#include <stdexcept>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
std::size_t
Config::calcOutPeers() const
{
return std::max(
((maxPeers * Tuning::kOutPercent) + 50) / 100, std::size_t(Tuning::kMinOutCount));
((maxPeers * tuning::kOutPercent) + 50) / 100, std::size_t(tuning::kMinOutCount));
}
void
@@ -26,8 +26,8 @@ Config::applyTuning()
// IP addresses.
ipLimit = 2;
if (inPeers > Tuning::kDefaultMaxPeers)
ipLimit += std::min(5, static_cast<int>(inPeers / Tuning::kDefaultMaxPeers));
if (inPeers > tuning::kDefaultMaxPeers)
ipLimit += std::min(5, static_cast<int>(inPeers / tuning::kDefaultMaxPeers));
}
// We don't allow a single IP to consume all incoming slots,
@@ -58,7 +58,7 @@ Config::makeConfig(
int ipLimit,
bool verifyEndpoints)
{
PeerFinder::Config config;
peer_finder::Config config;
if (!limits.maxPeers)
{
@@ -85,7 +85,7 @@ Config::makeConfig(
if (limits.maxPeers && *limits.maxPeers != 0)
config.maxPeers = *limits.maxPeers;
config.maxPeers = std::max<std::size_t>(config.maxPeers, Tuning::kMinOutCount);
config.maxPeers = std::max<std::size_t>(config.maxPeers, tuning::kMinOutCount);
config.outPeers = config.calcOutPeers();
// Calculate the number of outbound peers we want. If we dont want
@@ -132,4 +132,4 @@ Config::makeConfig(
return config;
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -5,11 +5,11 @@
#include <cstdint>
#include <utility>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
Endpoint::Endpoint(beast::IP::Endpoint ep, std::uint32_t hops)
: hops(std::min(hops, Tuning::kMaxHops + 1)), address(std::move(ep))
Endpoint::Endpoint(beast::ip::Endpoint ep, std::uint32_t hops)
: hops(std::min(hops, tuning::kMaxHops + 1)), address(std::move(ep))
{
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -29,7 +29,7 @@
#include <utility>
#include <vector>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
class ManagerImp : public Manager
{
@@ -98,7 +98,7 @@ public:
}
void
addFixedPeer(std::string_view name, std::vector<beast::IP::Endpoint> const& addresses) override
addFixedPeer(std::string_view name, std::vector<beast::ip::Endpoint> const& addresses) override
{
logic_.addFixedPeer(name, addresses);
}
@@ -119,14 +119,14 @@ public:
std::pair<std::shared_ptr<Slot>, Result>
newInboundSlot(
beast::IP::Endpoint const& localEndpoint,
beast::IP::Endpoint const& remoteEndpoint) override
beast::ip::Endpoint const& localEndpoint,
beast::ip::Endpoint const& remoteEndpoint) override
{
return logic_.newInboundSlot(localEndpoint, remoteEndpoint);
}
std::pair<std::shared_ptr<Slot>, Result>
newOutboundSlot(beast::IP::Endpoint const& remoteEndpoint) override
newOutboundSlot(beast::ip::Endpoint const& remoteEndpoint) override
{
return logic_.newOutboundSlot(remoteEndpoint);
}
@@ -163,7 +163,7 @@ public:
//--------------------------------------------------------------------------
bool
onConnected(std::shared_ptr<Slot> const& slot, beast::IP::Endpoint const& localEndpoint)
onConnected(std::shared_ptr<Slot> const& slot, beast::ip::Endpoint const& localEndpoint)
override
{
SlotImp::ptr const impl(std::dynamic_pointer_cast<SlotImp>(slot));
@@ -184,7 +184,7 @@ public:
return logic_.redirect(impl);
}
std::vector<beast::IP::Endpoint>
std::vector<beast::ip::Endpoint>
autoconnect() override
{
return logic_.autoconnect();
@@ -265,4 +265,4 @@ makeManager(
return std::make_unique<ManagerImp>(ioContext, clock, journal, store, collector);
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -9,11 +9,11 @@
#include <cstdint>
#include <utility>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
SlotImp::SlotImp(
beast::IP::Endpoint const& localEndpoint,
beast::IP::Endpoint remoteEndpoint,
beast::ip::Endpoint const& localEndpoint,
beast::ip::Endpoint remoteEndpoint,
bool fixed,
clock_type& clock)
: recent(clock)
@@ -30,7 +30,7 @@ SlotImp::SlotImp(
{
}
SlotImp::SlotImp(beast::IP::Endpoint remoteEndpoint, bool fixed, clock_type& clock)
SlotImp::SlotImp(beast::ip::Endpoint remoteEndpoint, bool fixed, clock_type& clock)
: recent(clock)
, inbound_(false)
, fixed_(fixed)
@@ -49,29 +49,29 @@ SlotImp::state(State state)
{
// Must go through activate() to set active state
XRPL_ASSERT(
state != State::Active, "xrpl::PeerFinder::SlotImp::state : input state is not active");
state != State::Active, "xrpl::peer_finder::SlotImp::state : input state is not active");
// The state must be different
XRPL_ASSERT(
state_ != state,
"xrpl::PeerFinder::SlotImp::state : input state is different from "
"xrpl::peer_finder::SlotImp::state : input state is different from "
"current");
// You can't transition into the initial states
XRPL_ASSERT(
state != State::Accept && state != State::Connect,
"xrpl::PeerFinder::SlotImp::state : input state is not an initial");
"xrpl::peer_finder::SlotImp::state : input state is not an initial");
// Can only become connected from outbound connect state
XRPL_ASSERT(
state != State::Connected || (!inbound_ && state_ == State::Connect),
"xrpl::PeerFinder::SlotImp::state : input state is not connected an "
"xrpl::peer_finder::SlotImp::state : input state is not connected an "
"invalid state");
// Can't gracefully close on an outbound connection attempt
XRPL_ASSERT(
state != State::Closing || state_ != State::Connect,
"xrpl::PeerFinder::SlotImp::state : input state is not closing an "
"xrpl::peer_finder::SlotImp::state : input state is not closing an "
"invalid state");
state_ = state;
@@ -83,7 +83,7 @@ SlotImp::activate(clock_type::time_point const& now)
// Can only become active from the accept or connected state
XRPL_ASSERT(
state_ == State::Accept || state_ == State::Connected,
"xrpl::PeerFinder::SlotImp::activate : valid state");
"xrpl::peer_finder::SlotImp::activate : valid state");
state_ = State::Active;
whenAcceptEndpoints = now;
@@ -100,7 +100,7 @@ SlotImp::RecentT::RecentT(clock_type& clock) : cache_(clock)
}
void
SlotImp::RecentT::insert(beast::IP::Endpoint const& ep, std::uint32_t hops)
SlotImp::RecentT::insert(beast::ip::Endpoint const& ep, std::uint32_t hops)
{
auto const result(cache_.emplace(ep, hops));
if (!result.second)
@@ -115,7 +115,7 @@ SlotImp::RecentT::insert(beast::IP::Endpoint const& ep, std::uint32_t hops)
}
bool
SlotImp::RecentT::filter(beast::IP::Endpoint const& ep, std::uint32_t hops)
SlotImp::RecentT::filter(beast::ip::Endpoint const& ep, std::uint32_t hops)
{
auto const iter(cache_.find(ep));
if (iter == cache_.end())
@@ -129,7 +129,7 @@ SlotImp::RecentT::filter(beast::IP::Endpoint const& ep, std::uint32_t hops)
void
SlotImp::RecentT::expire()
{
beast::expire(cache_, Tuning::kLiveCacheSecondsToLive);
beast::expire(cache_, tuning::kLiveCacheSecondsToLive);
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -8,7 +8,7 @@
#include <string>
#include <utility>
namespace xrpl::PeerFinder {
namespace xrpl::peer_finder {
class SourceStringsImp : public SourceStrings
{
@@ -33,9 +33,9 @@ public:
results.addresses.reserve(strings_.size());
for (auto const& str : strings_)
{
beast::IP::Endpoint ep(beast::IP::Endpoint::fromString(str));
beast::ip::Endpoint ep(beast::ip::Endpoint::fromString(str));
if (isUnspecified(ep))
ep = beast::IP::Endpoint::fromString(str);
ep = beast::ip::Endpoint::fromString(str);
if (!isUnspecified(ep))
results.addresses.push_back(ep);
}
@@ -54,4 +54,4 @@ SourceStrings::make(std::string const& name, Strings const& strings)
return std::make_shared<SourceStringsImp>(name, strings);
}
} // namespace xrpl::PeerFinder
} // namespace xrpl::peer_finder

View File

@@ -13,7 +13,7 @@
#include <string>
#include <string_view>
namespace xrpl::BuildInfo {
namespace xrpl::build_info {
namespace {
@@ -173,4 +173,4 @@ isNewerVersion(std::uint64_t version)
return false;
}
} // namespace xrpl::BuildInfo
} // namespace xrpl::build_info

View File

@@ -9,7 +9,7 @@
#include <string>
namespace xrpl {
namespace RPC {
namespace rpc {
namespace detail {
@@ -215,12 +215,12 @@ errorCodeHttpStatus(ErrorCodeI code)
return getErrorInfo(code).httpStatus;
}
} // namespace RPC
} // namespace rpc
std::string
rpcErrorString(json::Value const& jv)
{
XRPL_ASSERT(RPC::containsError(jv), "xrpl::RPC::rpcErrorString : input contains an error");
XRPL_ASSERT(rpc::containsError(jv), "xrpl::rpc::rpcErrorString : input contains an error");
return jv[jss::error].asString() + jv[jss::error_message].asString();
}

View File

@@ -9,7 +9,7 @@
#include <memory>
namespace xrpl::RPC {
namespace xrpl::rpc {
void
insertNFTSyntheticInJson(
@@ -21,4 +21,4 @@ insertNFTSyntheticInJson(
insertNFTokenOfferID(response[jss::meta], transaction, transactionMeta);
}
} // namespace xrpl::RPC
} // namespace xrpl::rpc

View File

@@ -13,7 +13,7 @@ json::Value
rpcError(ErrorCodeI iError)
{
json::Value jvResult(json::ValueType::Object);
RPC::injectError(iError, jvResult);
rpc::injectError(iError, jvResult);
return jvResult;
}

View File

@@ -11,6 +11,8 @@
#include <xrpl/protocol/Serializer.h>
#include <xrpl/protocol/UintTypes.h>
#include <boost/endian/conversion.hpp>
#include <cstddef>
#include <cstdint>
#include <cstring>
@@ -45,6 +47,10 @@ STIssue::STIssue(SerialIter& sit, SField const& name) : STBase{name}
{
MPTID mptID;
std::uint32_t sequence = sit.get32();
// MPTID stores the sequence in canonical big-endian bytes. STIssue
// ledger bytes are the legacy LE-host encoding, so convert the
// native get32() value to LE bytes before copying into the MPTID.
sequence = boost::endian::native_to_little(sequence);
static_assert(MPTID::size() == sizeof(sequence) + sizeof(currencyOrAccount));
memcpy(mptID.data(), &sequence, sizeof(sequence));
memcpy(
@@ -100,6 +106,10 @@ STIssue::add(Serializer& s) const
s.addBitString(noAccount());
std::uint32_t sequence = 0;
memcpy(&sequence, issue.getMptID().data(), sizeof(sequence));
// The MPTID bytes are canonical big-endian. Interpret those bytes
// as the legacy LE-host value so add32() writes the preserved
// STIssue wire bytes on every host endian.
sequence = boost::endian::little_to_native(sequence);
s.add32(sequence);
});
}

View File

@@ -48,7 +48,7 @@
namespace xrpl {
namespace STParsedJSONDetail {
namespace st_parsed_json_detail {
template <typename U, typename S>
constexpr U
toUnsigned(S value)
@@ -93,7 +93,7 @@ makeName(std::string const& object, std::string const& field)
static inline json::Value
notAnObject(std::string const& object, std::string const& field)
{
return RPC::makeError(
return rpc::makeError(
RpcInvalidParams, "Field '" + makeName(object, field) + "' is not a JSON object.");
}
@@ -106,33 +106,33 @@ notAnObject(std::string const& object)
static inline json::Value
notAnArray(std::string const& object)
{
return RPC::makeError(RpcInvalidParams, "Field '" + object + "' is not a JSON array.");
return rpc::makeError(RpcInvalidParams, "Field '" + object + "' is not a JSON array.");
}
static inline json::Value
unknownField(std::string const& object, std::string const& field)
{
return RPC::makeError(RpcInvalidParams, "Field '" + makeName(object, field) + "' is unknown.");
return rpc::makeError(RpcInvalidParams, "Field '" + makeName(object, field) + "' is unknown.");
}
static inline json::Value
outOfRange(std::string const& object, std::string const& field)
{
return RPC::makeError(
return rpc::makeError(
RpcInvalidParams, "Field '" + makeName(object, field) + "' is out of range.");
}
static inline json::Value
badType(std::string const& object, std::string const& field)
{
return RPC::makeError(
return rpc::makeError(
RpcInvalidParams, "Field '" + makeName(object, field) + "' has bad type.");
}
static inline json::Value
invalidData(std::string const& object, std::string const& field)
{
return RPC::makeError(
return rpc::makeError(
RpcInvalidParams, "Field '" + makeName(object, field) + "' has invalid data.");
}
@@ -145,14 +145,14 @@ invalidData(std::string const& object)
static inline json::Value
arrayExpected(std::string const& object, std::string const& field)
{
return RPC::makeError(
return rpc::makeError(
RpcInvalidParams, "Field '" + makeName(object, field) + "' must be a JSON array.");
}
static inline json::Value
arrayTooBig(std::string const& object, std::string const& field)
{
return RPC::makeError(
return rpc::makeError(
RpcInvalidParams,
"Field '" + makeName(object, field) + "' exceeds allowed JSON array size of " +
std::to_string(kMaxParsedJsonArraySize) + " elements per field.");
@@ -161,20 +161,20 @@ arrayTooBig(std::string const& object, std::string const& field)
static inline json::Value
stringExpected(std::string const& object, std::string const& field)
{
return RPC::makeError(
return rpc::makeError(
RpcInvalidParams, "Field '" + makeName(object, field) + "' must be a string.");
}
static inline json::Value
tooDeep(std::string const& object)
{
return RPC::makeError(RpcInvalidParams, "Field '" + object + "' exceeds nesting depth limit.");
return rpc::makeError(RpcInvalidParams, "Field '" + object + "' exceeds nesting depth limit.");
}
static inline json::Value
singletonExpected(std::string const& object, unsigned int index)
{
return RPC::makeError(
return rpc::makeError(
RpcInvalidParams,
"Field '" + object + "[" + std::to_string(index) +
"]' must be an object with a single key/object value.");
@@ -183,7 +183,7 @@ singletonExpected(std::string const& object, unsigned int index)
static inline json::Value
templateMismatch(SField const& sField)
{
return RPC::makeError(
return rpc::makeError(
RpcInvalidParams,
"Object '" + sField.getName() + "' contents did not meet requirements for that type.");
}
@@ -191,7 +191,7 @@ templateMismatch(SField const& sField)
static inline json::Value
nonObjectInArray(std::string const& item, json::UInt index)
{
return RPC::makeError(
return rpc::makeError(
RpcInvalidParams,
"Item '" + item + "' at index " + std::to_string(index) +
" is not an object. Arrays may only contain objects.");
@@ -791,7 +791,7 @@ parseLeaf(
if (pathEl.isMember(jss::currency) && pathEl.isMember(jss::mpt_issuance_id))
{
error = RPC::makeError(RpcInvalidParams, "Invalid Asset.");
error = rpc::makeError(RpcInvalidParams, "Invalid Asset.");
return ret;
}
@@ -1195,13 +1195,13 @@ parseArray(
}
}
} // namespace STParsedJSONDetail
} // namespace st_parsed_json_detail
//------------------------------------------------------------------------------
STParsedJSONObject::STParsedJSONObject(std::string const& name, json::Value const& json)
{
using namespace STParsedJSONDetail;
using namespace st_parsed_json_detail;
object = parseObject(name, json, sfGeneric, 0, error);
}

View File

@@ -24,7 +24,7 @@
#include <vector>
namespace xrpl {
namespace Attestations {
namespace attestations {
AttestationBase::AttestationBase(
AccountID attestationSignerAccount,
@@ -385,7 +385,7 @@ operator==(AttestationCreateAccount const& lhs, AttestationCreateAccount const&
std::tie(rhs.createCount, rhs.toCreate, rhs.rewardAmount);
}
} // namespace Attestations
} // namespace attestations
SField const& XChainClaimAttestation::arrayFieldName{sfXChainClaimAttestations};
SField const& XChainCreateAccountAttestation::arrayFieldName{sfXChainCreateAccountAttestations};

View File

@@ -6,7 +6,7 @@
#include <string>
#include <utility>
namespace xrpl::Resource {
namespace xrpl::resource {
Charge::Charge(value_type cost, std::string label) : cost_(cost), label_(std::move(label))
{
@@ -57,4 +57,4 @@ Charge::operator*(value_type m) const
return Charge(cost_ * m, label_);
}
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -12,7 +12,7 @@
#include <ostream>
#include <string>
namespace xrpl::Resource {
namespace xrpl::resource {
Consumer::Consumer(Logic& logic, Entry& entry) : logic_(&logic), entry_(&entry)
{
@@ -99,14 +99,14 @@ Consumer::charge(Charge const& what, std::string const& context)
bool
Consumer::warn()
{
XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::warn : non-null entry");
XRPL_ASSERT(entry_, "xrpl::resource::Consumer::warn : non-null entry");
return logic_->warn(*entry_);
}
bool
Consumer::disconnect(beast::Journal const& j)
{
XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::disconnect : non-null entry");
XRPL_ASSERT(entry_, "xrpl::resource::Consumer::disconnect : non-null entry");
bool const d = logic_->disconnect(*entry_);
if (d)
{
@@ -118,14 +118,14 @@ Consumer::disconnect(beast::Journal const& j)
int
Consumer::balance()
{
XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::balance : non-null entry");
XRPL_ASSERT(entry_, "xrpl::resource::Consumer::balance : non-null entry");
return logic_->balance(*entry_);
}
Entry&
Consumer::entry()
{
XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::entry : non-null entry");
XRPL_ASSERT(entry_, "xrpl::resource::Consumer::entry : non-null entry");
return *entry_;
}
@@ -142,4 +142,4 @@ operator<<(std::ostream& os, Consumer const& v)
return os;
}
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -2,7 +2,7 @@
#include <xrpl/resource/Charge.h>
namespace xrpl::Resource {
namespace xrpl::resource {
Charge const kFeeMalformedRequest(200, "malformed request");
Charge const kFeeRequestNoReply(10, "unsatisfiable request");
@@ -23,6 +23,6 @@ Charge const kFeeHeavyBurdenPeer(2000, "heavy peer request");
Charge const kFeeWarning(4000, "received warning");
Charge const kFeeDrop(6000, "dropped");
// See also Resource::Logic::charge for log level cutoff values
// See also resource::Logic::charge for log level cutoff values
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -23,7 +23,7 @@
#include <string_view>
#include <thread>
namespace xrpl::Resource {
namespace xrpl::resource {
class ManagerImp : public Manager
{
@@ -58,14 +58,14 @@ public:
}
Consumer
newInboundEndpoint(beast::IP::Endpoint const& address) override
newInboundEndpoint(beast::ip::Endpoint const& address) override
{
return logic_.newInboundEndpoint(address);
}
Consumer
newInboundEndpoint(
beast::IP::Endpoint const& address,
beast::ip::Endpoint const& address,
bool const proxy,
std::string_view forwardedFor) override
{
@@ -85,13 +85,13 @@ public:
}
Consumer
newOutboundEndpoint(beast::IP::Endpoint const& address) override
newOutboundEndpoint(beast::ip::Endpoint const& address) override
{
return logic_.newOutboundEndpoint(address);
}
Consumer
newUnlimitedEndpoint(beast::IP::Endpoint const& address) override
newUnlimitedEndpoint(beast::ip::Endpoint const& address) override
{
return logic_.newUnlimitedEndpoint(address);
}
@@ -136,7 +136,7 @@ private:
void
run()
{
beast::setCurrentThreadName("Resource::Mngr");
beast::setCurrentThreadName("resource::Mngr");
for (;;)
{
logic_.periodicActivity();
@@ -164,4 +164,4 @@ makeManager(beast::insight::Collector::ptr const& collector, beast::Journal jour
return std::make_unique<ManagerImp>(collector, journal);
}
} // namespace xrpl::Resource
} // namespace xrpl::resource

View File

@@ -104,7 +104,7 @@ InfoSub::~InfoSub()
}
}
Resource::Consumer&
resource::Consumer&
InfoSub::getConsumer()
{
return consumer_;

Some files were not shown because too many files have changed in this diff Show More