Merge remote-tracking branch 'XRPLF/develop' into ximinez/lending-shortages

* XRPLF/develop:
  fix: Disable unnecessary sanity-check in VaultDeposit (7288)
  ci: [DEPENDABOT] bump actions/upload-artifact from 7.0.0 to 7.0.1 (7286)
  ci: Only run reusable package in public repos (7293)
  fix: Set default peering port to 2459 (6848)
  fix: Use account ledger entry when canceling token escrows (6171)
  refactor: Rename `account_` to `accountID_` (7284)
  ci: Add Linux package builds (DEB + RPM) to CI (6639)
  refactor: Clean up comments post-clang-tidy changes (7283)
  release: Set version to 3.3.0-b0 (7280)
  refactor: Rename static constants (7120)
  refactor: Use `isFlag` where possible instead of bitwise math (7278)
  ci: Update XRPLF/actions (7281)
This commit is contained in:
Ed Hennis
2026-05-19 22:10:17 +01:00
690 changed files with 8291 additions and 7313 deletions

View File

@@ -171,7 +171,7 @@ CheckOptions:
readability-identifier-naming.EnumCase: CamelCase readability-identifier-naming.EnumCase: CamelCase
readability-identifier-naming.EnumConstantCase: CamelCase readability-identifier-naming.EnumConstantCase: CamelCase
readability-identifier-naming.ScopedEnumConstantCase: CamelCase readability-identifier-naming.ScopedEnumConstantCase: CamelCase
readability-identifier-naming.GlobalConstantCase: UPPER_CASE readability-identifier-naming.GlobalConstantCase: CamelCase
readability-identifier-naming.GlobalConstantPrefix: "k" readability-identifier-naming.GlobalConstantPrefix: "k"
readability-identifier-naming.GlobalVariableCase: CamelCase readability-identifier-naming.GlobalVariableCase: CamelCase
readability-identifier-naming.GlobalVariablePrefix: "g" readability-identifier-naming.GlobalVariablePrefix: "g"
@@ -179,14 +179,12 @@ CheckOptions:
readability-identifier-naming.ConstexprMethodCase: camelBack readability-identifier-naming.ConstexprMethodCase: camelBack
readability-identifier-naming.ClassMethodCase: camelBack readability-identifier-naming.ClassMethodCase: camelBack
readability-identifier-naming.ClassMemberCase: camelBack readability-identifier-naming.ClassMemberCase: camelBack
readability-identifier-naming.ClassConstantCase: UPPER_CASE readability-identifier-naming.ClassConstantCase: CamelCase
readability-identifier-naming.ClassConstantPrefix: "k" readability-identifier-naming.ClassConstantPrefix: "k"
readability-identifier-naming.StaticConstantCase: UPPER_CASE readability-identifier-naming.StaticConstantCase: CamelCase
readability-identifier-naming.StaticConstantPrefix: "k" readability-identifier-naming.StaticConstantPrefix: "k"
readability-identifier-naming.StaticVariableCase: UPPER_CASE readability-identifier-naming.StaticVariableCase: camelBack
readability-identifier-naming.StaticVariablePrefix: "k" readability-identifier-naming.ConstexprVariableCase: camelBack
readability-identifier-naming.ConstexprVariableCase: UPPER_CASE
readability-identifier-naming.ConstexprVariablePrefix: "k"
readability-identifier-naming.LocalConstantCase: camelBack readability-identifier-naming.LocalConstantCase: camelBack
readability-identifier-naming.LocalVariableCase: camelBack readability-identifier-naming.LocalVariableCase: camelBack
readability-identifier-naming.TemplateParameterCase: CamelCase readability-identifier-naming.TemplateParameterCase: CamelCase

View File

@@ -62,7 +62,7 @@ ${SED_COMMAND} -i 's@ripple/@xrpld/@g' src/test/core/Config_test.cpp
${SED_COMMAND} -i 's/Rippled/File/g' src/test/core/Config_test.cpp ${SED_COMMAND} -i 's/Rippled/File/g' src/test/core/Config_test.cpp
# Restore the old config file name in the code that maintains support for now. # Restore the old config file name in the code that maintains support for now.
${SED_COMMAND} -i 's/kCONFIG_LEGACY_NAME = "xrpld.cfg"/kCONFIG_LEGACY_NAME = "rippled.cfg"/g' src/xrpld/core/detail/Config.cpp ${SED_COMMAND} -i 's/kConfigLegacyName = "xrpld.cfg"/kConfigLegacyName = "rippled.cfg"/g' src/xrpld/core/detail/Config.cpp
# Restore an URL. # Restore an URL.
${SED_COMMAND} -i 's/connect-your-xrpld-to-the-xrp-test-net.html/connect-your-rippled-to-the-xrp-test-net.html/g' cfg/xrpld-example.cfg ${SED_COMMAND} -i 's/connect-your-xrpld-to-the-xrp-test-net.html/connect-your-rippled-to-the-xrp-test-net.html/g' cfg/xrpld-example.cfg

View File

@@ -90,7 +90,7 @@ ${SED_COMMAND} -i 's/www.ripple.com/www.xrpl.org/g' src/test/protocol/Seed_test.
# Restore specific changes. # Restore specific changes.
${SED_COMMAND} -i 's@b5efcc/src/xrpld@b5efcc/src/ripple@' include/xrpl/protocol/README.md ${SED_COMMAND} -i 's@b5efcc/src/xrpld@b5efcc/src/ripple@' include/xrpl/protocol/README.md
${SED_COMMAND} -i 's/dbPrefix_ = "xrpldb"/dbPrefix_ = "rippledb"/' src/xrpld/app/misc/SHAMapStoreImp.h # cspell: disable-line ${SED_COMMAND} -i 's/dbPrefix_ = "xrpldb"/dbPrefix_ = "rippledb"/' src/xrpld/app/misc/SHAMapStoreImp.h # cspell: disable-line
${SED_COMMAND} -i 's/kCONFIG_LEGACY_NAME = "xrpld.cfg"/kCONFIG_LEGACY_NAME = "rippled.cfg"/' src/xrpld/core/detail/Config.cpp ${SED_COMMAND} -i 's/kConfigLegacyName = "xrpld.cfg"/kConfigLegacyName = "rippled.cfg"/' src/xrpld/core/detail/Config.cpp
popd popd
echo "Renaming complete." echo "Renaming complete."

View File

@@ -32,7 +32,32 @@ We will further set additional CMake arguments as follows:
""" """
def generate_strategy_matrix(all: bool, config: Config) -> list: def build_config_name(os_entry: dict[str, str], platform: str, build_type: str) -> str:
parts = [os_entry["distro_name"]]
for key in ("distro_version", "compiler_name", "compiler_version"):
if value := os_entry[key]:
parts.append(value)
parts.append("arm64" if "arm64" in platform else "amd64")
parts.append(build_type.lower())
return "-".join(parts)
def generate_packaging_matrix(config: Config) -> list[dict]:
"""Emit one entry per os entry with `package: true`. Architecture is
hardcoded to linux/amd64 here (and the runner is hardcoded at the
workflow level) until arm64 packaging is ready.
"""
return [
{
"artifact_name": f"xrpld-{build_config_name(os, 'linux/amd64', 'Release')}",
"os": os,
}
for os in config.os
if os.get("package", False)
]
def generate_strategy_matrix(all: bool, config: Config) -> list[dict]:
configurations = [] configurations = []
for architecture, os, build_type, cmake_args in itertools.product( for architecture, os, build_type, cmake_args in itertools.product(
config.architecture, config.os, config.build_type, config.cmake_args config.architecture, config.os, config.build_type, config.cmake_args
@@ -101,14 +126,15 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
continue continue
# RHEL: # RHEL:
# - 9 using GCC 12: Debug on linux/amd64. # - 9 using GCC 12: Debug and Release on linux/amd64
# (Release is required for RPM packaging).
# - 10 using Clang: Release on linux/amd64. # - 10 using Clang: Release on linux/amd64.
if os["distro_name"] == "rhel": if os["distro_name"] == "rhel":
skip = True skip = True
if os["distro_version"] == "9": if os["distro_version"] == "9":
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-12" f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-12"
and build_type == "Debug" and build_type in ["Debug", "Release"]
and architecture["platform"] == "linux/amd64" and architecture["platform"] == "linux/amd64"
): ):
skip = False skip = False
@@ -123,7 +149,8 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
continue continue
# Ubuntu: # Ubuntu:
# - Jammy using GCC 12: Debug on linux/arm64. # - Jammy using GCC 12: Debug on linux/arm64, Release on
# linux/amd64 (Release is required for DEB packaging).
# - Noble using GCC 14: Release on linux/amd64. # - Noble using GCC 14: Release on linux/amd64.
# - Noble using Clang 18: Debug on linux/amd64. # - Noble using Clang 18: Debug on linux/amd64.
# - Noble using Clang 19: Release on linux/arm64. # - Noble using Clang 19: Release on linux/arm64.
@@ -136,6 +163,12 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
and architecture["platform"] == "linux/arm64" and architecture["platform"] == "linux/arm64"
): ):
skip = False skip = False
if (
f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-12"
and build_type == "Release"
and architecture["platform"] == "linux/amd64"
):
skip = False
elif os["distro_version"] == "noble": elif os["distro_version"] == "noble":
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-14" f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-14"
@@ -218,17 +251,7 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
# Generate a unique name for the configuration, e.g. macos-arm64-debug # Generate a unique name for the configuration, e.g. macos-arm64-debug
# or debian-bookworm-gcc-12-amd64-release. # or debian-bookworm-gcc-12-amd64-release.
config_name = os["distro_name"] config_name = build_config_name(os, architecture["platform"], build_type)
if (n := os["distro_version"]) != "":
config_name += f"-{n}"
if (n := os["compiler_name"]) != "":
config_name += f"-{n}"
if (n := os["compiler_version"]) != "":
config_name += f"-{n}"
config_name += (
f"-{architecture['platform'][architecture['platform'].find('/')+1:]}"
)
config_name += f"-{build_type.lower()}"
if "-Dcoverage=ON" in cmake_args: if "-Dcoverage=ON" in cmake_args:
config_name += "-coverage" config_name += "-coverage"
if "-Dunity=ON" in cmake_args: if "-Dunity=ON" in cmake_args:
@@ -332,10 +355,19 @@ if __name__ == "__main__":
required=False, required=False,
type=Path, type=Path,
) )
parser.add_argument(
"-p",
"--packaging",
help="Emit the packaging matrix (derived from the 'package' field on os entries) instead of the build/test matrix.",
action="store_true",
)
args = parser.parse_args() args = parser.parse_args()
matrix = [] matrix = []
if args.config is None or args.config == "": if args.packaging:
config_path = args.config if args.config else THIS_DIR / "linux.json"
matrix += generate_packaging_matrix(read_config(config_path))
elif args.config is None or args.config == "":
matrix += generate_strategy_matrix( matrix += generate_strategy_matrix(
args.all, read_config(THIS_DIR / "linux.json") args.all, read_config(THIS_DIR / "linux.json")
) )

View File

@@ -127,7 +127,8 @@
"distro_version": "9", "distro_version": "9",
"compiler_name": "gcc", "compiler_name": "gcc",
"compiler_version": "12", "compiler_version": "12",
"image_sha": "4c086b9" "image_sha": "4c086b9",
"package": true
}, },
{ {
"distro_name": "rhel", "distro_name": "rhel",
@@ -169,7 +170,8 @@
"distro_version": "jammy", "distro_version": "jammy",
"compiler_name": "gcc", "compiler_name": "gcc",
"compiler_version": "12", "compiler_version": "12",
"image_sha": "4c086b9" "image_sha": "4c086b9",
"package": true
}, },
{ {
"distro_name": "ubuntu", "distro_name": "ubuntu",

View File

@@ -11,4 +11,4 @@ on:
jobs: jobs:
check_title: check_title:
if: ${{ github.event.pull_request.draft != true }} if: ${{ github.event.pull_request.draft != true }}
uses: XRPLF/actions/.github/workflows/check-pr-title.yml@a5d8dd35be543365e90a11358447130c8763871d uses: XRPLF/actions/.github/workflows/check-pr-title.yml@291206777251b4d493641b5afbdf7c23009d2988

View File

@@ -64,11 +64,13 @@ jobs:
.github/workflows/reusable-build-test-config.yml .github/workflows/reusable-build-test-config.yml
.github/workflows/reusable-build-test.yml .github/workflows/reusable-build-test.yml
.github/workflows/reusable-clang-tidy.yml .github/workflows/reusable-clang-tidy.yml
.github/workflows/reusable-package.yml
.github/workflows/reusable-strategy-matrix.yml .github/workflows/reusable-strategy-matrix.yml
.github/workflows/reusable-test.yml .github/workflows/reusable-test.yml
.github/workflows/reusable-upload-recipe.yml .github/workflows/reusable-upload-recipe.yml
.clang-tidy .clang-tidy
.codecov.yml .codecov.yml
cfg/**
cmake/** cmake/**
conan/** conan/**
external/** external/**
@@ -78,6 +80,10 @@ jobs:
CMakeLists.txt CMakeLists.txt
conanfile.py conanfile.py
conan.lock conan.lock
LICENSE.md
package/**
README.md
- name: Check whether to run - name: Check whether to run
# This step determines whether the rest of the workflow should # This step determines whether the rest of the workflow should
# run. The rest of the workflow will run if this job runs AND at # run. The rest of the workflow will run if this job runs AND at
@@ -134,6 +140,11 @@ jobs:
secrets: secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
package:
needs: [should-run, build-test]
if: ${{ needs.should-run.outputs.go == 'true' }}
uses: ./.github/workflows/reusable-package.yml
upload-recipe: upload-recipe:
needs: needs:
- should-run - should-run
@@ -168,6 +179,7 @@ jobs:
- check-rename - check-rename
- clang-tidy - clang-tidy
- build-test - build-test
- package
- upload-recipe - upload-recipe
- notify-clio - notify-clio
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -1,5 +1,5 @@
# This workflow uploads the libxrpl recipe to the Conan remote when a versioned # This workflow uploads the libxrpl recipe to the Conan remote and builds
# tag is pushed. # release packages when a versioned tag is pushed.
name: Tag name: Tag
on: on:
@@ -22,3 +22,22 @@ jobs:
secrets: secrets:
remote_username: ${{ secrets.CONAN_REMOTE_USERNAME }} remote_username: ${{ secrets.CONAN_REMOTE_USERNAME }}
remote_password: ${{ secrets.CONAN_REMOTE_PASSWORD }} remote_password: ${{ secrets.CONAN_REMOTE_PASSWORD }}
build-test:
if: ${{ github.repository == 'XRPLF/rippled' }}
uses: ./.github/workflows/reusable-build-test.yml
strategy:
fail-fast: true
matrix:
os: [linux]
with:
ccache_enabled: false
os: ${{ matrix.os }}
strategy_matrix: minimal
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
package:
if: ${{ github.repository == 'XRPLF/rippled' }}
needs: build-test
uses: ./.github/workflows/reusable-package.yml

View File

@@ -21,11 +21,13 @@ on:
- ".github/workflows/reusable-build-test-config.yml" - ".github/workflows/reusable-build-test-config.yml"
- ".github/workflows/reusable-build-test.yml" - ".github/workflows/reusable-build-test.yml"
- ".github/workflows/reusable-clang-tidy.yml" - ".github/workflows/reusable-clang-tidy.yml"
- ".github/workflows/reusable-package.yml"
- ".github/workflows/reusable-strategy-matrix.yml" - ".github/workflows/reusable-strategy-matrix.yml"
- ".github/workflows/reusable-test.yml" - ".github/workflows/reusable-test.yml"
- ".github/workflows/reusable-upload-recipe.yml" - ".github/workflows/reusable-upload-recipe.yml"
- ".clang-tidy" - ".clang-tidy"
- ".codecov.yml" - ".codecov.yml"
- "cfg/**"
- "cmake/**" - "cmake/**"
- "conan/**" - "conan/**"
- "external/**" - "external/**"
@@ -35,6 +37,9 @@ on:
- "CMakeLists.txt" - "CMakeLists.txt"
- "conanfile.py" - "conanfile.py"
- "conan.lock" - "conan.lock"
- "LICENSE.md"
- "package/**"
- "README.md"
# Run at 06:32 UTC on every day of the week from Monday through Friday. This # Run at 06:32 UTC on every day of the week from Monday through Friday. This
# will force all dependencies to be rebuilt, which is useful to verify that # will force all dependencies to be rebuilt, which is useful to verify that
@@ -95,3 +100,7 @@ jobs:
secrets: secrets:
remote_username: ${{ secrets.CONAN_REMOTE_USERNAME }} remote_username: ${{ secrets.CONAN_REMOTE_USERNAME }}
remote_password: ${{ secrets.CONAN_REMOTE_PASSWORD }} remote_password: ${{ secrets.CONAN_REMOTE_PASSWORD }}
package:
needs: build-test
uses: ./.github/workflows/reusable-package.yml

View File

@@ -176,7 +176,7 @@ jobs:
- name: Create issue - name: Create issue
if: ${{ steps.run_clang_tidy.outcome != 'success' && inputs.create_issue_on_failure }} if: ${{ steps.run_clang_tidy.outcome != 'success' && inputs.create_issue_on_failure }}
uses: XRPLF/actions/create-issue@fbcc16eb7f20dc3199eaf1aed0d3523a5ba9008c uses: XRPLF/actions/create-issue@36d450d12d301e8410c1b7936e5de70c291cbe36
with: with:
title: "Clang-tidy check failed" title: "Clang-tidy check failed"
body_file: ${{ env.ISSUE_FILE }} body_file: ${{ env.ISSUE_FILE }}

99
.github/workflows/reusable-package.yml vendored Normal file
View File

@@ -0,0 +1,99 @@
# Build Linux packages (DEB and RPM) from pre-built binary artifacts.
# Discovers which configurations to package from linux.json (os entries
# with "package": true) and fans out one job per entry. Today only
# linux/amd64 is emitted; the architecture is hardcoded both here
# (runner) and in generate.py.
name: Package
on:
workflow_call:
inputs:
pkg_release:
description: "Package release number. Increment when repackaging the same executable."
required: false
type: string
default: "1"
defaults:
run:
shell: bash
env:
BUILD_DIR: build
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.13
- name: Generate packaging matrix
id: generate
working-directory: .github/scripts/strategy-matrix
run: |
./generate.py --packaging --config=linux.json >> "${GITHUB_OUTPUT}"
generate-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: |
.github/actions/generate-version
src/libxrpl/protocol/BuildInfo.cpp
- name: Generate version
id: version
uses: ./.github/actions/generate-version
package:
needs: [generate-matrix, generate-version]
if: ${{ github.event.repository.visibility == 'public' }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
name: "${{ matrix.artifact_name }}"
permissions:
contents: read
runs-on: ["self-hosted", "Linux", "X64", "heavy"]
container: ${{ format('ghcr.io/xrplf/ci/{0}-{1}:{2}-{3}-sha-{4}', matrix.os.distro_name, matrix.os.distro_version, matrix.os.compiler_name, matrix.os.compiler_version, matrix.os.image_sha) }}
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download pre-built binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ matrix.artifact_name }}
path: ${{ env.BUILD_DIR }}
- name: Make binary executable
run: chmod +x "${BUILD_DIR}/xrpld"
- name: Build package
env:
PKG_VERSION: ${{ needs.generate-version.outputs.version }}
PKG_RELEASE: ${{ inputs.pkg_release }}
run: ./package/build_pkg.sh
- name: Upload package artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ matrix.artifact_name }}-pkg-${{ needs.generate-version.outputs.version }}
path: |
${{ env.BUILD_DIR }}/debbuild/*.deb
${{ env.BUILD_DIR }}/debbuild/*.ddeb
${{ env.BUILD_DIR }}/rpmbuild/RPMS/**/*.rpm
if-no-files-found: error

View File

@@ -134,6 +134,7 @@ endif()
include(XrplCore) include(XrplCore)
include(XrplProtocolAutogen) include(XrplProtocolAutogen)
include(XrplInstall) include(XrplInstall)
include(XrplPackaging)
include(XrplValidatorKeys) include(XrplValidatorKeys)
if(tests) if(tests)

View File

@@ -28,7 +28,7 @@
# https://vl.ripple.com # https://vl.ripple.com
# https://unl.xrplf.org # https://unl.xrplf.org
# http://127.0.0.1:8000 # http://127.0.0.1:8000
# file:///etc/opt/xrpld/vl.txt # file:///etc/xrpld/vl.txt
# #
# [validator_list_keys] # [validator_list_keys]
# #

View File

@@ -1466,10 +1466,7 @@ admin = 127.0.0.1
protocol = http protocol = http
[port_peer] [port_peer]
# Many servers still use the legacy port of 51235, so for backward-compatibility port = 2459
# we maintain that port number here. However, for new servers we recommend
# changing this to the default port of 2459.
port = 51235
ip = 0.0.0.0 ip = 0.0.0.0
# alternatively, to accept connections on IPv4 + IPv6, use: # alternatively, to accept connections on IPv4 + IPv6, use:
#ip = :: #ip = ::

44
cmake/XrplPackaging.cmake Normal file
View File

@@ -0,0 +1,44 @@
#[===================================================================[
Linux packaging support: 'package' target.
The packaging script (package/build_pkg.sh) installs to FHS-standard
paths (/usr/bin, /etc/xrpld, etc.) regardless of CMAKE_INSTALL_PREFIX,
so no prefix guard is needed here.
#]===================================================================]
if(NOT is_linux)
message(STATUS "Packaging not supported on non-Linux hosts")
return()
endif()
if(NOT DEFINED pkg_release)
set(pkg_release 1)
endif()
find_program(RPMBUILD_EXECUTABLE rpmbuild)
find_program(DPKG_BUILDPACKAGE_EXECUTABLE dpkg-buildpackage)
if(NOT (RPMBUILD_EXECUTABLE OR DPKG_BUILDPACKAGE_EXECUTABLE))
message(
STATUS
"Neither rpmbuild nor dpkg-buildpackage found; 'package' target not available"
)
return()
endif()
set(package_env
SRC_DIR=${CMAKE_SOURCE_DIR}
BUILD_DIR=${CMAKE_BINARY_DIR}
PKG_VERSION=${xrpld_version}
PKG_RELEASE=${pkg_release}
)
add_custom_target(
package
COMMAND
${CMAKE_COMMAND} -E env ${package_env}
${CMAKE_SOURCE_DIR}/package/build_pkg.sh
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS xrpld
COMMENT "Building Linux package (deb/rpm inferred from host tooling)"
VERBATIM
)

View File

@@ -99,12 +99,15 @@ words:
- desync - desync
- desynced - desynced
- determ - determ
- disablerepo
- distro - distro
- doxyfile - doxyfile
- dxrpl - dxrpl
- enabled - enabled
- enablerepo
- endmacro - endmacro
- exceptioned - exceptioned
- EXPECT_STREQ
- Falco - Falco
- fcontext - fcontext
- finalizers - finalizers
@@ -162,6 +165,7 @@ words:
- Merkle - Merkle
- Metafuncton - Metafuncton
- misprediction - misprediction
- missingok
- mptbalance - mptbalance
- MPTDEX - MPTDEX
- mptflags - mptflags
@@ -193,7 +197,9 @@ words:
- NOLINT - NOLINT
- NOLINTNEXTLINE - NOLINTNEXTLINE
- nonxrp - nonxrp
- noreplace
- noripple - noripple
- notifempty
- nudb - nudb
- nullptr - nullptr
- nunl - nunl
@@ -213,6 +219,7 @@ words:
- preauthorize - preauthorize
- preauthorizes - preauthorizes
- preclaim - preclaim
- preun
- protobuf - protobuf
- protos - protos
- ptrs - ptrs
@@ -247,12 +254,14 @@ words:
- sfields - sfields
- shamap - shamap
- shamapitem - shamapitem
- shlibs
- sidechain - sidechain
- SIGGOOD - SIGGOOD
- sle - sle
- sles - sles
- soci - soci
- socidb - socidb
- SRPMS
- sslws - sslws
- statsd - statsd
- STATSDCOLLECTOR - STATSDCOLLECTOR
@@ -280,8 +289,8 @@ words:
- txn - txn
- txns - txns
- txs - txs
- UBSAN
- ubsan - ubsan
- UBSAN
- umant - umant
- unacquired - unacquired
- unambiguity - unambiguity
@@ -318,7 +327,6 @@ words:
- xbridge - xbridge
- xchain - xchain
- ximinez - ximinez
- EXPECT_STREQ
- XMACRO - XMACRO
- xrpkuwait - xrpkuwait
- xrpl - xrpl

View File

@@ -406,8 +406,8 @@ private:
// pointer. The low bit must be masked to zero when converting back to a // pointer. The low bit must be masked to zero when converting back to a
// pointer. If the low bit is '1', this is a weak pointer. // pointer. If the low bit is '1', this is a weak pointer.
std::uintptr_t tp_{0}; std::uintptr_t tp_{0};
static constexpr std::uintptr_t kTAG_MASK = 1; static constexpr std::uintptr_t kTagMask = 1;
static constexpr std::uintptr_t kPTR_MASK = ~kTAG_MASK; static constexpr std::uintptr_t kPtrMask = ~kTagMask;
private: private:
/** Return the raw pointer held by this object. /** Return the raw pointer held by this object.

View File

@@ -567,14 +567,14 @@ template <class T>
bool bool
SharedWeakUnion<T>::isStrong() const SharedWeakUnion<T>::isStrong() const
{ {
return (tp_ & kTAG_MASK) == 0u; return (tp_ & kTagMask) == 0u;
} }
template <class T> template <class T>
bool bool
SharedWeakUnion<T>::isWeak() const SharedWeakUnion<T>::isWeak() const
{ {
return (tp_ & kTAG_MASK) != 0u; return (tp_ & kTagMask) != 0u;
} }
template <class T> template <class T>
@@ -641,7 +641,7 @@ template <class T>
T* T*
SharedWeakUnion<T>::unsafeGetRawPtr() const SharedWeakUnion<T>::unsafeGetRawPtr() const
{ {
return reinterpret_cast<T*>(tp_ & kPTR_MASK); return reinterpret_cast<T*>(tp_ & kPtrMask);
} }
template <class T> template <class T>
@@ -650,7 +650,7 @@ SharedWeakUnion<T>::unsafeSetRawPtr(T* p, RefStrength rs)
{ {
tp_ = reinterpret_cast<std::uintptr_t>(p); tp_ = reinterpret_cast<std::uintptr_t>(p);
if (tp_ && rs == RefStrength::Weak) if (tp_ && rs == RefStrength::Weak)
tp_ |= kTAG_MASK; tp_ |= kTagMask;
} }
template <class T> template <class T>

View File

@@ -98,11 +98,11 @@ private:
// enough for strong pointers and 14 bit counts are enough for weak // enough for strong pointers and 14 bit counts are enough for weak
// pointers. Use type aliases to make it easy to switch types. // pointers. Use type aliases to make it easy to switch types.
using CountType = std::uint16_t; using CountType = std::uint16_t;
static constexpr size_t kSTRONG_COUNT_NUM_BITS = sizeof(CountType) * 8; static constexpr size_t kStrongCountNumBits = sizeof(CountType) * 8;
static constexpr size_t kWEAK_COUNT_NUM_BITS = kSTRONG_COUNT_NUM_BITS - 2; static constexpr size_t kWeakCountNumBits = kStrongCountNumBits - 2;
using FieldType = std::uint32_t; using FieldType = std::uint32_t;
static constexpr size_t kFIELD_TYPE_BITS = sizeof(FieldType) * 8; static constexpr size_t kFieldTypeBits = sizeof(FieldType) * 8;
static constexpr FieldType kONE = 1; static constexpr FieldType kOne = 1;
/** `refCounts` consists of four fields that are treated atomically: /** `refCounts` consists of four fields that are treated atomically:
@@ -137,21 +137,21 @@ private:
*/ */
mutable std::atomic<FieldType> refCounts_{kSTRONG_DELTA}; mutable std::atomic<FieldType> refCounts_{kStrongDelta};
/** Amount to change the strong count when adding or releasing a reference /** Amount to change the strong count when adding or releasing a reference
Note: The strong count is stored in the low `StrongCountNumBits` bits Note: The strong count is stored in the low `StrongCountNumBits` bits
of refCounts of refCounts
*/ */
static constexpr FieldType kSTRONG_DELTA = 1; static constexpr FieldType kStrongDelta = 1;
/** Amount to change the weak count when adding or releasing a reference /** Amount to change the weak count when adding or releasing a reference
Note: The weak count is stored in the high `WeakCountNumBits` bits of Note: The weak count is stored in the high `WeakCountNumBits` bits of
refCounts refCounts
*/ */
static constexpr FieldType kWEAK_DELTA = (kONE << kSTRONG_COUNT_NUM_BITS); static constexpr FieldType kWeakDelta = (kOne << kStrongCountNumBits);
/** Flag that is set when the partialDestroy function has started running /** Flag that is set when the partialDestroy function has started running
(or is about to start running). (or is about to start running).
@@ -159,34 +159,33 @@ private:
See description of the `refCounts` field for a fuller description of See description of the `refCounts` field for a fuller description of
this field. this field.
*/ */
static constexpr FieldType kPARTIAL_DESTROY_STARTED_MASK = (kONE << (kFIELD_TYPE_BITS - 1)); static constexpr FieldType kPartialDestroyStartedMask = (kOne << (kFieldTypeBits - 1));
/** Flag that is set when the partialDestroy function has finished running /** Flag that is set when the partialDestroy function has finished running
See description of the `refCounts` field for a fuller description of See description of the `refCounts` field for a fuller description of
this field. this field.
*/ */
static constexpr FieldType kPARTIAL_DESTROY_FINISHED_MASK = (kONE << (kFIELD_TYPE_BITS - 2)); static constexpr FieldType kPartialDestroyFinishedMask = (kOne << (kFieldTypeBits - 2));
/** Mask that will zero out all the `count` bits and leave the tag bits /** Mask that will zero out all the `count` bits and leave the tag bits
unchanged. unchanged.
*/ */
static constexpr FieldType kTAG_MASK = static constexpr FieldType kTagMask = kPartialDestroyStartedMask | kPartialDestroyFinishedMask;
kPARTIAL_DESTROY_STARTED_MASK | kPARTIAL_DESTROY_FINISHED_MASK;
/** Mask that will zero out the `tag` bits and leave the count bits /** Mask that will zero out the `tag` bits and leave the count bits
unchanged. unchanged.
*/ */
static constexpr FieldType kVALUE_MASK = ~kTAG_MASK; static constexpr FieldType kValueMask = ~kTagMask;
/** Mask that will zero out everything except the strong count. /** Mask that will zero out everything except the strong count.
*/ */
static constexpr FieldType kSTRONG_MASK = ((kONE << kSTRONG_COUNT_NUM_BITS) - 1) & kVALUE_MASK; static constexpr FieldType kStrongMask = ((kOne << kStrongCountNumBits) - 1) & kValueMask;
/** Mask that will zero out everything except the weak count. /** Mask that will zero out everything except the weak count.
*/ */
static constexpr FieldType kWEAK_MASK = static constexpr FieldType kWeakMask =
(((kONE << kWEAK_COUNT_NUM_BITS) - 1) << kSTRONG_COUNT_NUM_BITS) & kVALUE_MASK; (((kOne << kWeakCountNumBits) - 1) << kStrongCountNumBits) & kValueMask;
/** Unpack the count and tag fields from the packed atomic integer form. */ /** Unpack the count and tag fields from the packed atomic integer form. */
struct RefCountPair struct RefCountPair
@@ -211,29 +210,29 @@ private:
[[nodiscard]] FieldType [[nodiscard]] FieldType
combinedValue() const noexcept; combinedValue() const noexcept;
static constexpr CountType kMAX_STRONG_VALUE = static constexpr CountType kMaxStrongValue =
static_cast<CountType>((kONE << kSTRONG_COUNT_NUM_BITS) - 1); static_cast<CountType>((kOne << kStrongCountNumBits) - 1);
static constexpr CountType kMAX_WEAK_VALUE = static constexpr CountType kMaxWeakValue =
static_cast<CountType>((kONE << kWEAK_COUNT_NUM_BITS) - 1); static_cast<CountType>((kOne << kWeakCountNumBits) - 1);
/** Put an extra margin to detect when running up against limits. /** Put an extra margin to detect when running up against limits.
This is only used in debug code, and is useful if we reduce the This is only used in debug code, and is useful if we reduce the
number of bits in the strong and weak counts (to 16 and 14 bits). number of bits in the strong and weak counts (to 16 and 14 bits).
*/ */
static constexpr CountType kCHECK_STRONG_MAX_VALUE = kMAX_STRONG_VALUE - 32; static constexpr CountType kCheckStrongMaxValue = kMaxStrongValue - 32;
static constexpr CountType kCHECK_WEAK_MAX_VALUE = kMAX_WEAK_VALUE - 32; static constexpr CountType kCheckWeakMaxValue = kMaxWeakValue - 32;
}; };
}; };
inline void inline void
IntrusiveRefCounts::addStrongRef() const noexcept IntrusiveRefCounts::addStrongRef() const noexcept
{ {
refCounts_.fetch_add(kSTRONG_DELTA, std::memory_order_acq_rel); refCounts_.fetch_add(kStrongDelta, std::memory_order_acq_rel);
} }
inline void inline void
IntrusiveRefCounts::addWeakRef() const noexcept IntrusiveRefCounts::addWeakRef() const noexcept
{ {
refCounts_.fetch_add(kWEAK_DELTA, std::memory_order_acq_rel); refCounts_.fetch_add(kWeakDelta, std::memory_order_acq_rel);
} }
inline ReleaseStrongRefAction inline ReleaseStrongRefAction
@@ -252,10 +251,10 @@ IntrusiveRefCounts::releaseStrongRef() const
{ {
RefCountPair const prevVal{prevIntVal}; RefCountPair const prevVal{prevIntVal};
XRPL_ASSERT( XRPL_ASSERT(
(prevVal.strong >= kSTRONG_DELTA), (prevVal.strong >= kStrongDelta),
"xrpl::IntrusiveRefCounts::releaseStrongRef : previous ref " "xrpl::IntrusiveRefCounts::releaseStrongRef : previous ref "
"higher than new"); "higher than new");
auto nextIntVal = prevIntVal - kSTRONG_DELTA; auto nextIntVal = prevIntVal - kStrongDelta;
ReleaseStrongRefAction action = NoOp; ReleaseStrongRefAction action = NoOp;
if (prevVal.strong == 1) if (prevVal.strong == 1)
{ {
@@ -265,7 +264,7 @@ IntrusiveRefCounts::releaseStrongRef() const
} }
else else
{ {
nextIntVal |= kPARTIAL_DESTROY_STARTED_MASK; nextIntVal |= kPartialDestroyStartedMask;
action = PartialDestroy; action = PartialDestroy;
} }
} }
@@ -276,7 +275,7 @@ IntrusiveRefCounts::releaseStrongRef() const
// count to zero can start a partial destroy, and that can't happen // count to zero can start a partial destroy, and that can't happen
// twice. // twice.
XRPL_ASSERT( XRPL_ASSERT(
(action == NoOp) || !(prevIntVal & kPARTIAL_DESTROY_STARTED_MASK), (action == NoOp) || !(prevIntVal & kPartialDestroyStartedMask),
"xrpl::IntrusiveRefCounts::releaseStrongRef : not in partial " "xrpl::IntrusiveRefCounts::releaseStrongRef : not in partial "
"destroy"); "destroy");
return action; return action;
@@ -289,8 +288,8 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
{ {
using enum ReleaseStrongRefAction; using enum ReleaseStrongRefAction;
static_assert(kWEAK_DELTA > kSTRONG_DELTA); static_assert(kWeakDelta > kStrongDelta);
auto constexpr kDELTA = kWEAK_DELTA - kSTRONG_DELTA; static constexpr auto kDelta = kWeakDelta - kStrongDelta;
auto prevIntVal = refCounts_.load(std::memory_order_acquire); auto prevIntVal = refCounts_.load(std::memory_order_acquire);
// This loop will almost always run once. The loop is needed to atomically // This loop will almost always run once. The loop is needed to atomically
// change the counts and flags (the count could be atomically changed, but // change the counts and flags (the count could be atomically changed, but
@@ -312,7 +311,7 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
"xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef : not in " "xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef : not in "
"partial destroy"); "partial destroy");
auto nextIntVal = prevIntVal + kDELTA; auto nextIntVal = prevIntVal + kDelta;
ReleaseStrongRefAction action = NoOp; ReleaseStrongRefAction action = NoOp;
if (prevVal.strong == 1) if (prevVal.strong == 1)
{ {
@@ -322,14 +321,14 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
} }
else else
{ {
nextIntVal |= kPARTIAL_DESTROY_STARTED_MASK; nextIntVal |= kPartialDestroyStartedMask;
action = PartialDestroy; action = PartialDestroy;
} }
} }
if (refCounts_.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel)) if (refCounts_.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel))
{ {
XRPL_ASSERT( XRPL_ASSERT(
(!(prevIntVal & kPARTIAL_DESTROY_STARTED_MASK)), (!(prevIntVal & kPartialDestroyStartedMask)),
"xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef : not " "xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef : not "
"started partial destroy"); "started partial destroy");
return action; return action;
@@ -340,7 +339,7 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
inline ReleaseWeakRefAction inline ReleaseWeakRefAction
IntrusiveRefCounts::releaseWeakRef() const IntrusiveRefCounts::releaseWeakRef() const
{ {
auto prevIntVal = refCounts_.fetch_sub(kWEAK_DELTA, std::memory_order_acq_rel); auto prevIntVal = refCounts_.fetch_sub(kWeakDelta, std::memory_order_acq_rel);
RefCountPair prev = prevIntVal; RefCountPair prev = prevIntVal;
if (prev.weak == 1 && prev.strong == 0) if (prev.weak == 1 && prev.strong == 0)
{ {
@@ -357,7 +356,7 @@ IntrusiveRefCounts::releaseWeakRef() const
{ {
// partial destroy MUST finish before running a full destroy (when // partial destroy MUST finish before running a full destroy (when
// using weak pointers) // using weak pointers)
refCounts_.wait(prevIntVal - kWEAK_DELTA, std::memory_order_acquire); refCounts_.wait(prevIntVal - kWeakDelta, std::memory_order_acquire);
} }
return ReleaseWeakRefAction::Destroy; return ReleaseWeakRefAction::Destroy;
} }
@@ -376,7 +375,7 @@ IntrusiveRefCounts::checkoutStrongRefFromWeak() const noexcept
if (prev.strong == 0u) if (prev.strong == 0u)
return false; return false;
desiredValue = curValue + kSTRONG_DELTA; desiredValue = curValue + kStrongDelta;
} }
return true; return true;
} }
@@ -400,23 +399,22 @@ inline IntrusiveRefCounts::~IntrusiveRefCounts() noexcept
#ifndef NDEBUG #ifndef NDEBUG
auto v = refCounts_.load(std::memory_order_acquire); auto v = refCounts_.load(std::memory_order_acquire);
XRPL_ASSERT( XRPL_ASSERT(
(!(v & kVALUE_MASK)), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : count must be zero"); (!(v & kValueMask)), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : count must be zero");
auto t = v & kTAG_MASK; auto t = v & kTagMask;
XRPL_ASSERT( XRPL_ASSERT((!t || t == kTagMask), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : valid tag");
(!t || t == kTAG_MASK), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : valid tag");
#endif #endif
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
inline IntrusiveRefCounts::RefCountPair::RefCountPair(IntrusiveRefCounts::FieldType v) noexcept inline IntrusiveRefCounts::RefCountPair::RefCountPair(IntrusiveRefCounts::FieldType v) noexcept
: strong{static_cast<CountType>(v & kSTRONG_MASK)} : strong{static_cast<CountType>(v & kStrongMask)}
, weak{static_cast<CountType>((v & kWEAK_MASK) >> kSTRONG_COUNT_NUM_BITS)} , weak{static_cast<CountType>((v & kWeakMask) >> kStrongCountNumBits)}
, partialDestroyStartedBit{v & kPARTIAL_DESTROY_STARTED_MASK} , partialDestroyStartedBit{v & kPartialDestroyStartedMask}
, partialDestroyFinishedBit{v & kPARTIAL_DESTROY_FINISHED_MASK} , partialDestroyFinishedBit{v & kPartialDestroyFinishedMask}
{ {
XRPL_ASSERT( XRPL_ASSERT(
(strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE), (strong < kCheckStrongMaxValue && weak < kCheckWeakMaxValue),
"xrpl::IntrusiveRefCounts::RefCountPair(FieldType) : inputs inside " "xrpl::IntrusiveRefCounts::RefCountPair(FieldType) : inputs inside "
"range"); "range");
} }
@@ -427,7 +425,7 @@ inline IntrusiveRefCounts::RefCountPair::RefCountPair(
: strong{s}, weak{w} : strong{s}, weak{w}
{ {
XRPL_ASSERT( XRPL_ASSERT(
(strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE), (strong < kCheckStrongMaxValue && weak < kCheckWeakMaxValue),
"xrpl::IntrusiveRefCounts::RefCountPair(CountType, CountType) : " "xrpl::IntrusiveRefCounts::RefCountPair(CountType, CountType) : "
"inputs inside range"); "inputs inside range");
} }
@@ -436,11 +434,11 @@ inline IntrusiveRefCounts::FieldType
IntrusiveRefCounts::RefCountPair::combinedValue() const noexcept IntrusiveRefCounts::RefCountPair::combinedValue() const noexcept
{ {
XRPL_ASSERT( XRPL_ASSERT(
(strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE), (strong < kCheckStrongMaxValue && weak < kCheckWeakMaxValue),
"xrpl::IntrusiveRefCounts::RefCountPair::combinedValue : inputs " "xrpl::IntrusiveRefCounts::RefCountPair::combinedValue : inputs "
"inside range"); "inside range");
return (static_cast<IntrusiveRefCounts::FieldType>(weak) return (static_cast<IntrusiveRefCounts::FieldType>(weak)
<< IntrusiveRefCounts::kSTRONG_COUNT_NUM_BITS) | << IntrusiveRefCounts::kStrongCountNumBits) |
static_cast<IntrusiveRefCounts::FieldType>(strong) | partialDestroyStartedBit | static_cast<IntrusiveRefCounts::FieldType>(strong) | partialDestroyStartedBit |
partialDestroyFinishedBit; partialDestroyFinishedBit;
} }
@@ -451,7 +449,7 @@ partialDestructorFinished(T** o)
{ {
T& self = **o; T& self = **o;
IntrusiveRefCounts::RefCountPair const p = IntrusiveRefCounts::RefCountPair const p =
self.refCounts_.fetch_or(IntrusiveRefCounts::kPARTIAL_DESTROY_FINISHED_MASK); self.refCounts_.fetch_or(IntrusiveRefCounts::kPartialDestroyFinishedMask);
XRPL_ASSERT( XRPL_ASSERT(
(!p.partialDestroyFinishedBit && p.partialDestroyStartedBit && !p.strong), (!p.partialDestroyFinishedBit && p.partialDestroyStartedBit && !p.strong),
"xrpl::partialDestructorFinished : not a weak ref"); "xrpl::partialDestructorFinished : not a weak ref");

View File

@@ -55,8 +55,8 @@ template <class = void>
boost::thread_specific_ptr<detail::LocalValues>& boost::thread_specific_ptr<detail::LocalValues>&
getLocalValues() getLocalValues()
{ {
static boost::thread_specific_ptr<detail::LocalValues> kTSP(&detail::LocalValues::cleanup); static boost::thread_specific_ptr<detail::LocalValues> kTsp(&detail::LocalValues::cleanup);
return kTSP; return kTsp;
} }
} // namespace detail } // namespace detail

View File

@@ -191,7 +191,7 @@ public:
private: private:
// Maximum line length for log messages. // Maximum line length for log messages.
// If the message exceeds this length it will be truncated with ellipses. // If the message exceeds this length it will be truncated with ellipses.
static constexpr auto kMAXIMUM_MESSAGE_CHARACTERS = 12 * 1024; static constexpr auto kMaximumMessageCharacters = 12 * 1024;
static void static void
format( format(

View File

@@ -214,12 +214,12 @@ class Number
public: public:
// The range for the exponent when normalized // The range for the exponent when normalized
constexpr static int kMIN_EXPONENT = -32768; static constexpr int kMinExponent = -32768;
constexpr static int kMAX_EXPONENT = 32768; static constexpr int kMaxExponent = 32768;
constexpr static internalrep kMAX_REP = std::numeric_limits<rep>::max(); static constexpr internalrep kMaxRep = std::numeric_limits<rep>::max();
static_assert(kMAX_REP == 9'223'372'036'854'775'807); static_assert(kMaxRep == 9'223'372'036'854'775'807);
static_assert(-kMAX_REP == std::numeric_limits<rep>::min() + 1); static_assert(-kMaxRep == std::numeric_limits<rep>::min() + 1);
// May need to make unchecked private // May need to make unchecked private
struct Unchecked struct Unchecked
@@ -409,26 +409,26 @@ public:
static internalrep static internalrep
minMantissa() minMantissa()
{ {
return kRANGE.get().min; return kRange.get().min;
} }
static internalrep static internalrep
maxMantissa() maxMantissa()
{ {
return kRANGE.get().max; return kRange.get().max;
} }
static int static int
mantissaLog() mantissaLog()
{ {
return kRANGE.get().log; return kRange.get().log;
} }
/// oneSmall is needed because the ranges are private /// oneSmall is needed because the ranges are private
constexpr static Number static constexpr Number
oneSmall(); oneSmall();
/// oneLarge is needed because the ranges are private /// oneLarge is needed because the ranges are private
constexpr static Number static constexpr Number
oneLarge(); oneLarge();
// And one is needed because it needs to choose between oneSmall and // And one is needed because it needs to choose between oneSmall and
@@ -445,25 +445,25 @@ private:
static thread_local RoundingMode mode; static thread_local RoundingMode mode;
// The available ranges for mantissa // The available ranges for mantissa
constexpr static MantissaRange kSMALL_RANGE{MantissaRange::MantissaScale::Small}; static constexpr MantissaRange kSmallRange{MantissaRange::MantissaScale::Small};
static_assert(isPowerOfTen(kSMALL_RANGE.min)); static_assert(isPowerOfTen(kSmallRange.min));
static_assert(kSMALL_RANGE.min == 1'000'000'000'000'000LL); static_assert(kSmallRange.min == 1'000'000'000'000'000LL);
static_assert(kSMALL_RANGE.max == 9'999'999'999'999'999LL); static_assert(kSmallRange.max == 9'999'999'999'999'999LL);
static_assert(kSMALL_RANGE.log == 15); static_assert(kSmallRange.log == 15);
static_assert(kSMALL_RANGE.min < kMAX_REP); static_assert(kSmallRange.min < kMaxRep);
static_assert(kSMALL_RANGE.max < kMAX_REP); static_assert(kSmallRange.max < kMaxRep);
constexpr static MantissaRange kLARGE_RANGE{MantissaRange::MantissaScale::Large}; static constexpr MantissaRange kLargeRange{MantissaRange::MantissaScale::Large};
static_assert(isPowerOfTen(kLARGE_RANGE.min)); static_assert(isPowerOfTen(kLargeRange.min));
static_assert(kLARGE_RANGE.min == 1'000'000'000'000'000'000ULL); static_assert(kLargeRange.min == 1'000'000'000'000'000'000ULL);
static_assert(kLARGE_RANGE.max == internalrep(9'999'999'999'999'999'999ULL)); static_assert(kLargeRange.max == internalrep(9'999'999'999'999'999'999ULL));
static_assert(kLARGE_RANGE.log == 18); static_assert(kLargeRange.log == 18);
static_assert(kLARGE_RANGE.min < kMAX_REP); static_assert(kLargeRange.min < kMaxRep);
static_assert(kLARGE_RANGE.max > kMAX_REP); static_assert(kLargeRange.max > kMaxRep);
// The range for the mantissa when normalized. // The range for the mantissa when normalized.
// Use reference_wrapper to avoid making copies, and prevent accidentally // Use reference_wrapper to avoid making copies, and prevent accidentally
// changing the values inside the range. // changing the values inside the range.
static thread_local std::reference_wrapper<MantissaRange const> kRANGE; static thread_local std::reference_wrapper<MantissaRange const> kRange;
void void
normalize(); normalize();
@@ -471,7 +471,7 @@ private:
/** Normalize Number components to an arbitrary range. /** Normalize Number components to an arbitrary range.
* *
* min/maxMantissa are parameters because this function is used by both * min/maxMantissa are parameters because this function is used by both
* normalize(), which reads from kRANGE, and by normalizeToRange, * normalize(), which reads from kRange, and by normalizeToRange,
* which is public and can accept an arbitrary range from the caller. * which is public and can accept an arbitrary range from the caller.
*/ */
template <class T> template <class T>
@@ -521,7 +521,7 @@ constexpr Number::Number(internalrep mantissa, int exponent, Unchecked) noexcept
{ {
} }
constexpr static Number kNUM_ZERO{}; static constexpr Number kNumZero{};
inline Number::Number(bool negative, internalrep mantissa, int exponent, Normalized) inline Number::Number(bool negative, internalrep mantissa, int exponent, Normalized)
: Number(negative, mantissa, exponent, Unchecked{}) : Number(negative, mantissa, exponent, Unchecked{})
@@ -552,10 +552,10 @@ constexpr Number::rep
Number::mantissa() const noexcept Number::mantissa() const noexcept
{ {
auto m = mantissa_; auto m = mantissa_;
if (m > kMAX_REP) if (m > kMaxRep)
{ {
XRPL_ASSERT_PARTS( XRPL_ASSERT_PARTS(
!isnormal() || (m % 10 == 0 && m / 10 <= kMAX_REP), !isnormal() || (m % 10 == 0 && m / 10 <= kMaxRep),
"xrpl::Number::mantissa", "xrpl::Number::mantissa",
"large normalized mantissa has no remainder"); "large normalized mantissa has no remainder");
m /= 10; m /= 10;
@@ -573,10 +573,10 @@ constexpr int
Number::exponent() const noexcept Number::exponent() const noexcept
{ {
auto e = exponent_; auto e = exponent_;
if (mantissa_ > kMAX_REP) if (mantissa_ > kMaxRep)
{ {
XRPL_ASSERT_PARTS( XRPL_ASSERT_PARTS(
!isnormal() || (mantissa_ % 10 == 0 && mantissa_ / 10 <= kMAX_REP), !isnormal() || (mantissa_ % 10 == 0 && mantissa_ / 10 <= kMaxRep),
"xrpl::Number::exponent", "xrpl::Number::exponent",
"large normalized mantissa has no remainder"); "large normalized mantissa has no remainder");
++e; ++e;
@@ -671,29 +671,29 @@ operator/(Number const& x, Number const& y)
inline Number inline Number
Number::min() noexcept Number::min() noexcept
{ {
return Number{false, kRANGE.get().min, kMIN_EXPONENT, Unchecked{}}; return Number{false, kRange.get().min, kMinExponent, Unchecked{}};
} }
inline Number inline Number
Number::max() noexcept Number::max() noexcept
{ {
return Number{false, std::min(kRANGE.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}}; return Number{false, std::min(kRange.get().max, kMaxRep), kMaxExponent, Unchecked{}};
} }
inline Number inline Number
Number::lowest() noexcept Number::lowest() noexcept
{ {
return Number{true, std::min(kRANGE.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}}; return Number{true, std::min(kRange.get().max, kMaxRep), kMaxExponent, Unchecked{}};
} }
inline bool inline bool
Number::isnormal() const noexcept Number::isnormal() const noexcept
{ {
MantissaRange const& range = kRANGE; MantissaRange const& range = kRange;
auto const absM = mantissa_; auto const absM = mantissa_;
return *this == Number{} || return *this == Number{} ||
(range.min <= absM && absM <= range.max && (absM <= kMAX_REP || absM % 10 == 0) && (range.min <= absM && absM <= range.max && (absM <= kMaxRep || absM % 10 == 0) &&
kMIN_EXPONENT <= exponent_ && exponent_ <= kMAX_EXPONENT); kMinExponent <= exponent_ && exponent_ <= kMaxExponent);
} }
template <Integral64 T> template <Integral64 T>

View File

@@ -57,10 +57,10 @@ template <class T>
std::shared_ptr<T> const& std::shared_ptr<T> const&
SharedWeakCachePointer<T>::getStrong() const SharedWeakCachePointer<T>::getStrong() const
{ {
static std::shared_ptr<T> const kEMPTY; static std::shared_ptr<T> const kEmpty;
if (auto p = std::get_if<std::shared_ptr<T>>(&combo_)) if (auto p = std::get_if<std::shared_ptr<T>>(&combo_))
return *p; return *p;
return kEMPTY; return kEmpty;
} }
template <class T> template <class T>

View File

@@ -34,7 +34,7 @@ template <typename T>
concept SomeChar = std::same_as<std::remove_cvref_t<T>, int8_t> || concept SomeChar = std::same_as<std::remove_cvref_t<T>, int8_t> ||
std::same_as<std::remove_cvref_t<T>, char> || std::same_as<std::remove_cvref_t<T>, uint8_t>; std::same_as<std::remove_cvref_t<T>, char> || std::same_as<std::remove_cvref_t<T>, uint8_t>;
inline constexpr std::array<std::optional<int>, 256> const kDIGIT_LOOKUP_TABLE = []() { inline constexpr std::array<std::optional<int>, 256> const kDigitLookupTable = []() {
std::array<std::optional<int>, 256> t{}; std::array<std::optional<int>, 256> t{};
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
@@ -52,7 +52,7 @@ inline constexpr std::array<std::optional<int>, 256> const kDIGIT_LOOKUP_TABLE =
inline std::optional<int> inline std::optional<int>
hexCharToInt(SomeChar auto hexChar) hexCharToInt(SomeChar auto hexChar)
{ {
return kDIGIT_LOOKUP_TABLE[static_cast<uint8_t>(hexChar)]; return kDigitLookupTable[static_cast<uint8_t>(hexChar)];
} }
} // namespace detail } // namespace detail

View File

@@ -30,8 +30,8 @@ public:
now(); // seconds since xrpld program start now(); // seconds since xrpld program start
private: private:
static std::atomic<rep> kNOW; static std::atomic<rep> kNow;
static std::atomic<bool> kSTOP; static std::atomic<bool> kStop;
struct UpdateThread : private std::thread struct UpdateThread : private std::thread
{ {

View File

@@ -73,12 +73,12 @@ class BaseUInt
static_assert(Bits >= 64, "The length of a base_uint in bits must be at least 64."); static_assert(Bits >= 64, "The length of a base_uint in bits must be at least 64.");
static constexpr std::size_t kWIDTH = Bits / 32; static constexpr std::size_t kWidth = Bits / 32;
// This is really big-endian in byte order. // This is really big-endian in byte order.
// We sometimes use std::uint32_t for speed. // We sometimes use std::uint32_t for speed.
std::array<std::uint32_t, kWIDTH> data_; std::array<std::uint32_t, kWidth> data_;
public: public:
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@@ -86,8 +86,8 @@ public:
// STL Container Interface // STL Container Interface
// //
static std::size_t constexpr kBYTES = Bits / 8; static constexpr std::size_t kBytes = Bits / 8;
static_assert(sizeof(data_) == kBYTES, ""); static_assert(sizeof(data_) == kBytes, "");
using size_type = std::size_t; using size_type = std::size_t;
using difference_type = std::ptrdiff_t; using difference_type = std::ptrdiff_t;
@@ -121,7 +121,7 @@ public:
iterator iterator
end() end()
{ {
return data() + kBYTES; return data() + kBytes;
} }
[[nodiscard]] const_iterator [[nodiscard]] const_iterator
begin() const begin() const
@@ -131,7 +131,7 @@ public:
[[nodiscard]] const_iterator [[nodiscard]] const_iterator
end() const end() const
{ {
return data() + kBYTES; return data() + kBytes;
} }
[[nodiscard]] const_iterator [[nodiscard]] const_iterator
cbegin() const cbegin() const
@@ -141,7 +141,7 @@ public:
[[nodiscard]] const_iterator [[nodiscard]] const_iterator
cend() const cend() const
{ {
return data() + kBYTES; return data() + kBytes;
} }
/** Value hashing function. /** Value hashing function.
@@ -167,7 +167,7 @@ private:
explicit BaseUInt(void const* data, VoidHelper) explicit BaseUInt(void const* data, VoidHelper)
{ {
memcpy(data_.data(), data, kBYTES); memcpy(data_.data(), data, kBytes);
} }
// Helper function to initialize a base_uint from a std::string_view. // Helper function to initialize a base_uint from a std::string_view.
@@ -336,7 +336,7 @@ public:
[[nodiscard]] constexpr int [[nodiscard]] constexpr int
signum() const signum() const
{ {
for (int i = 0; i < kWIDTH; i++) for (int i = 0; i < kWidth; i++)
{ {
if (data_[i] != 0) if (data_[i] != 0)
return 1; return 1;
@@ -348,7 +348,7 @@ public:
bool bool
operator!() const operator!() const
{ {
return *this == beast::kZERO; return *this == beast::kZero;
} }
constexpr BaseUInt constexpr BaseUInt
@@ -356,7 +356,7 @@ public:
{ {
BaseUInt ret; BaseUInt ret;
for (int i = 0; i < kWIDTH; i++) for (int i = 0; i < kWidth; i++)
ret.data_[i] = ~data_[i]; ret.data_[i] = ~data_[i];
return ret; return ret;
@@ -365,7 +365,7 @@ public:
BaseUInt& BaseUInt&
operator=(std::uint64_t uHost) operator=(std::uint64_t uHost)
{ {
*this = beast::kZERO; *this = beast::kZero;
// NOLINTBEGIN(cppcoreguidelines-pro-type-member-init) // NOLINTBEGIN(cppcoreguidelines-pro-type-member-init)
union union
{ {
@@ -375,15 +375,15 @@ public:
// NOLINTEND(cppcoreguidelines-pro-type-member-init) // NOLINTEND(cppcoreguidelines-pro-type-member-init)
// Put in least significant bits. // Put in least significant bits.
ul = boost::endian::native_to_big(uHost); ul = boost::endian::native_to_big(uHost);
data_[kWIDTH - 2] = u[0]; data_[kWidth - 2] = u[0];
data_[kWIDTH - 1] = u[1]; data_[kWidth - 1] = u[1];
return *this; return *this;
} }
BaseUInt& BaseUInt&
operator^=(BaseUInt const& b) operator^=(BaseUInt const& b)
{ {
for (int i = 0; i < kWIDTH; i++) for (int i = 0; i < kWidth; i++)
data_[i] ^= b.data_[i]; data_[i] ^= b.data_[i];
return *this; return *this;
@@ -392,7 +392,7 @@ public:
BaseUInt& BaseUInt&
operator&=(BaseUInt const& b) operator&=(BaseUInt const& b)
{ {
for (int i = 0; i < kWIDTH; i++) for (int i = 0; i < kWidth; i++)
data_[i] &= b.data_[i]; data_[i] &= b.data_[i];
return *this; return *this;
@@ -401,7 +401,7 @@ public:
BaseUInt& BaseUInt&
operator|=(BaseUInt const& b) operator|=(BaseUInt const& b)
{ {
for (int i = 0; i < kWIDTH; i++) for (int i = 0; i < kWidth; i++)
data_[i] |= b.data_[i]; data_[i] |= b.data_[i];
return *this; return *this;
@@ -411,7 +411,7 @@ public:
operator++() operator++()
{ {
// prefix operator // prefix operator
for (int i = kWIDTH - 1; i >= 0; --i) for (int i = kWidth - 1; i >= 0; --i)
{ {
data_[i] = boost::endian::native_to_big(boost::endian::big_to_native(data_[i]) + 1); data_[i] = boost::endian::native_to_big(boost::endian::big_to_native(data_[i]) + 1);
if (data_[i] != 0) if (data_[i] != 0)
@@ -434,7 +434,7 @@ public:
BaseUInt& BaseUInt&
operator--() operator--()
{ {
for (int i = kWIDTH - 1; i >= 0; --i) for (int i = kWidth - 1; i >= 0; --i)
{ {
auto prev = data_[i]; auto prev = data_[i];
data_[i] = boost::endian::native_to_big(boost::endian::big_to_native(data_[i]) - 1); data_[i] = boost::endian::native_to_big(boost::endian::big_to_native(data_[i]) - 1);
@@ -475,7 +475,7 @@ public:
{ {
std::uint64_t carry = 0; std::uint64_t carry = 0;
for (int i = kWIDTH - 1; i >= 0; i--) for (int i = kWidth - 1; i >= 0; i--)
{ {
std::uint64_t const n = carry + boost::endian::big_to_native(data_[i]) + std::uint64_t const n = carry + boost::endian::big_to_native(data_[i]) +
boost::endian::big_to_native(b.data_[i]); boost::endian::big_to_native(b.data_[i]);
@@ -526,10 +526,10 @@ public:
return parseHex(std::string_view{str}); return parseHex(std::string_view{str});
} }
constexpr static std::size_t static constexpr std::size_t
size() size()
{ {
return kBYTES; return kBytes;
} }
BaseUInt<Bits, Tag>& BaseUInt<Bits, Tag>&
@@ -543,17 +543,17 @@ public:
[[nodiscard]] bool [[nodiscard]] bool
isZero() const isZero() const
{ {
return *this == beast::kZERO; return *this == beast::kZero;
} }
[[nodiscard]] bool [[nodiscard]] bool
isNonZero() const isNonZero() const
{ {
return *this != beast::kZERO; return *this != beast::kZero;
} }
void void
zero() zero()
{ {
*this = beast::kZERO; *this = beast::kZero;
} }
}; };
@@ -639,7 +639,7 @@ template <std::size_t Bits, class Tag>
inline std::string inline std::string
toShortString(BaseUInt<Bits, Tag> const& a) toShortString(BaseUInt<Bits, Tag> const& a)
{ {
static_assert(BaseUInt<Bits, Tag>::kBYTES > 4, "For 4 bytes or less, use a native type"); static_assert(BaseUInt<Bits, Tag>::kBytes > 4, "For 4 bytes or less, use a native type");
return strHex(a.cbegin(), a.cbegin() + 4) + "..."; return strHex(a.cbegin(), a.cbegin() + 4) + "...";
} }

View File

@@ -30,10 +30,10 @@ using weeks = std::chrono::duration<int, std::ratio_multiply<days::period, std::
= seconds(946684800) = seconds(946684800)
*/ */
constexpr static std::chrono::seconds kEPOCH_OFFSET = static constexpr std::chrono::seconds kEpochOffset =
date::sys_days{date::year{2000} / 1 / 1} - date::sys_days{date::year{1970} / 1 / 1}; date::sys_days{date::year{2000} / 1 / 1} - date::sys_days{date::year{1970} / 1 / 1};
static_assert(kEPOCH_OFFSET.count() == 946684800); static_assert(kEpochOffset.count() == 946684800);
class NetClock class NetClock
{ {
@@ -60,7 +60,7 @@ to_string(NetClock::time_point tp)
{ {
// 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC // 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC
using namespace std::chrono; using namespace std::chrono;
return to_string(system_clock::time_point{tp.time_since_epoch() + kEPOCH_OFFSET}); return to_string(system_clock::time_point{tp.time_since_epoch() + kEpochOffset});
} }
template <class Duration> template <class Duration>
@@ -77,7 +77,7 @@ toStringIso(NetClock::time_point tp)
// 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC // 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC
// Note, NetClock::duration is seconds, as checked by static_assert // Note, NetClock::duration is seconds, as checked by static_assert
static_assert(std::is_same_v<NetClock::duration::period, std::ratio<1>>); static_assert(std::is_same_v<NetClock::duration::period, std::ratio<1>>);
return toStringIso(date::sys_time<NetClock::duration>{tp.time_since_epoch() + kEPOCH_OFFSET}); return toStringIso(date::sys_time<NetClock::duration>{tp.time_since_epoch() + kEpochOffset});
} }
/** A clock for measuring elapsed time. /** A clock for measuring elapsed time.

View File

@@ -31,9 +31,9 @@ makeSeedPair() noexcept
// state_t(state_t const&) = delete; // state_t(state_t const&) = delete;
// state_t& operator=(state_t const&) = delete; // state_t& operator=(state_t const&) = delete;
}; };
static StateT kSTATE; static StateT kState;
std::scoped_lock const lock(kSTATE.mutex); std::scoped_lock const lock(kState.mutex);
return {kSTATE.dist(kSTATE.gen), kSTATE.dist(kSTATE.gen)}; return {kState.dist(kState.gen), kState.dist(kState.gen)};
} }
} // namespace detail } // namespace detail

View File

@@ -5,7 +5,7 @@
#include <optional> #include <optional>
namespace xrpl { namespace xrpl {
auto constexpr kMULDIV_MAX = std::numeric_limits<std::uint64_t>::max(); constexpr auto kMuldivMax = std::numeric_limits<std::uint64_t>::max();
/** Return value*mul/div accurately. /** Return value*mul/div accurately.
Computes the result of the multiplication and division in Computes the result of the multiplication and division in

View File

@@ -47,7 +47,7 @@ inline beast::xor_shift_engine&
defaultPrng() defaultPrng()
{ {
// This is used to seed the thread-specific PRNGs on demand // This is used to seed the thread-specific PRNGs on demand
static beast::xor_shift_engine kSEEDER = [] { static beast::xor_shift_engine kSeeder = [] {
std::random_device rng; std::random_device rng;
std::uniform_int_distribution<std::uint64_t> distribution{1}; std::uniform_int_distribution<std::uint64_t> distribution{1};
return beast::xor_shift_engine(distribution(rng)); return beast::xor_shift_engine(distribution(rng));
@@ -57,17 +57,17 @@ defaultPrng()
static std::mutex kM; static std::mutex kM;
// The thread-specific PRNGs: // The thread-specific PRNGs:
thread_local beast::xor_shift_engine kENGINE = [] { thread_local beast::xor_shift_engine kEngine = [] {
std::uint64_t seed = 0; std::uint64_t seed = 0;
{ {
std::scoped_lock const lk(kM); std::scoped_lock const lk(kM);
std::uniform_int_distribution<std::uint64_t> distribution{1}; std::uniform_int_distribution<std::uint64_t> distribution{1};
seed = distribution(kSEEDER); seed = distribution(kSeeder);
} }
return beast::xor_shift_engine{seed}; return beast::xor_shift_engine{seed};
}(); }();
return kENGINE; return kEngine;
} }
/** Return a uniformly distributed random integer. /** Return a uniformly distributed random integer.

View File

@@ -22,9 +22,9 @@ safeCast(Src s) noexcept
{ {
static_assert( static_assert(
std::is_signed_v<Dest> || std::is_unsigned_v<Src>, "Cannot cast signed to unsigned"); std::is_signed_v<Dest> || std::is_unsigned_v<Src>, "Cannot cast signed to unsigned");
constexpr unsigned kNOT_SAME = std::is_signed_v<Dest> != std::is_signed_v<Src>; constexpr unsigned kNotSame = std::is_signed_v<Dest> != std::is_signed_v<Src>;
static_assert( static_assert(
sizeof(Dest) >= sizeof(Src) + kNOT_SAME, sizeof(Dest) >= sizeof(Src) + kNotSame,
"Destination is too small to hold all values of source"); "Destination is too small to hold all values of source");
return static_cast<Dest>(s); return static_cast<Dest>(s);
} }

View File

@@ -83,8 +83,8 @@ template <class Facade, class Clock = Facade>
AbstractClock<Facade>& AbstractClock<Facade>&
getAbstractClock() getAbstractClock()
{ {
static detail::AbstractClockWrapper<Facade, Clock> kCLOCK; static detail::AbstractClockWrapper<Facade, Clock> kClock;
return kCLOCK; return kClock;
} }
} // namespace beast } // namespace beast

View File

@@ -21,7 +21,7 @@ setCurrentThreadName(std::string_view newThreadName);
// On Linux, thread names are limited to 16 bytes including the null terminator. // On Linux, thread names are limited to 16 bytes including the null terminator.
// Maximum number of characters is therefore 15. // Maximum number of characters is therefore 15.
constexpr std::size_t kMAX_THREAD_NAME_LENGTH = 15; constexpr std::size_t kMaxThreadNameLength = 15;
/** Sets the name of the caller thread with compile-time size checking. /** Sets the name of the caller thread with compile-time size checking.
@tparam N The size of the string literal including null terminator @tparam N The size of the string literal including null terminator
@@ -34,7 +34,7 @@ template <std::size_t N>
void void
setCurrentThreadName(char const (&newThreadName)[N]) setCurrentThreadName(char const (&newThreadName)[N])
{ {
static_assert(N <= kMAX_THREAD_NAME_LENGTH + 1, "Thread name cannot exceed 15 characters"); static_assert(N <= kMaxThreadNameLength + 1, "Thread name cannot exceed 15 characters");
setCurrentThreadName(std::string_view(newThreadName, N - 1)); setCurrentThreadName(std::string_view(newThreadName, N - 1));
} }

View File

@@ -53,7 +53,7 @@ inline void
maybeReverseBytes(T& t, Hasher&) maybeReverseBytes(T& t, Hasher&)
{ {
maybeReverseBytes( maybeReverseBytes(
t, std::integral_constant<bool, Hasher::kENDIAN != boost::endian::order::native>{}); t, std::integral_constant<bool, Hasher::kEndian != boost::endian::order::native>{});
} }
} // namespace detail } // namespace detail
@@ -154,7 +154,7 @@ struct IsContiguouslyHashable
: public std::integral_constant< : public std::integral_constant<
bool, bool,
IsUniquelyRepresented<T>::value && IsUniquelyRepresented<T>::value &&
(sizeof(T) == 1 || HashAlgorithm::kENDIAN == boost::endian::order::native)> (sizeof(T) == 1 || HashAlgorithm::kEndian == boost::endian::order::native)>
{ {
explicit IsContiguouslyHashable() = default; explicit IsContiguouslyHashable() = default;
}; };

View File

@@ -21,9 +21,9 @@ private:
static_assert(sizeof(std::size_t) == 8, "requires 64-bit std::size_t"); static_assert(sizeof(std::size_t) == 8, "requires 64-bit std::size_t");
// Have an internal buffer to avoid the streaming API // Have an internal buffer to avoid the streaming API
// A 64-byte buffer should to be big enough for us // A 64-byte buffer should to be big enough for us
static constexpr std::size_t kINTERNAL_BUFFER_SIZE = 64; static constexpr std::size_t kInternalBufferSize = 64;
alignas(64) std::array<std::uint8_t, kINTERNAL_BUFFER_SIZE> buffer_{}; alignas(64) std::array<std::uint8_t, kInternalBufferSize> buffer_{};
std::span<std::uint8_t> readBuffer_; std::span<std::uint8_t> readBuffer_;
std::span<std::uint8_t> writeBuffer_; std::span<std::uint8_t> writeBuffer_;
@@ -102,7 +102,7 @@ private:
} }
public: public:
static constexpr auto const kENDIAN = boost::endian::order::native; static constexpr auto kEndian = boost::endian::order::native;
Xxhasher(Xxhasher const&) = delete; Xxhasher(Xxhasher const&) = delete;
Xxhasher& Xxhasher&

View File

@@ -62,7 +62,7 @@ private:
{ {
using run_time = std::pair<std::string, typename clock_type::duration>; using run_time = std::pair<std::string, typename clock_type::duration>;
static constexpr auto kMAX_TOP = 10; static constexpr auto kMaxTop = 10;
std::size_t suites = 0; std::size_t suites = 0;
std::size_t cases = 0; std::size_t cases = 0;
@@ -146,11 +146,11 @@ Reporter<Unused>::Results::add(SuiteResults const& r)
}); });
if (iter != top.end()) if (iter != top.end())
{ {
if (top.size() == kMAX_TOP) if (top.size() == kMaxTop)
top.resize(top.size() - 1); top.resize(top.size() - 1);
top.emplace(iter, r.name, elapsed); top.emplace(iter, r.name, elapsed);
} }
else if (top.size() < kMAX_TOP) else if (top.size() < kMaxTop)
{ {
top.emplace_back(r.name, elapsed); top.emplace_back(r.name, elapsed);
} }

View File

@@ -299,8 +299,8 @@ private:
static Suite** static Suite**
pThisSuite() pThisSuite()
{ {
static Suite* kP_TS = nullptr; // NOLINT TODO static Suite* kPTs = nullptr; // NOLINT TODO
return &kP_TS; return &kPTs;
} }
/** Runs the suite. */ /** Runs the suite. */

View File

@@ -27,7 +27,7 @@ struct Zero
}; };
namespace { namespace {
constexpr Zero kZERO{}; constexpr Zero kZero{};
} // namespace } // namespace
/** Default implementation of signum calls the method on the class. */ /** Default implementation of signum calls the method on the class. */
@@ -102,42 +102,42 @@ template <typename T>
bool bool
operator==(Zero, T const& t) operator==(Zero, T const& t)
{ {
return t == kZERO; return t == kZero;
} }
template <typename T> template <typename T>
bool bool
operator!=(Zero, T const& t) operator!=(Zero, T const& t)
{ {
return t != kZERO; return t != kZero;
} }
template <typename T> template <typename T>
bool bool
operator<(Zero, T const& t) operator<(Zero, T const& t)
{ {
return t > kZERO; return t > kZero;
} }
template <typename T> template <typename T>
bool bool
operator>(Zero, T const& t) operator>(Zero, T const& t)
{ {
return t < kZERO; return t < kZero;
} }
template <typename T> template <typename T>
bool bool
operator>=(Zero, T const& t) operator>=(Zero, T const& t)
{ {
return t <= kZERO; return t <= kZero;
} }
template <typename T> template <typename T>
bool bool
operator<=(Zero, T const& t) operator<=(Zero, T const& t)
{ {
return t >= kZERO; return t >= kZero;
} }
} // namespace beast } // namespace beast

View File

@@ -14,23 +14,23 @@ void
rngfill(void* const buffer, std::size_t const bytes, Generator& g) rngfill(void* const buffer, std::size_t const bytes, Generator& g)
{ {
using result_type = typename Generator::result_type; using result_type = typename Generator::result_type;
constexpr std::size_t kRESULT_SIZE = sizeof(result_type); constexpr std::size_t kResultSize = sizeof(result_type);
std::uint8_t* const bufferStart = static_cast<std::uint8_t*>(buffer); std::uint8_t* const bufferStart = static_cast<std::uint8_t*>(buffer);
std::size_t const completeIterations = bytes / kRESULT_SIZE; std::size_t const completeIterations = bytes / kResultSize;
std::size_t const bytesRemaining = bytes % kRESULT_SIZE; std::size_t const bytesRemaining = bytes % kResultSize;
for (std::size_t count = 0; count < completeIterations; ++count) for (std::size_t count = 0; count < completeIterations; ++count)
{ {
result_type const v = g(); result_type const v = g();
std::size_t const offset = count * kRESULT_SIZE; std::size_t const offset = count * kResultSize;
std::memcpy(bufferStart + offset, &v, kRESULT_SIZE); std::memcpy(bufferStart + offset, &v, kResultSize);
} }
if (bytesRemaining > 0) if (bytesRemaining > 0)
{ {
result_type const v = g(); result_type const v = g();
std::size_t const offset = completeIterations * kRESULT_SIZE; std::size_t const offset = completeIterations * kResultSize;
std::memcpy(bufferStart + offset, &v, bytesRemaining); std::memcpy(bufferStart + offset, &v, bytesRemaining);
} }
} }

View File

@@ -26,12 +26,14 @@ public:
result_type result_type
operator()(); operator()();
static result_type constexpr min() static constexpr result_type
min()
{ {
return std::numeric_limits<result_type>::min(); return std::numeric_limits<result_type>::min();
} }
static result_type constexpr max() static constexpr result_type
max()
{ {
return std::numeric_limits<result_type>::max(); return std::numeric_limits<result_type>::max();
} }

View File

@@ -27,7 +27,7 @@ public:
that were previously considered valid to no longer that were previously considered valid to no longer
be allowed. be allowed.
*/ */
static constexpr std::size_t kMAX_SERIALIZED_CONDITION = 128; static constexpr std::size_t kMaxSerializedCondition = 128;
/** Load a condition from its binary form /** Load a condition from its binary form

View File

@@ -16,7 +16,7 @@ public:
that were previously considered valid to no longer that were previously considered valid to no longer
be allowed. be allowed.
*/ */
static constexpr std::size_t kMAX_SERIALIZED_FULFILLMENT = 256; static constexpr std::size_t kMaxSerializedFulfillment = 256;
/** Load a fulfillment from its binary form /** Load a fulfillment from its binary form

View File

@@ -23,7 +23,7 @@ public:
While future versions of this code will never lower While future versions of this code will never lower
this limit, they may opt to raise it. this limit, they may opt to raise it.
*/ */
static constexpr std::size_t kMAX_PREIMAGE_LENGTH = 128; static constexpr std::size_t kMaxPreimageLength = 128;
/** Parse the payload for a PreimageSha256 condition /** Parse the payload for a PreimageSha256 condition
@@ -65,7 +65,7 @@ public:
return {}; return {};
} }
if (s.size() > kMAX_PREIMAGE_LENGTH) if (s.size() > kMaxPreimageLength)
{ {
ec = Error::PreimageTooLong; ec = Error::PreimageTooLong;
return {}; return {};

View File

@@ -6,7 +6,7 @@ namespace xrpl {
/// Coroutine stack size (1.5 MB). Increased from 1 MB because /// Coroutine stack size (1.5 MB). Increased from 1 MB because
/// ASAN-instrumented deep call stacks exceeded the original limit. /// ASAN-instrumented deep call stacks exceeded the original limit.
constexpr std::size_t kCORO_STACK_SIZE = 1536 * 1024; constexpr std::size_t kCoroStackSize = 1536 * 1024;
template <class F> template <class F>
JobQueue::Coro::Coro(CoroCreateT, JobQueue& jq, JobType type, std::string name, F&& f) JobQueue::Coro::Coro(CoroCreateT, JobQueue& jq, JobType type, std::string name, F&& f)
@@ -14,7 +14,7 @@ JobQueue::Coro::Coro(CoroCreateT, JobQueue& jq, JobType type, std::string name,
, type_(type) , type_(type)
, name_(std::move(name)) , name_(std::move(name))
, coro_( , coro_(
boost::context::protected_fixedsize_stack(kCORO_STACK_SIZE), boost::context::protected_fixedsize_stack(kCoroStackSize),
[this, fn = std::forward<F>(f)](boost::coroutines2::coroutine<void>::push_type& doYield) { [this, fn = std::forward<F>(f)](boost::coroutines2::coroutine<void>::push_type& doYield) {
yield_ = &doYield; yield_ = &doYield;
yield(); yield();

View File

@@ -101,8 +101,8 @@ public:
static JobTypes const& static JobTypes const&
instance() instance()
{ {
static JobTypes const kTYPES; static JobTypes const kTypes;
return kTYPES; return kTypes;
} }
static std::string const& static std::string const&

View File

@@ -67,7 +67,7 @@ public:
[[nodiscard]] std::string [[nodiscard]] std::string
getFormattedErrorMessages() const; getFormattedErrorMessages() const;
static constexpr unsigned kNEST_LIMIT{25}; static constexpr unsigned kNestLimit{25};
private: private:
enum class TokenType { enum class TokenType {

View File

@@ -102,8 +102,8 @@ operator!=(StaticString x, std::string const& y)
/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value. /** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
* *
* This class is a discriminated union wrapper that can represent a: * This class is a discriminated union wrapper that can represent a:
* - signed integer [range: Value::kMIN_INT - Value::kMAX_INT] * - signed integer [range: Value::kMinInt - Value::kMaxInt]
* - unsigned integer (range: 0 - Value::kMAX_UINT) * - unsigned integer (range: 0 - Value::kMaxUInt)
* - double * - double
* - UTF-8 string * - UTF-8 string
* - boolean * - boolean
@@ -138,10 +138,10 @@ public:
using Int = json::Int; using Int = json::Int;
using ArrayIndex = UInt; using ArrayIndex = UInt;
static Value const kNULL; static Value const kNull;
static constexpr Int kMIN_INT = std::numeric_limits<Int>::min(); static constexpr Int kMinInt = std::numeric_limits<Int>::min();
static constexpr Int kMAX_INT = std::numeric_limits<Int>::max(); static constexpr Int kMaxInt = std::numeric_limits<Int>::max();
static constexpr UInt kMAX_UINT = std::numeric_limits<UInt>::max(); static constexpr UInt kMaxUInt = std::numeric_limits<UInt>::max();
private: private:
class CZString class CZString
@@ -472,7 +472,7 @@ operator>=(Value const& x, Value const& y)
class ValueAllocator class ValueAllocator
{ {
public: public:
static constexpr auto kUNKNOWN = (unsigned)-1; static constexpr auto kUnknown = (unsigned)-1;
virtual ~ValueAllocator() = default; virtual ~ValueAllocator() = default;
@@ -481,7 +481,7 @@ public:
virtual void virtual void
releaseMemberName(char* memberName) = 0; releaseMemberName(char* memberName) = 0;
virtual char* virtual char*
duplicateStringValue(char const* value, unsigned int length = kUNKNOWN) = 0; duplicateStringValue(char const* value, unsigned int length = kUnknown) = 0;
virtual void virtual void
releaseStringValue(char* value) = 0; releaseStringValue(char* value) = 0;
}; };

View File

@@ -24,7 +24,7 @@ struct CreateGenesisT
{ {
explicit CreateGenesisT() = default; explicit CreateGenesisT() = default;
}; };
extern CreateGenesisT const kCREATE_GENESIS; extern CreateGenesisT const kCreateGenesis;
/** Holds a ledger. /** Holds a ledger.

View File

@@ -12,7 +12,7 @@ namespace xrpl {
Values should not be duplicated. Values should not be duplicated.
@see getNextLedgerTimeResolution @see getNextLedgerTimeResolution
*/ */
std::chrono::seconds constexpr kLEDGER_POSSIBLE_TIME_RESOLUTIONS[] = { constexpr std::chrono::seconds kLedgerPossibleTimeResolutions[] = {
std::chrono::seconds{10}, std::chrono::seconds{10},
std::chrono::seconds{20}, std::chrono::seconds{20},
std::chrono::seconds{30}, std::chrono::seconds{30},
@@ -21,16 +21,16 @@ std::chrono::seconds constexpr kLEDGER_POSSIBLE_TIME_RESOLUTIONS[] = {
std::chrono::seconds{120}}; std::chrono::seconds{120}};
//! Initial resolution of ledger close time. //! Initial resolution of ledger close time.
auto constexpr kLEDGER_DEFAULT_TIME_RESOLUTION = kLEDGER_POSSIBLE_TIME_RESOLUTIONS[2]; constexpr auto kLedgerDefaultTimeResolution = kLedgerPossibleTimeResolutions[2];
//! Close time resolution in genesis ledger //! Close time resolution in genesis ledger
auto constexpr kLEDGER_GENESIS_TIME_RESOLUTION = kLEDGER_POSSIBLE_TIME_RESOLUTIONS[0]; constexpr auto kLedgerGenesisTimeResolution = kLedgerPossibleTimeResolutions[0];
//! How often we increase the close time resolution (in numbers of ledgers) //! How often we increase the close time resolution (in numbers of ledgers)
auto constexpr kINCREASE_LEDGER_TIME_RESOLUTION_EVERY = 8; constexpr auto kIncreaseLedgerTimeResolutionEvery = 8;
//! How often we decrease the close time resolution (in numbers of ledgers) //! How often we decrease the close time resolution (in numbers of ledgers)
auto constexpr kDECREASE_LEDGER_TIME_RESOLUTION_EVERY = 1; constexpr auto kDecreaseLedgerTimeResolutionEvery = 1;
/** Calculates the close time resolution for the specified ledger. /** Calculates the close time resolution for the specified ledger.
@@ -46,7 +46,7 @@ auto constexpr kDECREASE_LEDGER_TIME_RESOLUTION_EVERY = 1;
@param ledgerSeq the sequence number of the new ledger @param ledgerSeq the sequence number of the new ledger
@pre previousResolution must be a valid bin @pre previousResolution must be a valid bin
from @ref kLEDGER_POSSIBLE_TIME_RESOLUTIONS from @ref kLedgerPossibleTimeResolutions
@tparam Rep Type representing number of ticks in std::chrono::duration @tparam Rep Type representing number of ticks in std::chrono::duration
@tparam Period An std::ratio representing tick period in @tparam Period An std::ratio representing tick period in
@@ -67,30 +67,30 @@ getNextLedgerTimeResolution(
using namespace std::chrono; using namespace std::chrono;
// Find the current resolution: // Find the current resolution:
auto iter = std::find( auto iter = std::find(
std::begin(kLEDGER_POSSIBLE_TIME_RESOLUTIONS), std::begin(kLedgerPossibleTimeResolutions),
std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS), std::end(kLedgerPossibleTimeResolutions),
previousResolution); previousResolution);
XRPL_ASSERT( XRPL_ASSERT(
iter != std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS), iter != std::end(kLedgerPossibleTimeResolutions),
"xrpl::getNextLedgerTimeResolution : found time resolution"); "xrpl::getNextLedgerTimeResolution : found time resolution");
// This should never happen, but just as a precaution // This should never happen, but just as a precaution
if (iter == std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS)) if (iter == std::end(kLedgerPossibleTimeResolutions))
return previousResolution; return previousResolution;
// If we did not previously agree, we try to decrease the resolution to // If we did not previously agree, we try to decrease the resolution to
// improve the chance that we will agree now. // improve the chance that we will agree now.
if (!previousAgree && (ledgerSeq % Seq{kDECREASE_LEDGER_TIME_RESOLUTION_EVERY} == Seq{0})) if (!previousAgree && (ledgerSeq % Seq{kDecreaseLedgerTimeResolutionEvery} == Seq{0}))
{ {
if (++iter != std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS)) if (++iter != std::end(kLedgerPossibleTimeResolutions))
return *iter; return *iter;
} }
// If we previously agreed, we try to increase the resolution to determine // If we previously agreed, we try to increase the resolution to determine
// if we can continue to agree. // if we can continue to agree.
if (previousAgree && (ledgerSeq % Seq{kINCREASE_LEDGER_TIME_RESOLUTION_EVERY} == Seq{0})) if (previousAgree && (ledgerSeq % Seq{kIncreaseLedgerTimeResolutionEvery} == Seq{0}))
{ {
if (iter-- != std::begin(kLEDGER_POSSIBLE_TIME_RESOLUTIONS)) if (iter-- != std::begin(kLedgerPossibleTimeResolutions))
return *iter; return *iter;
} }

View File

@@ -23,7 +23,7 @@ namespace xrpl {
inline constexpr struct OpenLedgerT inline constexpr struct OpenLedgerT
{ {
explicit constexpr OpenLedgerT() = default; explicit constexpr OpenLedgerT() = default;
} kOPEN_LEDGER{}; } kOpenLedger{};
/** Batch view construction tag. /** Batch view construction tag.
@@ -33,7 +33,7 @@ inline constexpr struct OpenLedgerT
inline constexpr struct BatchViewT inline constexpr struct BatchViewT
{ {
explicit constexpr BatchViewT() = default; explicit constexpr BatchViewT() = default;
} kBATCH_VIEW{}; } kBatchView{};
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -47,7 +47,7 @@ private:
// Initial size for the monotonic_buffer_resource used for allocations // Initial size for the monotonic_buffer_resource used for allocations
// The size was chosen from the old `qalloc` code (which this replaces). // The size was chosen from the old `qalloc` code (which this replaces).
// It is unclear how the size initially chosen in qalloc. // It is unclear how the size initially chosen in qalloc.
static constexpr size_t kINITIAL_BUFFER_SIZE = kilobytes(256); static constexpr size_t kInitialBufferSize = kilobytes(256);
class TxsIterImpl; class TxsIterImpl;
@@ -139,7 +139,7 @@ public:
std::shared_ptr<void const> hold = nullptr); std::shared_ptr<void const> hold = nullptr);
OpenView(OpenLedgerT, Rules const& rules, std::shared_ptr<ReadView const> const& base) OpenView(OpenLedgerT, Rules const& rules, std::shared_ptr<ReadView const> const& base)
: OpenView(kOPEN_LEDGER, &*base, rules, base) : OpenView(kOpenLedger, &*base, rules, base)
{ {
} }

View File

@@ -19,16 +19,16 @@ public:
// Initial size for the monotonic_buffer_resource used for allocations // Initial size for the monotonic_buffer_resource used for allocations
// The size was chosen from the old `qalloc` code (which this replaces). // The size was chosen from the old `qalloc` code (which this replaces).
// It is unclear how the size initially chosen in qalloc. // It is unclear how the size initially chosen in qalloc.
static constexpr size_t kINITIAL_BUFFER_SIZE = kilobytes(256); static constexpr size_t kInitialBufferSize = kilobytes(256);
RawStateTable() RawStateTable()
: monotonic_resource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>( : monotonic_resource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>(
kINITIAL_BUFFER_SIZE)} kInitialBufferSize)}
, items_{monotonic_resource_.get()} {}; , items_{monotonic_resource_.get()} {};
RawStateTable(RawStateTable const& rhs) RawStateTable(RawStateTable const& rhs)
: monotonic_resource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>( : monotonic_resource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>(
kINITIAL_BUFFER_SIZE)} kInitialBufferSize)}
, items_{rhs.items_, monotonic_resource_.get()} , items_{rhs.items_, monotonic_resource_.get()}
, dropsDestroyed_{rhs.dropsDestroyed_} {}; , dropsDestroyed_{rhs.dropsDestroyed_} {};

View File

@@ -25,11 +25,11 @@ namespace detail {
Number Number
reduceOffer(auto const& amount) reduceOffer(auto const& amount)
{ {
static Number const kREDUCED_OFFER_PCT(9999, -4); static Number const kReducedOfferPct(9999, -4);
// Make sure the result is always less than amount or zero. // Make sure the result is always less than amount or zero.
NumberRoundModeGuard const mg(Number::RoundingMode::TowardsZero); NumberRoundModeGuard const mg(Number::RoundingMode::TowardsZero);
return amount * kREDUCED_OFFER_PCT; return amount * kReducedOfferPct;
} }
} // namespace detail } // namespace detail
@@ -177,7 +177,7 @@ getAMMOfferStartWithTakerGets(
Quality const& targetQuality, Quality const& targetQuality,
std::uint16_t const& tfee) std::uint16_t const& tfee)
{ {
if (targetQuality.rate() == beast::kZERO) if (targetQuality.rate() == beast::kZero)
return std::nullopt; return std::nullopt;
NumberRoundModeGuard const mg(Number::RoundingMode::ToNearest); NumberRoundModeGuard const mg(Number::RoundingMode::ToNearest);
@@ -244,7 +244,7 @@ getAMMOfferStartWithTakerPays(
Quality const& targetQuality, Quality const& targetQuality,
std::uint16_t tfee) std::uint16_t tfee)
{ {
if (targetQuality.rate() == beast::kZERO) if (targetQuality.rate() == beast::kZero)
return std::nullopt; return std::nullopt;
NumberRoundModeGuard const mg(Number::RoundingMode::ToNearest); NumberRoundModeGuard const mg(Number::RoundingMode::ToNearest);

View File

@@ -70,21 +70,21 @@ escrowUnlockApplyHelper<Issue>(
initialBalance.get<Issue>().account = noAccount(); initialBalance.get<Issue>().account = noAccount();
if (TER const ter = trustCreate( if (TER const ter = trustCreate(
view, // payment sandbox view, // payment sandbox
recvLow, // is dest low? recvLow, // is dest low?
issuer, // source issuer, // source
receiver, // destination receiver, // destination
trustLineKey.key, // ledger index trustLineKey.key, // ledger index
sleDest, // Account to add to sleDest, // Account to add to
false, // authorize account false, // authorize account
(sleDest->getFlags() & lsfDefaultRipple) == 0, // !sleDest->isFlag(lsfDefaultRipple), //
false, // freeze trust line false, // freeze trust line
false, // deep freeze trust line false, // deep freeze trust line
initialBalance, // zero initial balance initialBalance, // zero initial balance
Issue(currency, receiver), // limit of zero Issue(currency, receiver), // limit of zero
0, // quality in 0, // quality in
0, // quality out 0, // quality out
journal); // journal journal); // journal
!isTesSuccess(ter)) !isTesSuccess(ter))
{ {
return ter; // LCOV_EXCL_LINE return ter; // LCOV_EXCL_LINE
@@ -111,7 +111,7 @@ escrowUnlockApplyHelper<Issue>(
// whereas in a normal payment, the transfer fee is taken on top of the // whereas in a normal payment, the transfer fee is taken on top of the
// sending amount. // sending amount.
auto finalAmt = amount; auto finalAmt = amount;
if ((!senderIssuer && !receiverIssuer) && lockedRate != kPARITY_RATE) if ((!senderIssuer && !receiverIssuer) && lockedRate != kParityRate)
{ {
// compute transfer fee, if any // compute transfer fee, if any
auto const xferFee = auto const xferFee =
@@ -211,7 +211,7 @@ escrowUnlockApplyHelper<MPTIssue>(
// whereas in a normal payment, the transfer fee is taken on top of the // whereas in a normal payment, the transfer fee is taken on top of the
// sending amount. // sending amount.
auto finalAmt = amount; auto finalAmt = amount;
if ((!senderIssuer && !receiverIssuer) && lockedRate != kPARITY_RATE) if ((!senderIssuer && !receiverIssuer) && lockedRate != kParityRate)
{ {
// compute transfer fee, if any // compute transfer fee, if any
auto const xferFee = amount.value() - divideRound(amount, lockedRate, amount.asset(), true); auto const xferFee = amount.value() - divideRound(amount, lockedRate, amount.asset(), true);

View File

@@ -10,7 +10,7 @@ namespace xrpl {
bool bool
checkLendingProtocolDependencies(Rules const& rules, STTx const& tx); checkLendingProtocolDependencies(Rules const& rules, STTx const& tx);
static constexpr std::uint32_t kSECONDS_IN_YEAR = 365 * 24 * 60 * 60; static constexpr std::uint32_t kSecondsInYear = 365 * 24 * 60 * 60;
Number Number
loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval); loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval);
@@ -42,14 +42,14 @@ struct LoanPaymentParts
// The amount of principal paid that reduces the loan balance. // The amount of principal paid that reduces the loan balance.
// This amount is subtracted from sfPrincipalOutstanding in the Loan object // This amount is subtracted from sfPrincipalOutstanding in the Loan object
// and paid to the Vault // and paid to the Vault
Number principalPaid = kNUM_ZERO; Number principalPaid = kNumZero;
// The total amount of interest paid to the Vault. // The total amount of interest paid to the Vault.
// This includes: // This includes:
// - Tracked interest from the amortization schedule // - Tracked interest from the amortization schedule
// - Untracked interest (e.g., late payment penalty interest) // - Untracked interest (e.g., late payment penalty interest)
// This value is always non-negative. // This value is always non-negative.
Number interestPaid = kNUM_ZERO; Number interestPaid = kNumZero;
// The change in the loan's total value outstanding. // The change in the loan's total value outstanding.
// - If valueChange < 0: Loan value decreased // - If valueChange < 0: Loan value decreased
@@ -62,7 +62,7 @@ struct LoanPaymentParts
// - Late payments add penalty interest to the loan value // - Late payments add penalty interest to the loan value
// - Early full payment may increase or decrease the loan value based on // - Early full payment may increase or decrease the loan value based on
// terms // terms
Number valueChange = kNUM_ZERO; Number valueChange = kNumZero;
/* The total amount of fees paid to the Broker. /* The total amount of fees paid to the Broker.
* This includes: * This includes:
@@ -70,7 +70,7 @@ struct LoanPaymentParts
* - Untracked fees (e.g., late payment fees, service fees, origination * - Untracked fees (e.g., late payment fees, service fees, origination
* fees) This value is always non-negative. * fees) This value is always non-negative.
*/ */
Number feePaid = kNUM_ZERO; Number feePaid = kNumZero;
LoanPaymentParts& LoanPaymentParts&
operator+=(LoanPaymentParts const& other); operator+=(LoanPaymentParts const& other);
@@ -161,7 +161,7 @@ adjustImpreciseNumber(
{ {
value = roundToAsset(asset, value + adjustment, vaultScale); value = roundToAsset(asset, value + adjustment, vaultScale);
if (*value < beast::kZERO) if (*value < beast::kZero)
value = 0; value = 0;
} }
@@ -169,7 +169,7 @@ inline int
getAssetsTotalScale(SLE::const_ref vaultSle) getAssetsTotalScale(SLE::const_ref vaultSle)
{ {
if (!vaultSle) if (!vaultSle)
return Number::kMIN_EXPONENT - 1; // LCOV_EXCL_LINE return Number::kMinExponent - 1; // LCOV_EXCL_LINE
return scale(vaultSle->at(sfAssetsTotal), vaultSle->at(sfAsset)); return scale(vaultSle->at(sfAssetsTotal), vaultSle->at(sfAsset));
} }
@@ -311,7 +311,7 @@ struct ExtendedPaymentComponents : public PaymentComponents
// borrower is sufficient to cover all components of the payment. // borrower is sufficient to cover all components of the payment.
Number totalDue; Number totalDue;
ExtendedPaymentComponents(PaymentComponents const& p, Number fee, Number interest = kNUM_ZERO) ExtendedPaymentComponents(PaymentComponents const& p, Number fee, Number interest = kNumZero)
: PaymentComponents(p) : PaymentComponents(p)
, untrackedManagementFee(fee) , untrackedManagementFee(fee)
, untrackedInterest(interest) , untrackedInterest(interest)

View File

@@ -20,7 +20,7 @@ class HTTPClient
public: public:
explicit HTTPClient() = default; explicit HTTPClient() = default;
static constexpr auto kMAX_CLIENT_HEADER_BYTES = kilobytes(32); static constexpr auto kMaxClientHeaderBytes = kilobytes(32);
static void static void
initializeSSLContext( initializeSSLContext(

View File

@@ -29,7 +29,7 @@ enum class NodeObjectType : std::uint32_t {
class NodeObject : public CountedObject<NodeObject> class NodeObject : public CountedObject<NodeObject>
{ {
public: public:
static constexpr std::size_t kKEY_BYTES = 32; static constexpr std::size_t kKeyBytes = 32;
private: private:
// This hack is used to make the constructor effectively private // This hack is used to make the constructor effectively private

View File

@@ -9,13 +9,13 @@ namespace xrpl::NodeStore {
// This is only used to pre-allocate the array for // This is only used to pre-allocate the array for
// batch objects and does not affect the amount written. // batch objects and does not affect the amount written.
// //
static constexpr auto kBATCH_WRITE_PREALLOCATION_SIZE = 256; static constexpr auto kBatchWritePreallocationSize = 256;
// This sets a limit on the maximum number of writes // This sets a limit on the maximum number of writes
// in a batch. Actual usage can be twice this since // in a batch. Actual usage can be twice this since
// we have a new batch growing as we write the old. // we have a new batch growing as we write the old.
// //
static constexpr auto kBATCH_WRITE_LIMIT_SIZE = 65536; static constexpr auto kBatchWriteLimitSize = 65536;
/** Return codes from Backend operations. */ /** Return codes from Backend operations. */
enum class Status { enum class Status {

View File

@@ -55,7 +55,7 @@ lz4Compress(void const* in, std::size_t inSize, BufferFactory&& bf)
using std::runtime_error; using std::runtime_error;
using namespace nudb::detail; using namespace nudb::detail;
std::pair<void const*, std::size_t> result; std::pair<void const*, std::size_t> result;
std::array<std::uint8_t, varint_traits<std::size_t>::kMAX> vi{}; std::array<std::uint8_t, varint_traits<std::size_t>::kMax> vi{};
auto const n = writeVarint(vi.data(), inSize); auto const n = writeVarint(vi.data(), inSize);
auto const outMax = LZ4_compressBound(inSize); auto const outMax = LZ4_compressBound(inSize);
std::uint8_t* out = reinterpret_cast<std::uint8_t*>(bf(n + outMax)); std::uint8_t* out = reinterpret_cast<std::uint8_t*>(bf(n + outMax));
@@ -254,12 +254,12 @@ nodeobjectCompress(void const* in, std::size_t inSize, BufferFactory&& bf)
} }
} }
std::array<std::uint8_t, varint_traits<std::size_t>::kMAX> vi{}; std::array<std::uint8_t, varint_traits<std::size_t>::kMax> vi{};
constexpr std::size_t kCODEC_TYPE = 1; static constexpr std::size_t kCodecType = 1;
auto const vn = writeVarint(vi.data(), kCODEC_TYPE); auto const vn = writeVarint(vi.data(), kCodecType);
std::pair<void const*, std::size_t> result; std::pair<void const*, std::size_t> result;
switch (kCODEC_TYPE) switch (kCodecType)
{ {
// case 0 was uncompressed data; we always compress now. // case 0 was uncompressed data; we always compress now.
case 1: // lz4 case 1: // lz4
@@ -275,7 +275,7 @@ nodeobjectCompress(void const* in, std::size_t inSize, BufferFactory&& bf)
break; break;
} }
default: default:
Throw<std::logic_error>("nodeobject codec: unknown=" + std::to_string(kCODEC_TYPE)); Throw<std::logic_error>("nodeobject codec: unknown=" + std::to_string(kCodecType));
}; };
return result; return result;
} }

View File

@@ -25,7 +25,7 @@ struct varint_traits<T, true>
{ {
explicit varint_traits() = default; explicit varint_traits() = default;
static std::size_t constexpr kMAX = (8 * sizeof(T) + 6) / 7; static constexpr std::size_t kMax = (8 * sizeof(T) + 6) / 7;
}; };
// Returns: Number of bytes consumed or 0 on error, // Returns: Number of bytes consumed or 0 on error,

View File

@@ -8,21 +8,21 @@
namespace xrpl { namespace xrpl {
std::uint16_t constexpr kTRADING_FEE_THRESHOLD = 1000; // 1% constexpr std::uint16_t kTradingFeeThreshold = 1000; // 1%
// Auction slot // Auction slot
std::uint32_t constexpr kTOTAL_TIME_SLOT_SECS = 24 * 3600; constexpr std::uint32_t kTotalTimeSlotSecs = 24 * 3600;
std::uint16_t constexpr kAUCTION_SLOT_TIME_INTERVALS = 20; constexpr std::uint16_t kAuctionSlotTimeIntervals = 20;
std::uint16_t constexpr kAUCTION_SLOT_MAX_AUTH_ACCOUNTS = 4; constexpr std::uint16_t kAuctionSlotMaxAuthAccounts = 4;
std::uint32_t constexpr kAUCTION_SLOT_FEE_SCALE_FACTOR = 100000; constexpr std::uint32_t kAuctionSlotFeeScaleFactor = 100000;
std::uint32_t constexpr kAUCTION_SLOT_DISCOUNTED_FEE_FRACTION = 10; constexpr std::uint32_t kAuctionSlotDiscountedFeeFraction = 10;
std::uint32_t constexpr kAUCTION_SLOT_MIN_FEE_FRACTION = 25; constexpr std::uint32_t kAuctionSlotMinFeeFraction = 25;
std::uint32_t constexpr kAUCTION_SLOT_INTERVAL_DURATION = constexpr std::uint32_t kAuctionSlotIntervalDuration =
kTOTAL_TIME_SLOT_SECS / kAUCTION_SLOT_TIME_INTERVALS; kTotalTimeSlotSecs / kAuctionSlotTimeIntervals;
// Votes // Votes
std::uint16_t constexpr kVOTE_MAX_SLOTS = 8; constexpr std::uint16_t kVoteMaxSlots = 8;
std::uint32_t constexpr kVOTE_WEIGHT_SCALE_FACTOR = 100000; constexpr std::uint32_t kVoteWeightScaleFactor = 100000;
class STObject; class STObject;
class STAmount; class STAmount;
@@ -77,7 +77,7 @@ ammEnabled(Rules const&);
inline Number inline Number
getFee(std::uint16_t tfee) getFee(std::uint16_t tfee)
{ {
return Number{tfee} / kAUCTION_SLOT_FEE_SCALE_FACTOR; return Number{tfee} / kAuctionSlotFeeScaleFactor;
} }
/** Get fee multiplier (1 - tfee) /** Get fee multiplier (1 - tfee)

View File

@@ -69,7 +69,7 @@ toIssuer(AccountID&, std::string const&);
inline bool inline bool
isXRP(AccountID const& c) isXRP(AccountID const& c)
{ {
return c == beast::kZERO; return c == beast::kZero;
} }
// DEPRECATED // DEPRECATED

View File

@@ -96,9 +96,9 @@ inline MPTAmount
toAmount<MPTAmount>(STAmount const& amt) toAmount<MPTAmount>(STAmount const& amt)
{ {
XRPL_ASSERT( XRPL_ASSERT(
amt.holds<MPTIssue>() && amt.mantissa() <= kMAX_MP_TOKEN_AMOUNT && amt.exponent() == 0, amt.holds<MPTIssue>() && amt.mantissa() <= kMaxMpTokenAmount && amt.exponent() == 0,
"xrpl::toAmount<MPTAmount> : maximum mantissa"); "xrpl::toAmount<MPTAmount> : maximum mantissa");
if (amt.mantissa() > kMAX_MP_TOKEN_AMOUNT || amt.exponent() != 0) if (amt.mantissa() > kMaxMpTokenAmount || amt.exponent() != 0)
Throw<std::runtime_error>("toAmount<MPTAmount>: invalid mantissa or exponent"); Throw<std::runtime_error>("toAmount<MPTAmount>: invalid mantissa or exponent");
bool const isNeg = amt.negative(); bool const isNeg = amt.negative();
std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa();
@@ -167,8 +167,8 @@ toAmount(Asset const& asset, Number const& n, Number::RoundingMode mode = Number
} }
else else
{ {
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>; static constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
static_assert(kALWAYS_FALSE, "Unsupported type for toAmount"); static_assert(kAlwaysFalse, "Unsupported type for toAmount");
} }
} }
@@ -178,30 +178,30 @@ toMaxAmount(Asset const& asset)
{ {
if constexpr (std::is_same_v<IOUAmount, T>) if constexpr (std::is_same_v<IOUAmount, T>)
{ {
return IOUAmount(STAmount::kMAX_VALUE, STAmount::kMAX_OFFSET); return IOUAmount(STAmount::kMaxValue, STAmount::kMaxOffset);
} }
else if constexpr (std::is_same_v<XRPAmount, T>) else if constexpr (std::is_same_v<XRPAmount, T>)
{ {
return XRPAmount(static_cast<std::int64_t>(STAmount::kMAX_NATIVE_N)); return XRPAmount(static_cast<std::int64_t>(STAmount::kMaxNativeN));
} }
else if constexpr (std::is_same_v<MPTAmount, T>) else if constexpr (std::is_same_v<MPTAmount, T>)
{ {
return MPTAmount(kMAX_MP_TOKEN_AMOUNT); return MPTAmount(kMaxMpTokenAmount);
} }
else if constexpr (std::is_same_v<STAmount, T>) else if constexpr (std::is_same_v<STAmount, T>)
{ {
return asset.visit( return asset.visit(
[](Issue const& issue) { [](Issue const& issue) {
if (isXRP(issue)) if (isXRP(issue))
return STAmount(issue, static_cast<std::int64_t>(STAmount::kMAX_NATIVE_N)); return STAmount(issue, static_cast<std::int64_t>(STAmount::kMaxNativeN));
return STAmount(issue, STAmount::kMAX_VALUE, STAmount::kMAX_OFFSET); return STAmount(issue, STAmount::kMaxValue, STAmount::kMaxOffset);
}, },
[](MPTIssue const& issue) { return STAmount(issue, kMAX_MP_TOKEN_AMOUNT); }); [](MPTIssue const& issue) { return STAmount(issue, kMaxMpTokenAmount); });
} }
else else
{ {
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>; static constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
static_assert(kALWAYS_FALSE, "Unsupported type for toMaxAmount"); static_assert(kAlwaysFalse, "Unsupported type for toMaxAmount");
} }
} }
@@ -233,8 +233,8 @@ getAsset(T const& amt)
} }
else else
{ {
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>; static constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
static_assert(kALWAYS_FALSE, "Unsupported type for getIssue"); static_assert(kAlwaysFalse, "Unsupported type for getIssue");
} }
} }
@@ -260,8 +260,8 @@ get(STAmount const& a)
} }
else else
{ {
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>; constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
static_assert(kALWAYS_FALSE, "Unsupported type for get"); static_assert(kAlwaysFalse, "Unsupported type for get");
} }
} }

View File

@@ -35,49 +35,49 @@ namespace xrpl {
namespace RPC { namespace RPC {
template <unsigned int Version> template <unsigned int Version>
constexpr static std::integral_constant<unsigned, Version> kAPI_VERSION = {}; static constexpr std::integral_constant<unsigned, Version> kApiVersion = {};
constexpr static auto kAPI_INVALID_VERSION = kAPI_VERSION<0>; static constexpr auto kApiInvalidVersion = kApiVersion<0>;
constexpr static auto kAPI_MINIMUM_SUPPORTED_VERSION = kAPI_VERSION<1>; static constexpr auto kApiMinimumSupportedVersion = kApiVersion<1>;
constexpr static auto kAPI_MAXIMUM_SUPPORTED_VERSION = kAPI_VERSION<2>; static constexpr auto kApiMaximumSupportedVersion = kApiVersion<2>;
constexpr static auto kAPI_VERSION_IF_UNSPECIFIED = kAPI_VERSION<1>; static constexpr auto kApiVersionIfUnspecified = kApiVersion<1>;
constexpr static auto kAPI_COMMAND_LINE_VERSION = kAPI_VERSION<1>; // TODO Bump to 2 later static constexpr auto kApiCommandLineVersion = kApiVersion<1>; // TODO Bump to 2 later
constexpr static auto kAPI_BETA_VERSION = kAPI_VERSION<3>; static constexpr auto kApiBetaVersion = kApiVersion<3>;
constexpr static auto kAPI_MAXIMUM_VALID_VERSION = kAPI_BETA_VERSION; static constexpr auto kApiMaximumValidVersion = kApiBetaVersion;
static_assert(kAPI_INVALID_VERSION < kAPI_MINIMUM_SUPPORTED_VERSION); static_assert(kApiInvalidVersion < kApiMinimumSupportedVersion);
static_assert( static_assert(
kAPI_VERSION_IF_UNSPECIFIED >= kAPI_MINIMUM_SUPPORTED_VERSION && kApiVersionIfUnspecified >= kApiMinimumSupportedVersion &&
kAPI_VERSION_IF_UNSPECIFIED <= kAPI_MAXIMUM_SUPPORTED_VERSION); kApiVersionIfUnspecified <= kApiMaximumSupportedVersion);
static_assert( static_assert(
kAPI_COMMAND_LINE_VERSION >= kAPI_MINIMUM_SUPPORTED_VERSION && kApiCommandLineVersion >= kApiMinimumSupportedVersion &&
kAPI_COMMAND_LINE_VERSION <= kAPI_MAXIMUM_SUPPORTED_VERSION); kApiCommandLineVersion <= kApiMaximumSupportedVersion);
static_assert(kAPI_MAXIMUM_SUPPORTED_VERSION >= kAPI_MINIMUM_SUPPORTED_VERSION); static_assert(kApiMaximumSupportedVersion >= kApiMinimumSupportedVersion);
static_assert(kAPI_BETA_VERSION >= kAPI_MAXIMUM_SUPPORTED_VERSION); static_assert(kApiBetaVersion >= kApiMaximumSupportedVersion);
static_assert(kAPI_MAXIMUM_VALID_VERSION >= kAPI_MAXIMUM_SUPPORTED_VERSION); static_assert(kApiMaximumValidVersion >= kApiMaximumSupportedVersion);
inline void inline void
setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled) setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled)
{ {
XRPL_ASSERT(apiVersion != kAPI_INVALID_VERSION, "xrpl::RPC::setVersion : input is valid"); XRPL_ASSERT(apiVersion != kApiInvalidVersion, "xrpl::RPC::setVersion : input is valid");
auto& retObj = parent[jss::version] = json::ValueType::Object; auto& retObj = parent[jss::version] = json::ValueType::Object;
if (apiVersion == kAPI_VERSION_IF_UNSPECIFIED) if (apiVersion == kApiVersionIfUnspecified)
{ {
// API version numbers used in API version 1 // API version numbers used in API version 1
static beast::SemanticVersion const kFIRST_VERSION{"1.0.0"}; static beast::SemanticVersion const kFirstVersion{"1.0.0"};
static beast::SemanticVersion const kGOOD_VERSION{"1.0.0"}; static beast::SemanticVersion const kGoodVersion{"1.0.0"};
static beast::SemanticVersion const kLAST_VERSION{"1.0.0"}; static beast::SemanticVersion const kLastVersion{"1.0.0"};
retObj[jss::first] = kFIRST_VERSION.print(); retObj[jss::first] = kFirstVersion.print();
retObj[jss::good] = kGOOD_VERSION.print(); retObj[jss::good] = kGoodVersion.print();
retObj[jss::last] = kLAST_VERSION.print(); retObj[jss::last] = kLastVersion.print();
} }
else else
{ {
retObj[jss::first] = kAPI_MINIMUM_SUPPORTED_VERSION.value; retObj[jss::first] = kApiMinimumSupportedVersion.value;
retObj[jss::last] = betaEnabled ? kAPI_BETA_VERSION : kAPI_MAXIMUM_SUPPORTED_VERSION; retObj[jss::last] = betaEnabled ? kApiBetaVersion : kApiMaximumSupportedVersion;
} }
} }
@@ -98,9 +98,9 @@ setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled)
inline unsigned int inline unsigned int
getAPIVersionNumber(json::Value const& jv, bool betaEnabled) getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
{ {
static json::Value const kMIN_VERSION(RPC::kAPI_MINIMUM_SUPPORTED_VERSION); static json::Value const kMinVersion(RPC::kApiMinimumSupportedVersion);
json::Value const maxVersion( json::Value const maxVersion(
betaEnabled ? RPC::kAPI_BETA_VERSION : RPC::kAPI_MAXIMUM_SUPPORTED_VERSION); betaEnabled ? RPC::kApiBetaVersion : RPC::kApiMaximumSupportedVersion);
if (jv.isObject()) if (jv.isObject())
{ {
@@ -109,18 +109,18 @@ getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
auto const specifiedVersion = jv[jss::api_version]; auto const specifiedVersion = jv[jss::api_version];
if (!specifiedVersion.isInt() && !specifiedVersion.isUInt()) if (!specifiedVersion.isInt() && !specifiedVersion.isUInt())
{ {
return RPC::kAPI_INVALID_VERSION; return RPC::kApiInvalidVersion;
} }
auto const specifiedVersionInt = specifiedVersion.asInt(); auto const specifiedVersionInt = specifiedVersion.asInt();
if (specifiedVersionInt < kMIN_VERSION || specifiedVersionInt > maxVersion) if (specifiedVersionInt < kMinVersion || specifiedVersionInt > maxVersion)
{ {
return RPC::kAPI_INVALID_VERSION; return RPC::kApiInvalidVersion;
} }
return specifiedVersionInt; return specifiedVersionInt;
} }
} }
return RPC::kAPI_VERSION_IF_UNSPECIFIED; return RPC::kApiVersionIfUnspecified;
} }
} // namespace RPC } // namespace RPC
@@ -128,33 +128,33 @@ getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
template <unsigned MinVer, unsigned MaxVer, typename Fn, typename... Args> template <unsigned MinVer, unsigned MaxVer, typename Fn, typename... Args>
void void
forApiVersions(Fn const& fn, Args&&... args) forApiVersions(Fn const& fn, Args&&... args)
requires // requires //
(MaxVer >= MinVer) && // (MaxVer >= MinVer) && //
(MinVer >= RPC::kAPI_MINIMUM_SUPPORTED_VERSION) && // (MinVer >= RPC::kApiMinimumSupportedVersion) && //
(RPC::kAPI_MAXIMUM_VALID_VERSION >= MaxVer) && requires { (RPC::kApiMaximumValidVersion >= MaxVer) && requires {
fn(std::integral_constant<unsigned int, MinVer>{}, std::forward<Args>(args)...); fn(std::integral_constant<unsigned int, MinVer>{}, std::forward<Args>(args)...);
fn(std::integral_constant<unsigned int, MaxVer>{}, std::forward<Args>(args)...); fn(std::integral_constant<unsigned int, MaxVer>{}, std::forward<Args>(args)...);
} }
{ {
constexpr auto kSIZE = MaxVer + 1 - MinVer; static constexpr auto kSize = MaxVer + 1 - MinVer;
[&]<std::size_t... Offset>(std::index_sequence<Offset...>) { [&]<std::size_t... Offset>(std::index_sequence<Offset...>) {
// NOLINTBEGIN(bugprone-use-after-move) // NOLINTBEGIN(bugprone-use-after-move)
(((void)fn( (((void)fn(
std::integral_constant<unsigned int, MinVer + Offset>{}, std::forward<Args>(args)...)), std::integral_constant<unsigned int, MinVer + Offset>{}, std::forward<Args>(args)...)),
...); ...);
// NOLINTEND(bugprone-use-after-move) // NOLINTEND(bugprone-use-after-move)
}(std::make_index_sequence<kSIZE>{}); }(std::make_index_sequence<kSize>{});
} }
template <typename Fn, typename... Args> template <typename Fn, typename... Args>
void void
forAllApiVersions(Fn const& fn, Args&&... args) forAllApiVersions(Fn const& fn, Args&&... args)
requires requires { requires requires {
forApiVersions<RPC::kAPI_MINIMUM_SUPPORTED_VERSION, RPC::kAPI_MAXIMUM_VALID_VERSION>( forApiVersions<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>(
fn, std::forward<Args>(args)...); fn, std::forward<Args>(args)...);
} }
{ {
forApiVersions<RPC::kAPI_MINIMUM_SUPPORTED_VERSION, RPC::kAPI_MAXIMUM_VALID_VERSION>( forApiVersions<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>(
fn, std::forward<Args>(args)...); fn, std::forward<Args>(args)...);
} }

View File

@@ -148,10 +148,10 @@ public:
}; };
template <ValidIssueType TIss> template <ValidIssueType TIss>
constexpr bool kIS_ISSUE_V = std::is_same_v<TIss, Issue>; constexpr bool kIsIssueV = std::is_same_v<TIss, Issue>;
template <ValidIssueType TIss> template <ValidIssueType TIss>
constexpr bool kIS_MPTISSUE_V = std::is_same_v<TIss, MPTIssue>; constexpr bool kIsMptissueV = std::is_same_v<TIss, MPTIssue>;
inline json::Value inline json::Value
toJson(Asset const& asset) toJson(Asset const& asset)
@@ -242,7 +242,7 @@ operator<=>(Asset const& lhs, Asset const& rhs)
{ {
return std::weak_ordering(lhs <=> rhs); return std::weak_ordering(lhs <=> rhs);
} }
else if constexpr (kIS_ISSUE_V<TLhs> && kIS_MPTISSUE_V<TRhs>) else if constexpr (kIsIssueV<TLhs> && kIsMptissueV<TRhs>)
{ {
return std::weak_ordering::greater; return std::weak_ordering::greater;
} }

View File

@@ -65,11 +65,11 @@
namespace xrpl { namespace xrpl {
// Feature names must not exceed this length (in characters, excluding the null terminator). // Feature names must not exceed this length (in characters, excluding the null terminator).
static constexpr std::size_t kMAX_FEATURE_NAME_SIZE = 63; static constexpr std::size_t kMaxFeatureNameSize = 63;
// Reserve this exact feature-name length (in characters/bytes, excluding the null terminator) // Reserve this exact feature-name length (in characters/bytes, excluding the null terminator)
// so that a 32-byte uint256 (for example, in WASM or other interop contexts) can be used // so that a 32-byte uint256 (for example, in WASM or other interop contexts) can be used
// as a compact, fixed-size feature selector without conflicting with human-readable names. // as a compact, fixed-size feature selector without conflicting with human-readable names.
static constexpr std::size_t kRESERVED_FEATURE_NAME_SIZE = 32; static constexpr std::size_t kReservedFeatureNameSize = 32;
// Both validFeatureNameSize and validFeatureName are consteval functions that can be used in // Both validFeatureNameSize and validFeatureName are consteval functions that can be used in
// static_asserts to validate feature names at compile time. They are only used inside // static_asserts to validate feature names at compile time. They are only used inside
@@ -81,14 +81,14 @@ validFeatureNameSize(auto fn) -> bool
{ {
constexpr char const* kN = fn(); constexpr char const* kN = fn();
// Note, std::strlen is not constexpr, we need to implement our own here. // Note, std::strlen is not constexpr, we need to implement our own here.
constexpr std::size_t kLEN = [](auto n) { constexpr std::size_t kLen = [](auto n) {
std::size_t ret = 0; std::size_t ret = 0;
for (auto ptr = n; *ptr != '\0'; ret++, ++ptr) for (auto ptr = n; *ptr != '\0'; ret++, ++ptr)
; ;
return ret; return ret;
}(kN); }(kN);
return kLEN != kRESERVED_FEATURE_NAME_SIZE && // return kLen != kReservedFeatureNameSize && //
kLEN <= kMAX_FEATURE_NAME_SIZE; kLen <= kMaxFeatureNameSize;
} }
consteval auto consteval auto
@@ -136,7 +136,7 @@ namespace detail {
// Feature.cpp. Because it's only used to reserve storage, and determine how // Feature.cpp. Because it's only used to reserve storage, and determine how
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than // large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
// the actual number of amendments. A LogicError on startup will verify this. // the actual number of amendments. A LogicError on startup will verify this.
static constexpr std::size_t kNUM_FEATURES = static constexpr std::size_t kNumFeatures =
(0 + (0 +
#include <xrpl/protocol/detail/features.macro> #include <xrpl/protocol/detail/features.macro>
); );
@@ -184,9 +184,9 @@ bitsetIndexToFeature(size_t i);
std::string std::string
featureToName(uint256 const& f); featureToName(uint256 const& f);
class FeatureBitset : private std::bitset<detail::kNUM_FEATURES> class FeatureBitset : private std::bitset<detail::kNumFeatures>
{ {
using base = std::bitset<detail::kNUM_FEATURES>; using base = std::bitset<detail::kNumFeatures>;
template <class... Fs> template <class... Fs>
void void

View File

@@ -6,7 +6,7 @@ namespace xrpl {
// Deprecated constant for backwards compatibility with pre-XRPFees amendment. // Deprecated constant for backwards compatibility with pre-XRPFees amendment.
// This was the reference fee units used in the old fee calculation. // This was the reference fee units used in the old fee calculation.
inline constexpr std::uint32_t kFEE_UNITS_DEPRECATED = 10; inline constexpr std::uint32_t kFeeUnitsDeprecated = 10;
/** Reflects the fee settings for a particular ledger. /** Reflects the fee settings for a particular ledger.

View File

@@ -92,7 +92,7 @@ public:
inline IOUAmount::IOUAmount(beast::Zero) inline IOUAmount::IOUAmount(beast::Zero)
{ {
*this = beast::kZERO; *this = beast::kZero;
} }
inline IOUAmount::IOUAmount(mantissa_type mantissa, exponent_type exponent) inline IOUAmount::IOUAmount(mantissa_type mantissa, exponent_type exponent)

View File

@@ -82,7 +82,7 @@ struct BookT
Keylet Keylet
operator()(Book const& b) const; operator()(Book const& b) const;
}; };
static BookT const kBOOK{}; static BookT const kBook{};
/** The index of a trust line for a given currency /** The index of a trust line for a given currency
@@ -126,7 +126,7 @@ struct NextT
Keylet Keylet
operator()(Keylet const& k) const; operator()(Keylet const& k) const;
}; };
static NextT const kNEXT{}; static NextT const kNext{};
/** A ticket belonging to an account */ /** A ticket belonging to an account */
struct TicketT struct TicketT
@@ -145,7 +145,7 @@ struct TicketT
return {ltTICKET, key}; return {ltTICKET, key};
} }
}; };
static TicketT const kTICKET{}; static TicketT const kTicket{};
/** A SignerList */ /** A SignerList */
Keylet Keylet
@@ -373,7 +373,7 @@ struct KeyletDesc
// This list should include all of the keylet functions that take a single // This list should include all of the keylet functions that take a single
// AccountID parameter. // AccountID parameter.
std::array<KeyletDesc<AccountID const&>, 6> const kDIRECT_ACCOUNT_KEYLETS{ std::array<KeyletDesc<AccountID const&>, 6> const kDirectAccountKeylets{
{{.function = &keylet::account, .expectedLEName = jss::AccountRoot, .includeInTests = false}, {{.function = &keylet::account, .expectedLEName = jss::AccountRoot, .includeInTests = false},
{.function = &keylet::ownerDir, .expectedLEName = jss::DirectoryNode, .includeInTests = true}, {.function = &keylet::ownerDir, .expectedLEName = jss::DirectoryNode, .includeInTests = true},
{.function = &keylet::signers, .expectedLEName = jss::SignerList, .includeInTests = true}, {.function = &keylet::signers, .expectedLEName = jss::SignerList, .includeInTests = true},

View File

@@ -96,16 +96,16 @@ operator<=>(Issue const& lhs, Issue const& rhs)
inline Issue const& inline Issue const&
xrpIssue() xrpIssue()
{ {
static Issue const kISSUE{xrpCurrency(), xrpAccount()}; static Issue const kIssue{xrpCurrency(), xrpAccount()};
return kISSUE; return kIssue;
} }
/** Returns an asset specifier that represents no account and currency. */ /** Returns an asset specifier that represents no account and currency. */
inline Issue const& inline Issue const&
noIssue() noIssue()
{ {
static Issue const kISSUE{noCurrency(), noAccount()}; static Issue const kIssue{noCurrency(), noAccount()};
return kISSUE; return kIssue;
} }
inline bool inline bool

View File

@@ -26,12 +26,12 @@ struct LedgerHeader
// //
// Closed means "tx set already determined" // Closed means "tx set already determined"
uint256 hash = beast::kZERO; uint256 hash = beast::kZero;
uint256 txHash = beast::kZERO; uint256 txHash = beast::kZero;
uint256 accountHash = beast::kZERO; uint256 accountHash = beast::kZero;
uint256 parentHash = beast::kZERO; uint256 parentHash = beast::kZero;
XRPAmount drops = beast::kZERO; XRPAmount drops = beast::kZero;
// If validated is false, it means "not yet validated." // If validated is false, it means "not yet validated."
// Once validated is true, it will never be set false at a later time. // Once validated is true, it will never be set false at a later time.
@@ -53,12 +53,12 @@ struct LedgerHeader
}; };
// ledger close flags // ledger close flags
static std::uint32_t const kS_LCF_NO_CONSENSUS_TIME = 0x01; static std::uint32_t const kSLcfNoConsensusTime = 0x01;
inline bool inline bool
getCloseAgree(LedgerHeader const& info) getCloseAgree(LedgerHeader const& info)
{ {
return (info.closeFlags & kS_LCF_NO_CONSENSUS_TIME) == 0; return (info.closeFlags & kSLcfNoConsensusTime) == 0;
} }
void void

View File

@@ -88,7 +88,7 @@ constexpr MPTAmount::MPTAmount(value_type value) : value_(value)
constexpr MPTAmount::MPTAmount(beast::Zero) constexpr MPTAmount::MPTAmount(beast::Zero)
{ {
*this = beast::kZERO; *this = beast::kZero;
} }
constexpr MPTAmount& constexpr MPTAmount&

View File

@@ -15,14 +15,14 @@ namespace xrpl {
namespace detail { namespace detail {
template <typename T> template <typename T>
constexpr bool kIS_INTEGRAL_CONSTANT = false; constexpr bool kIsIntegralConstant = false;
template <typename I, auto A> template <typename I, auto A>
constexpr bool kIS_INTEGRAL_CONSTANT<std::integral_constant<I, A>&> = true; constexpr bool kIsIntegralConstant<std::integral_constant<I, A>&> = true;
template <typename I, auto A> template <typename I, auto A>
constexpr bool kIS_INTEGRAL_CONSTANT<std::integral_constant<I, A> const&> = true; constexpr bool kIsIntegralConstant<std::integral_constant<I, A> const&> = true;
template <typename T> template <typename T>
concept some_integral_constant = detail::kIS_INTEGRAL_CONSTANT<T&>; concept some_integral_constant = detail::kIsIntegralConstant<T&>;
// This class is designed to wrap a collection of _almost_ identical json::Value // This class is designed to wrap a collection of _almost_ identical json::Value
// objects, indexed by version (i.e. there is some mapping of version to object // objects, indexed by version (i.e. there is some mapping of version to object
@@ -47,8 +47,8 @@ struct MultiApiJson
return (v < MinVer) ? 0 : static_cast<std::size_t>(v - MinVer); return (v < MinVer) ? 0 : static_cast<std::size_t>(v - MinVer);
} }
constexpr static std::size_t kSIZE = MaxVer + 1 - MinVer; static constexpr std::size_t kSize = MaxVer + 1 - MinVer;
std::array<json::Value, kSIZE> val = {}; std::array<json::Value, kSize> val = {};
explicit MultiApiJson(json::Value const& init = {}) explicit MultiApiJson(json::Value const& init = {})
{ {
@@ -80,7 +80,7 @@ struct MultiApiJson
if (count == 0) if (count == 0)
return IsMemberResult::None; return IsMemberResult::None;
return count < kSIZE ? IsMemberResult::Some : IsMemberResult::All; return count < kSize ? IsMemberResult::Some : IsMemberResult::All;
} }
static constexpr struct VisitorT final static constexpr struct VisitorT final
@@ -100,7 +100,7 @@ struct MultiApiJson
std::integral_constant<unsigned int, Version>, std::integral_constant<unsigned int, Version>,
Args&&...> Args&&...>
{ {
static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSIZE); static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSize);
return std::invoke(fn, json.val[index(Version)], version, std::forward<Args>(args)...); return std::invoke(fn, json.val[index(Version)], version, std::forward<Args>(args)...);
} }
@@ -111,7 +111,7 @@ struct MultiApiJson
operator()(Json& json, std::integral_constant<unsigned int, Version> const, Fn fn) const operator()(Json& json, std::integral_constant<unsigned int, Version> const, Fn fn) const
-> std::invoke_result_t<Fn, decltype(json.val[0])> -> std::invoke_result_t<Fn, decltype(json.val[0])>
{ {
static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSIZE); static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSize);
return std::invoke(fn, json.val[index(Version)]); return std::invoke(fn, json.val[index(Version)]);
} }
@@ -124,7 +124,7 @@ struct MultiApiJson
-> std::invoke_result_t<Fn, decltype(json.val[0]), Version, Args&&...> -> std::invoke_result_t<Fn, decltype(json.val[0]), Version, Args&&...>
{ {
XRPL_ASSERT( XRPL_ASSERT(
valid(version) && index(version) >= 0 && index(version) < kSIZE, valid(version) && index(version) >= 0 && index(version) < kSize,
"xrpl::detail::MultiApijson::operator<Args...>() : valid " "xrpl::detail::MultiApijson::operator<Args...>() : valid "
"version"); "version");
return std::invoke(fn, json.val[index(version)], version, std::forward<Args>(args)...); return std::invoke(fn, json.val[index(version)], version, std::forward<Args>(args)...);
@@ -139,20 +139,20 @@ struct MultiApiJson
-> std::invoke_result_t<Fn, decltype(json.val[0])> -> std::invoke_result_t<Fn, decltype(json.val[0])>
{ {
XRPL_ASSERT( XRPL_ASSERT(
valid(version) && index(version) >= 0 && index(version) < kSIZE, valid(version) && index(version) >= 0 && index(version) < kSize,
"xrpl::detail::MultiApijson::operator() : valid version"); "xrpl::detail::MultiApijson::operator() : valid version");
return std::invoke(fn, json.val[index(version)]); return std::invoke(fn, json.val[index(version)]);
} }
} kVISITOR = {}; } kVisitor = {};
auto auto
visit() visit()
{ {
return [self = this](auto... args) return [self = this](auto... args)
requires requires { requires requires {
kVISITOR(std::declval<MultiApiJson&>(), std::declval<decltype(args)>()...); kVisitor(std::declval<MultiApiJson&>(), std::declval<decltype(args)>()...);
} }
{ return kVISITOR(*self, std::forward<decltype(args)>(args)...); }; { return kVisitor(*self, std::forward<decltype(args)>(args)...); };
} }
[[nodiscard]] auto [[nodiscard]] auto
@@ -160,27 +160,27 @@ struct MultiApiJson
{ {
return [self = this](auto... args) return [self = this](auto... args)
requires requires { requires requires {
kVISITOR(std::declval<MultiApiJson const&>(), std::declval<decltype(args)>()...); kVisitor(std::declval<MultiApiJson const&>(), std::declval<decltype(args)>()...);
} }
{ return kVISITOR(*self, std::forward<decltype(args)>(args)...); }; { return kVisitor(*self, std::forward<decltype(args)>(args)...); };
} }
template <typename... Args> template <typename... Args>
auto auto
visit(Args... args) -> std::invoke_result_t<VisitorT, MultiApiJson&, Args...> visit(Args... args) -> std::invoke_result_t<VisitorT, MultiApiJson&, Args...>
requires(sizeof...(args) > 0) && requires(sizeof...(args) > 0) &&
requires { kVISITOR(*this, std::forward<decltype(args)>(args)...); } requires { kVisitor(*this, std::forward<decltype(args)>(args)...); }
{ {
return kVISITOR(*this, std::forward<decltype(args)>(args)...); return kVisitor(*this, std::forward<decltype(args)>(args)...);
} }
template <typename... Args> template <typename... Args>
[[nodiscard]] auto [[nodiscard]] auto
visit(Args... args) const -> std::invoke_result_t<VisitorT, MultiApiJson const&, Args...> visit(Args... args) const -> std::invoke_result_t<VisitorT, MultiApiJson const&, Args...>
requires(sizeof...(args) > 0) && requires(sizeof...(args) > 0) &&
requires { kVISITOR(*this, std::forward<decltype(args)>(args)...); } requires { kVisitor(*this, std::forward<decltype(args)>(args)...); }
{ {
return kVISITOR(*this, std::forward<decltype(args)>(args)...); return kVisitor(*this, std::forward<decltype(args)>(args)...);
} }
}; };
@@ -188,6 +188,6 @@ struct MultiApiJson
// Wrapper for Json for all supported API versions. // Wrapper for Json for all supported API versions.
using MultiApiJson = using MultiApiJson =
detail::MultiApiJson<RPC::kAPI_MINIMUM_SUPPORTED_VERSION, RPC::kAPI_MAXIMUM_VALID_VERSION>; detail::MultiApiJson<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>;
} // namespace xrpl } // namespace xrpl

View File

@@ -52,10 +52,10 @@ public:
}; };
template <ValidPathAsset PA> template <ValidPathAsset PA>
constexpr bool kIS_CURRENCY_V = std::is_same_v<PA, Currency>; constexpr bool kIsCurrencyV = std::is_same_v<PA, Currency>;
template <ValidPathAsset PA> template <ValidPathAsset PA>
constexpr bool kIS_MPTID_V = std::is_same_v<PA, MPTID>; constexpr bool kIsMptidV = std::is_same_v<PA, MPTID>;
inline PathAsset::PathAsset(Asset const& asset) inline PathAsset::PathAsset(Asset const& asset)
{ {

View File

@@ -19,40 +19,40 @@ namespace xrpl {
@ingroup protocol @ingroup protocol
*/ */
/** Smallest legal byte size of a transaction. */ /** Smallest legal byte size of a transaction. */
std::size_t constexpr kTX_MIN_SIZE_BYTES = 32; constexpr std::size_t kTxMinSizeBytes = 32;
/** Largest legal byte size of a transaction. */ /** Largest legal byte size of a transaction. */
std::size_t constexpr kTX_MAX_SIZE_BYTES = megabytes(1); constexpr std::size_t kTxMaxSizeBytes = megabytes(1);
/** The maximum number of unfunded offers to delete at once */ /** The maximum number of unfunded offers to delete at once */
std::size_t constexpr kUNFUNDED_OFFER_REMOVE_LIMIT = 1000; constexpr std::size_t kUnfundedOfferRemoveLimit = 1000;
/** The maximum number of expired offers to delete at once */ /** The maximum number of expired offers to delete at once */
std::size_t constexpr kEXPIRED_OFFER_REMOVE_LIMIT = 256; constexpr std::size_t kExpiredOfferRemoveLimit = 256;
/** The maximum number of metadata entries allowed in one transaction */ /** The maximum number of metadata entries allowed in one transaction */
std::size_t constexpr kOVERSIZE_META_DATA_CAP = 5200; constexpr std::size_t kOversizeMetaDataCap = 5200;
/** The maximum number of entries per directory page */ /** The maximum number of entries per directory page */
std::size_t constexpr kDIR_NODE_MAX_ENTRIES = 32; constexpr std::size_t kDirNodeMaxEntries = 32;
/** The maximum number of pages allowed in a directory /** The maximum number of pages allowed in a directory
Made obsolete by fixDirectoryLimit amendment. Made obsolete by fixDirectoryLimit amendment.
*/ */
std::uint64_t constexpr kDIR_NODE_MAX_PAGES = 262144; constexpr std::uint64_t kDirNodeMaxPages = 262144;
/** The maximum number of items in an NFT page */ /** The maximum number of items in an NFT page */
std::size_t constexpr kDIR_MAX_TOKENS_PER_PAGE = 32; constexpr std::size_t kDirMaxTokensPerPage = 32;
/** The maximum number of owner directory entries for account to be deletable */ /** The maximum number of owner directory entries for account to be deletable */
std::size_t constexpr kMAX_DELETABLE_DIR_ENTRIES = 1000; constexpr std::size_t kMaxDeletableDirEntries = 1000;
/** The maximum number of token offers that can be canceled at once */ /** The maximum number of token offers that can be canceled at once */
std::size_t constexpr kMAX_TOKEN_OFFER_CANCEL_COUNT = 500; constexpr std::size_t kMaxTokenOfferCancelCount = 500;
/** The maximum number of offers in an offer directory for NFT to be burnable */ /** The maximum number of offers in an offer directory for NFT to be burnable */
std::size_t constexpr kMAX_DELETABLE_TOKEN_OFFER_ENTRIES = 500; constexpr std::size_t kMaxDeletableTokenOfferEntries = 500;
/** The maximum token transfer fee allowed. /** The maximum token transfer fee allowed.
@@ -63,7 +63,7 @@ std::size_t constexpr kMAX_DELETABLE_TOKEN_OFFER_ENTRIES = 500;
Note that for extremely low transfer fees values, it is possible that the Note that for extremely low transfer fees values, it is possible that the
calculated fee will be 0. calculated fee will be 0.
*/ */
std::uint16_t constexpr kMAX_TRANSFER_FEE = 50000; constexpr std::uint16_t kMaxTransferFee = 50000;
/** There are 10,000 basis points (bips) in 100%. /** There are 10,000 basis points (bips) in 100%.
* *
@@ -81,32 +81,32 @@ std::uint16_t constexpr kMAX_TRANSFER_FEE = 50000;
* *
* Example: 50% is 0.50 * bipsPerUnity = 5,000 bps. * Example: 50% is 0.50 * bipsPerUnity = 5,000 bps.
*/ */
Bips32 constexpr kBIPS_PER_UNITY(100 * 100); constexpr Bips32 kBipsPerUnity(100 * 100);
static_assert(kBIPS_PER_UNITY == Bips32{10'000}); static_assert(kBipsPerUnity == Bips32{10'000});
TenthBips32 constexpr kTENTH_BIPS_PER_UNITY(kBIPS_PER_UNITY.value() * 10); constexpr TenthBips32 kTenthBipsPerUnity(kBipsPerUnity.value() * 10);
static_assert(kTENTH_BIPS_PER_UNITY == TenthBips32(100'000)); static_assert(kTenthBipsPerUnity == TenthBips32(100'000));
constexpr Bips32 constexpr Bips32
percentageToBips(std::uint32_t percentage) percentageToBips(std::uint32_t percentage)
{ {
return Bips32(percentage * kBIPS_PER_UNITY.value() / 100); return Bips32(percentage * kBipsPerUnity.value() / 100);
} }
constexpr TenthBips32 constexpr TenthBips32
percentageToTenthBips(std::uint32_t percentage) percentageToTenthBips(std::uint32_t percentage)
{ {
return TenthBips32(percentage * kTENTH_BIPS_PER_UNITY.value() / 100); return TenthBips32(percentage * kTenthBipsPerUnity.value() / 100);
} }
template <typename T, class TBips> template <typename T, class TBips>
constexpr T constexpr T
bipsOfValue(T value, Bips<TBips> bips) bipsOfValue(T value, Bips<TBips> bips)
{ {
return value * bips.value() / kBIPS_PER_UNITY.value(); return value * bips.value() / kBipsPerUnity.value();
} }
template <typename T, class TBips> template <typename T, class TBips>
constexpr T constexpr T
tenthBipsOfValue(T value, TenthBips<TBips> bips) tenthBipsOfValue(T value, TenthBips<TBips> bips)
{ {
return value * bips.value() / kTENTH_BIPS_PER_UNITY.value(); return value * bips.value() / kTenthBipsPerUnity.value();
} }
namespace Lending { namespace Lending {
@@ -114,54 +114,54 @@ namespace Lending {
Valid values are between 0 and 10% inclusive. Valid values are between 0 and 10% inclusive.
*/ */
TenthBips16 constexpr kMAX_MANAGEMENT_FEE_RATE( constexpr TenthBips16 kMaxManagementFeeRate(
unsafeCast<std::uint16_t>(percentageToTenthBips(10).value())); unsafeCast<std::uint16_t>(percentageToTenthBips(10).value()));
static_assert(kMAX_MANAGEMENT_FEE_RATE == TenthBips16(std::uint16_t(10'000u))); static_assert(kMaxManagementFeeRate == TenthBips16(std::uint16_t(10'000u)));
/** The maximum coverage rate required of a loan broker in 1/10 bips. /** The maximum coverage rate required of a loan broker in 1/10 bips.
Valid values are between 0 and 100% inclusive. Valid values are between 0 and 100% inclusive.
*/ */
TenthBips32 constexpr kMAX_COVER_RATE = percentageToTenthBips(100); constexpr TenthBips32 kMaxCoverRate = percentageToTenthBips(100);
static_assert(kMAX_COVER_RATE == TenthBips32(100'000u)); static_assert(kMaxCoverRate == TenthBips32(100'000u));
/** The maximum overpayment fee on a loan in 1/10 bips. /** The maximum overpayment fee on a loan in 1/10 bips.
* *
Valid values are between 0 and 100% inclusive. Valid values are between 0 and 100% inclusive.
*/ */
TenthBips32 constexpr kMAX_OVERPAYMENT_FEE = percentageToTenthBips(100); constexpr TenthBips32 kMaxOverpaymentFee = percentageToTenthBips(100);
static_assert(kMAX_OVERPAYMENT_FEE == TenthBips32(100'000u)); static_assert(kMaxOverpaymentFee == TenthBips32(100'000u));
/** Annualized interest rate of the Loan in 1/10 bips. /** Annualized interest rate of the Loan in 1/10 bips.
* *
* Valid values are between 0 and 100% inclusive. * Valid values are between 0 and 100% inclusive.
*/ */
TenthBips32 constexpr kMAX_INTEREST_RATE = percentageToTenthBips(100); constexpr TenthBips32 kMaxInterestRate = percentageToTenthBips(100);
static_assert(kMAX_INTEREST_RATE == TenthBips32(100'000u)); static_assert(kMaxInterestRate == TenthBips32(100'000u));
/** The maximum premium added to the interest rate for late payments on a loan /** The maximum premium added to the interest rate for late payments on a loan
* in 1/10 bips. * in 1/10 bips.
* *
* Valid values are between 0 and 100% inclusive. * Valid values are between 0 and 100% inclusive.
*/ */
TenthBips32 constexpr kMAX_LATE_INTEREST_RATE = percentageToTenthBips(100); constexpr TenthBips32 kMaxLateInterestRate = percentageToTenthBips(100);
static_assert(kMAX_LATE_INTEREST_RATE == TenthBips32(100'000u)); static_assert(kMaxLateInterestRate == TenthBips32(100'000u));
/** The maximum close interest rate charged for repaying a loan early in 1/10 /** The maximum close interest rate charged for repaying a loan early in 1/10
* bips. * bips.
* *
* Valid values are between 0 and 100% inclusive. * Valid values are between 0 and 100% inclusive.
*/ */
TenthBips32 constexpr kMAX_CLOSE_INTEREST_RATE = percentageToTenthBips(100); constexpr TenthBips32 kMaxCloseInterestRate = percentageToTenthBips(100);
static_assert(kMAX_CLOSE_INTEREST_RATE == TenthBips32(100'000u)); static_assert(kMaxCloseInterestRate == TenthBips32(100'000u));
/** The maximum overpayment interest rate charged on loan overpayments in 1/10 /** The maximum overpayment interest rate charged on loan overpayments in 1/10
* bips. * bips.
* *
* Valid values are between 0 and 100% inclusive. * Valid values are between 0 and 100% inclusive.
*/ */
TenthBips32 constexpr kMAX_OVERPAYMENT_INTEREST_RATE = percentageToTenthBips(100); constexpr TenthBips32 kMaxOverpaymentInterestRate = percentageToTenthBips(100);
static_assert(kMAX_OVERPAYMENT_INTEREST_RATE == TenthBips32(100'000u)); static_assert(kMaxOverpaymentInterestRate == TenthBips32(100'000u));
/** LoanPay transaction cost will be one base fee per X combined payments /** LoanPay transaction cost will be one base fee per X combined payments
* *
@@ -172,7 +172,7 @@ static_assert(kMAX_OVERPAYMENT_INTEREST_RATE == TenthBips32(100'000u));
* This number was chosen arbitrarily, but should not be changed once released * This number was chosen arbitrarily, but should not be changed once released
* without an amendment * without an amendment
*/ */
static constexpr int kLOAN_PAYMENTS_PER_FEE_INCREMENT = 5; static constexpr int kLoanPaymentsPerFeeIncrement = 5;
/** Maximum number of combined payments that a LoanPay transaction will process /** Maximum number of combined payments that a LoanPay transaction will process
* *
@@ -196,65 +196,65 @@ static constexpr int kLOAN_PAYMENTS_PER_FEE_INCREMENT = 5;
* This number was chosen arbitrarily, but should not be changed once released * This number was chosen arbitrarily, but should not be changed once released
* without an amendment * without an amendment
*/ */
static constexpr int kLOAN_MAXIMUM_PAYMENTS_PER_TRANSACTION = 100; static constexpr int kLoanMaximumPaymentsPerTransaction = 100;
} // namespace Lending } // namespace Lending
/** The maximum length of a URI inside an NFT */ /** The maximum length of a URI inside an NFT */
std::size_t constexpr kMAX_TOKEN_URI_LENGTH = 256; constexpr std::size_t kMaxTokenUriLength = 256;
/** The maximum length of a Data element inside a DID */ /** The maximum length of a Data element inside a DID */
std::size_t constexpr kMAX_DID_DOCUMENT_LENGTH = 256; constexpr std::size_t kMaxDidDocumentLength = 256;
/** The maximum length of a URI inside a DID */ /** The maximum length of a URI inside a DID */
std::size_t constexpr kMAX_DIDURI_LENGTH = 256; constexpr std::size_t kMaxDidUriLength = 256;
/** The maximum length of an Attestation inside a DID */ /** The maximum length of an Attestation inside a DID */
std::size_t constexpr kMAX_DID_DATA_LENGTH = 256; constexpr std::size_t kMaxDidDataLength = 256;
/** The maximum length of a domain */ /** The maximum length of a domain */
std::size_t constexpr kMAX_DOMAIN_LENGTH = 256; constexpr std::size_t kMaxDomainLength = 256;
/** The maximum length of a URI inside a Credential */ /** The maximum length of a URI inside a Credential */
std::size_t constexpr kMAX_CREDENTIAL_URI_LENGTH = 256; constexpr std::size_t kMaxCredentialUriLength = 256;
/** The maximum length of a CredentialType inside a Credential */ /** The maximum length of a CredentialType inside a Credential */
std::size_t constexpr kMAX_CREDENTIAL_TYPE_LENGTH = 64; constexpr std::size_t kMaxCredentialTypeLength = 64;
/** The maximum number of credentials can be passed in array */ /** The maximum number of credentials can be passed in array */
std::size_t constexpr kMAX_CREDENTIALS_ARRAY_SIZE = 8; constexpr std::size_t kMaxCredentialsArraySize = 8;
/** The maximum number of credentials can be passed in array for permissioned /** The maximum number of credentials can be passed in array for permissioned
* domain */ * domain */
std::size_t constexpr kMAX_PERMISSIONED_DOMAIN_CREDENTIALS_ARRAY_SIZE = 10; constexpr std::size_t kMaxPermissionedDomainCredentialsArraySize = 10;
/** The maximum length of MPTokenMetadata */ /** The maximum length of MPTokenMetadata */
std::size_t constexpr kMAX_MP_TOKEN_METADATA_LENGTH = 1024; constexpr std::size_t kMaxMpTokenMetadataLength = 1024;
/** The maximum amount of MPTokenIssuance */ /** The maximum amount of MPTokenIssuance */
std::uint64_t constexpr kMAX_MP_TOKEN_AMOUNT = 0x7FFF'FFFF'FFFF'FFFFull; constexpr std::uint64_t kMaxMpTokenAmount = 0x7FFF'FFFF'FFFF'FFFFull;
static_assert(Number::kMAX_REP >= kMAX_MP_TOKEN_AMOUNT); static_assert(Number::kMaxRep >= kMaxMpTokenAmount);
/** The maximum length of Data payload */ /** The maximum length of Data payload */
std::size_t constexpr kMAX_DATA_PAYLOAD_LENGTH = 256; constexpr std::size_t kMaxDataPayloadLength = 256;
/** Vault withdrawal policies */ /** Vault withdrawal policies */
std::uint8_t constexpr kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE = 1; constexpr std::uint8_t kVaultStrategyFirstComeFirstServe = 1;
/** Default IOU scale factor for a Vault */ /** Default IOU scale factor for a Vault */
std::uint8_t constexpr kVAULT_DEFAULT_IOU_SCALE = 6; constexpr std::uint8_t kVaultDefaultIouScale = 6;
/** Maximum scale factor for a Vault. The number is chosen to ensure that /** Maximum scale factor for a Vault. The number is chosen to ensure that
1 IOU can be always converted to shares. 1 IOU can be always converted to shares.
10^19 > maxMPTokenAmount (2^64-1) > 10^18 */ 10^19 > maxMPTokenAmount (2^64-1) > 10^18 */
std::uint8_t constexpr kVAULT_MAXIMUM_IOU_SCALE = 18; constexpr std::uint8_t kVaultMaximumIouScale = 18;
/** Maximum recursion depth for vault shares being put as an asset inside /** Maximum recursion depth for vault shares being put as an asset inside
* another vault; counted from 0 */ * another vault; counted from 0 */
std::uint8_t constexpr kMAX_ASSET_CHECK_DEPTH = 5; constexpr std::uint8_t kMaxAssetCheckDepth = 5;
/** A ledger index. */ /** A ledger index. */
using LedgerIndex = std::uint32_t; using LedgerIndex = std::uint32_t;
std::uint32_t constexpr kFLAG_LEDGER_INTERVAL = 256; constexpr std::uint32_t kFlagLedgerInterval = 256;
/** Returns true if the given ledgerIndex is a voting ledgerIndex */ /** Returns true if the given ledgerIndex is a voting ledgerIndex */
bool bool
@@ -273,38 +273,38 @@ using TxID = uint256;
/** The maximum number of trustlines to delete as part of AMM account /** The maximum number of trustlines to delete as part of AMM account
* deletion cleanup. * deletion cleanup.
*/ */
std::uint16_t constexpr kMAX_DELETABLE_AMM_TRUST_LINES = 512; constexpr std::uint16_t kMaxDeletableAmmTrustLines = 512;
/** The maximum length of a URI inside an Oracle */ /** The maximum length of a URI inside an Oracle */
std::size_t constexpr kMAX_ORACLE_URI = 256; constexpr std::size_t kMaxOracleUri = 256;
/** The maximum length of a Provider inside an Oracle */ /** The maximum length of a Provider inside an Oracle */
std::size_t constexpr kMAX_ORACLE_PROVIDER = 256; constexpr std::size_t kMaxOracleProvider = 256;
/** The maximum size of a data series array inside an Oracle */ /** The maximum size of a data series array inside an Oracle */
std::size_t constexpr kMAX_ORACLE_DATA_SERIES = 10; constexpr std::size_t kMaxOracleDataSeries = 10;
/** The maximum length of a SymbolClass inside an Oracle */ /** The maximum length of a SymbolClass inside an Oracle */
std::size_t constexpr kMAX_ORACLE_SYMBOL_CLASS = 16; constexpr std::size_t kMaxOracleSymbolClass = 16;
/** The maximum allowed time difference between lastUpdateTime and the time /** The maximum allowed time difference between lastUpdateTime and the time
of the last closed ledger of the last closed ledger
*/ */
std::size_t constexpr kMAX_LAST_UPDATE_TIME_DELTA = 300; constexpr std::size_t kMaxLastUpdateTimeDelta = 300;
/** The maximum price scaling factor /** The maximum price scaling factor
*/ */
std::size_t constexpr kMAX_PRICE_SCALE = 20; constexpr std::size_t kMaxPriceScale = 20;
/** The maximum percentage of outliers to trim /** The maximum percentage of outliers to trim
*/ */
std::size_t constexpr kMAX_TRIM = 25; constexpr std::size_t kMaxTrim = 25;
/** The maximum number of delegate permissions an account can grant /** The maximum number of delegate permissions an account can grant
*/ */
std::size_t constexpr kPERMISSION_MAX_SIZE = 10; constexpr std::size_t kPermissionMaxSize = 10;
/** The maximum number of transactions that can be in a batch. */ /** The maximum number of transactions that can be in a batch. */
std::size_t constexpr kMAX_BATCH_TX_COUNT = 8; constexpr std::size_t kMaxBatchTxCount = 8;
} // namespace xrpl } // namespace xrpl

View File

@@ -43,8 +43,8 @@ class PublicKey
protected: protected:
// All the constructed public keys are valid, non-empty and contain 33 // All the constructed public keys are valid, non-empty and contain 33
// bytes of data. // bytes of data.
static constexpr std::size_t kSIZE = 33; static constexpr std::size_t kSize = 33;
std::uint8_t buf_[kSIZE]{}; // should be large enough std::uint8_t buf_[kSize]{}; // should be large enough
public: public:
using const_iterator = std::uint8_t const*; using const_iterator = std::uint8_t const*;
@@ -72,7 +72,7 @@ public:
static std::size_t static std::size_t
size() noexcept size() noexcept
{ {
return kSIZE; return kSize;
} }
[[nodiscard]] const_iterator [[nodiscard]] const_iterator
@@ -90,19 +90,19 @@ public:
[[nodiscard]] const_iterator [[nodiscard]] const_iterator
end() const noexcept end() const noexcept
{ {
return buf_ + kSIZE; return buf_ + kSize;
} }
[[nodiscard]] const_iterator [[nodiscard]] const_iterator
cend() const noexcept cend() const noexcept
{ {
return buf_ + kSIZE; return buf_ + kSize;
} }
[[nodiscard]] Slice [[nodiscard]] Slice
slice() const noexcept slice() const noexcept
{ {
return {buf_, kSIZE}; return {buf_, kSize};
} }
operator Slice() const noexcept operator Slice() const noexcept

View File

@@ -26,7 +26,7 @@ struct TAmounts
{ {
TAmounts() = default; TAmounts() = default;
TAmounts(beast::Zero, beast::Zero) : in(beast::kZERO), out(beast::kZERO) TAmounts(beast::Zero, beast::Zero) : in(beast::kZero), out(beast::kZero)
{ {
} }
@@ -38,7 +38,7 @@ struct TAmounts
[[nodiscard]] bool [[nodiscard]] bool
empty() const noexcept empty() const noexcept
{ {
return in <= beast::kZERO || out <= beast::kZERO; return in <= beast::kZero || out <= beast::kZero;
} }
TAmounts& TAmounts&
@@ -94,8 +94,8 @@ public:
// have lower unsigned integer representations. // have lower unsigned integer representations.
using value_type = std::uint64_t; using value_type = std::uint64_t;
static int const kMIN_TICK_SIZE = 3; static int const kMinTickSize = 3;
static int const kMAX_TICK_SIZE = 16; static int const kMaxTickSize = 16;
private: private:
// This has the same representation as STAmount, see the comment on the // This has the same representation as STAmount, see the comment on the
@@ -316,10 +316,10 @@ TAmounts<In, Out>
Quality::ceilIn(TAmounts<In, Out> const& amount, In const& limit) const Quality::ceilIn(TAmounts<In, Out> const& amount, In const& limit) const
{ {
// Construct a function pointer to the function we want to call. // Construct a function pointer to the function we want to call.
static constexpr Amounts (Quality::*kCEIL_IN_FN_PTR)(Amounts const&, STAmount const&) const = static constexpr Amounts (Quality::*kCeilInFnPtr)(Amounts const&, STAmount const&) const =
&Quality::ceilIn; &Quality::ceilIn;
return ceilTAmountsHelper(amount, limit, amount.in, kCEIL_IN_FN_PTR); return ceilTAmountsHelper(amount, limit, amount.in, kCeilInFnPtr);
} }
template <class In, class Out> template <class In, class Out>
@@ -327,10 +327,10 @@ TAmounts<In, Out>
Quality::ceilInStrict(TAmounts<In, Out> const& amount, In const& limit, bool roundUp) const Quality::ceilInStrict(TAmounts<In, Out> const& amount, In const& limit, bool roundUp) const
{ {
// Construct a function pointer to the function we want to call. // Construct a function pointer to the function we want to call.
static constexpr Amounts (Quality::*kCEIL_IN_FN_PTR)(Amounts const&, STAmount const&, bool) static constexpr Amounts (Quality::*kCeilInFnPtr)(Amounts const&, STAmount const&, bool) const =
const = &Quality::ceilInStrict; &Quality::ceilInStrict;
return ceilTAmountsHelper(amount, limit, amount.in, kCEIL_IN_FN_PTR, roundUp); return ceilTAmountsHelper(amount, limit, amount.in, kCeilInFnPtr, roundUp);
} }
template <class In, class Out> template <class In, class Out>
@@ -338,10 +338,10 @@ TAmounts<In, Out>
Quality::ceilOut(TAmounts<In, Out> const& amount, Out const& limit) const Quality::ceilOut(TAmounts<In, Out> const& amount, Out const& limit) const
{ {
// Construct a function pointer to the function we want to call. // Construct a function pointer to the function we want to call.
static constexpr Amounts (Quality::*kCEIL_OUT_FN_PTR)(Amounts const&, STAmount const&) const = static constexpr Amounts (Quality::*kCeilOutFnPtr)(Amounts const&, STAmount const&) const =
&Quality::ceilOut; &Quality::ceilOut;
return ceil_TAmounts_helper(amount, limit, amount.out, kCEIL_OUT_FN_PTR); return ceil_TAmounts_helper(amount, limit, amount.out, kCeilOutFnPtr);
} }
template <class In, class Out> template <class In, class Out>
@@ -349,10 +349,10 @@ TAmounts<In, Out>
Quality::ceilOutStrict(TAmounts<In, Out> const& amount, Out const& limit, bool roundUp) const Quality::ceilOutStrict(TAmounts<In, Out> const& amount, Out const& limit, bool roundUp) const
{ {
// Construct a function pointer to the function we want to call. // Construct a function pointer to the function we want to call.
static constexpr Amounts (Quality::*kCEIL_OUT_FN_PTR)(Amounts const&, STAmount const&, bool) static constexpr Amounts (Quality::*kCeilOutFnPtr)(Amounts const&, STAmount const&, bool)
const = &Quality::ceilOutStrict; const = &Quality::ceilOutStrict;
return ceilTAmountsHelper(amount, limit, amount.out, kCEIL_OUT_FN_PTR, roundUp); return ceilTAmountsHelper(amount, limit, amount.out, kCeilOutFnPtr, roundUp);
} }
/** Calculate the quality of a two-hop path given the two hops. /** Calculate the quality of a two-hop path given the two hops.

View File

@@ -72,7 +72,7 @@ QualityFunction::QualityFunction(
std::uint32_t tfee, std::uint32_t tfee,
QualityFunction::AMMTag) QualityFunction::AMMTag)
{ {
if (amounts.in <= beast::kZERO || amounts.out <= beast::kZERO) if (amounts.in <= beast::kZero || amounts.out <= beast::kZero)
Throw<std::runtime_error>("QualityFunction amounts are 0."); Throw<std::runtime_error>("QualityFunction amounts are 0.");
Number const cfee = feeMult(tfee); Number const cfee = feeMult(tfee);
m_ = -cfee / amounts.in; m_ = -cfee / amounts.in;

View File

@@ -72,6 +72,6 @@ transferFeeAsRate(std::uint16_t fee);
} // namespace nft } // namespace nft
/** A transfer rate signifying a 1:1 exchange */ /** A transfer rate signifying a 1:1 exchange */
extern Rate const kPARITY_RATE; extern Rate const kParityRate;
} // namespace xrpl } // namespace xrpl

View File

@@ -92,7 +92,7 @@ class STCurrency;
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum SerializedTypeID { XMACRO(TO_ENUM) }; enum SerializedTypeID { XMACRO(TO_ENUM) };
static std::map<std::string, int> const kS_TYPE_MAP = {XMACRO(TO_MAP)}; static std::map<std::string, int> const kSTypeMap = {XMACRO(TO_MAP)};
#undef XMACRO #undef XMACRO
#undef TO_ENUM #undef TO_ENUM
@@ -129,23 +129,23 @@ fieldCode(int id, int index)
class SField class SField
{ {
public: public:
static constexpr auto kSMD_NEVER = 0x00; static constexpr auto kSmdNever = 0x00;
static constexpr auto kSMD_CHANGE_ORIG = 0x01; // original value when it changes static constexpr auto kSmdChangeOrig = 0x01; // original value when it changes
static constexpr auto kSMD_CHANGE_NEW = 0x02; // new value when it changes static constexpr auto kSmdChangeNew = 0x02; // new value when it changes
static constexpr auto kSMD_DELETE_FINAL = 0x04; // final value when it is deleted static constexpr auto kSmdDeleteFinal = 0x04; // final value when it is deleted
static constexpr auto kSMD_CREATE = 0x08; // value when it's created static constexpr auto kSmdCreate = 0x08; // value when it's created
static constexpr auto kSMD_ALWAYS = 0x10; // value when node containing it is affected at all static constexpr auto kSmdAlways = 0x10; // value when node containing it is affected at all
static constexpr auto kSMD_BASE_TEN = 0x20; // value is treated as base 10, overriding behavior static constexpr auto kSmdBaseTen = 0x20; // value is treated as base 10, overriding behavior
static constexpr auto kSMD_PSEUDO_ACCOUNT = 0x40; // if this field is set in an ACCOUNT_ROOT static constexpr auto kSmdPseudoAccount = 0x40; // if this field is set in an ACCOUNT_ROOT
// _only_, then it is a pseudo-account // _only_, then it is a pseudo-account
static constexpr auto kSMD_NEEDS_ASSET = 0x80; // This field needs to be associated with an static constexpr auto kSmdNeedsAsset = 0x80; // This field needs to be associated with an
// asset before it is serialized as a ledger // asset before it is serialized as a ledger
// object. Intended for STNumber. // object. Intended for STNumber.
static constexpr auto kSMD_DEFAULT = static constexpr auto kSmdDefault =
kSMD_CHANGE_ORIG | kSMD_CHANGE_NEW | kSMD_DELETE_FINAL | kSMD_CREATE; kSmdChangeOrig | kSmdChangeNew | kSmdDeleteFinal | kSmdCreate;
enum class IsSigning : unsigned char { No, Yes }; enum class IsSigning : unsigned char { No, Yes };
static IsSigning const kNOT_SIGNING = IsSigning::No; static IsSigning const kNotSigning = IsSigning::No;
int const fieldCodeMem; // (type<<16)|index // TODO: rename, clashes with function int const fieldCodeMem; // (type<<16)|index // TODO: rename, clashes with function
SerializedTypeID const fieldType; // STI_* SerializedTypeID const fieldType; // STI_*
@@ -172,7 +172,7 @@ public:
SerializedTypeID tid, SerializedTypeID tid,
int fv, int fv,
char const* fn, char const* fn,
int meta = kSMD_DEFAULT, int meta = kSmdDefault,
IsSigning signing = IsSigning::Yes); IsSigning signing = IsSigning::Yes);
explicit SField(PrivateAccessTagT, int fc, char const* fn); explicit SField(PrivateAccessTagT, int fc, char const* fn);
@@ -365,8 +365,8 @@ using SF_XCHAIN_BRIDGE = TypedField<STXChainBridge>;
#define UNTYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SField const sfName; #define UNTYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SField const sfName;
#define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SF_##stiSuffix const sfName; #define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SF_##stiSuffix const sfName;
extern SField const kSF_INVALID; extern SField const kSfInvalid;
extern SField const kSF_GENERIC; extern SField const kSfGeneric;
#include <xrpl/protocol/detail/sfields.macro> #include <xrpl/protocol/detail/sfields.macro>

View File

@@ -42,24 +42,24 @@ private:
public: public:
using value_type = STAmount; using value_type = STAmount;
constexpr static int kMIN_OFFSET = -96; static constexpr int kMinOffset = -96;
constexpr static int kMAX_OFFSET = 80; static constexpr int kMaxOffset = 80;
// Maximum native value supported by the code // Maximum native value supported by the code
constexpr static std::uint64_t kMIN_VALUE = 1'000'000'000'000'000ull; static constexpr std::uint64_t kMinValue = 1'000'000'000'000'000ull;
static_assert(isPowerOfTen(kMIN_VALUE)); static_assert(isPowerOfTen(kMinValue));
constexpr static std::uint64_t kMAX_VALUE = (kMIN_VALUE * 10) - 1; static constexpr std::uint64_t kMaxValue = (kMinValue * 10) - 1;
static_assert(kMAX_VALUE == 9'999'999'999'999'999ull); static_assert(kMaxValue == 9'999'999'999'999'999ull);
constexpr static std::uint64_t kMAX_NATIVE = 9'000'000'000'000'000'000ull; static constexpr std::uint64_t kMaxNative = 9'000'000'000'000'000'000ull;
// Max native value on network. // Max native value on network.
constexpr static std::uint64_t kMAX_NATIVE_N = 100'000'000'000'000'000ull; static constexpr std::uint64_t kMaxNativeN = 100'000'000'000'000'000ull;
constexpr static std::uint64_t kISSUED_CURRENCY = 0x8'000'000'000'000'000ull; static constexpr std::uint64_t kIssuedCurrency = 0x8'000'000'000'000'000ull;
constexpr static std::uint64_t kPOSITIVE = 0x4'000'000'000'000'000ull; static constexpr std::uint64_t kPositive = 0x4'000'000'000'000'000ull;
constexpr static std::uint64_t kMP_TOKEN = 0x2'000'000'000'000'000ull; static constexpr std::uint64_t kMpToken = 0x2'000'000'000'000'000ull;
constexpr static std::uint64_t kVALUE_MASK = ~(kPOSITIVE | kMP_TOKEN); static constexpr std::uint64_t kValueMask = ~(kPositive | kMpToken);
static std::uint64_t const kU_RATE_ONE; static std::uint64_t const kURateOne;
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
STAmount(SerialIter& sit, SField const& name); STAmount(SerialIter& sit, SField const& name);
@@ -356,7 +356,7 @@ STAmount::STAmount(A const& asset, int mantissa, int exponent)
// Legacy support for new-style amounts // Legacy support for new-style amounts
inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue) inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue)
: asset_(issue), offset_(amount.exponent()), isNegative_(amount < beast::kZERO) : asset_(issue), offset_(amount.exponent()), isNegative_(amount < beast::kZero)
{ {
if (isNegative_) if (isNegative_)
{ {
@@ -371,7 +371,7 @@ inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue)
} }
inline STAmount::STAmount(MPTAmount const& amount, MPTIssue const& mptIssue) inline STAmount::STAmount(MPTAmount const& amount, MPTIssue const& mptIssue)
: asset_(mptIssue), offset_(0), isNegative_(amount < beast::kZERO) : asset_(mptIssue), offset_(0), isNegative_(amount < beast::kZero)
{ {
if (isNegative_) if (isNegative_)
{ {
@@ -498,7 +498,7 @@ STAmount::zeroed() const
inline STAmount:: inline STAmount::
operator bool() const noexcept operator bool() const noexcept
{ {
return *this != beast::kZERO; return *this != beast::kZero;
} }
inline STAmount:: inline STAmount::
@@ -540,7 +540,7 @@ STAmount::fromNumber(A const& a, Number const& number)
return STAmount{asset, intValue, 0, negative}; return STAmount{asset, intValue, 0, negative};
} }
auto const [mantissa, exponent] = working.normalizeToRange(kMIN_VALUE, kMAX_VALUE); auto const [mantissa, exponent] = working.normalizeToRange(kMinValue, kMaxValue);
return STAmount{asset, mantissa, exponent, negative}; return STAmount{asset, mantissa, exponent, negative};
} }
@@ -548,7 +548,7 @@ STAmount::fromNumber(A const& a, Number const& number)
inline void inline void
STAmount::negate() STAmount::negate()
{ {
if (*this != beast::kZERO) if (*this != beast::kZero)
isNegative_ = !isNegative_; isNegative_ = !isNegative_;
} }
@@ -578,7 +578,7 @@ STAmount::value() const noexcept
inline bool inline bool
isLegalNet(STAmount const& value) isLegalNet(STAmount const& value)
{ {
return !value.native() || (value.mantissa() <= STAmount::kMAX_NATIVE_N); return !value.native() || (value.mantissa() <= STAmount::kMaxNativeN);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@@ -65,7 +65,7 @@ struct JsonOptions
} }
/// Returns JsonOptions binary negation, can be used with & (above) for set /// Returns JsonOptions binary negation, can be used with & (above) for set
/// difference e.g. `(options & ~JsonOptions::kINCLUDE_DATE)` /// difference e.g. `(options & ~JsonOptions::kIncludeDate)`
[[nodiscard]] constexpr JsonOptions friend [[nodiscard]] constexpr JsonOptions friend
operator~(JsonOptions v) noexcept operator~(JsonOptions v) noexcept
{ {

View File

@@ -180,7 +180,7 @@ template <int Bits>
bool bool
STBitString<Bits>::isDefault() const STBitString<Bits>::isDefault() const
{ {
return value_ == beast::kZERO; return value_ == beast::kZero;
} }
} // namespace xrpl } // namespace xrpl

View File

@@ -24,7 +24,7 @@ public:
STBlob(SField const& f, void const* data, std::size_t size); STBlob(SField const& f, void const* data, std::size_t size);
STBlob(SField const& f, Buffer&& b); STBlob(SField const& f, Buffer&& b);
STBlob(SField const& n); STBlob(SField const& n);
STBlob(SerialIter&, SField const& name = kSF_GENERIC); STBlob(SerialIter&, SField const& name = kSfGeneric);
[[nodiscard]] std::size_t [[nodiscard]] std::size_t
size() const; size() const;

View File

@@ -7,11 +7,11 @@
namespace xrpl { namespace xrpl {
/** Maximum JSON object nesting depth permitted during parsing. */ /** Maximum JSON object nesting depth permitted during parsing. */
inline constexpr std::size_t kMAX_PARSED_JSON_DEPTH = 64; inline constexpr std::size_t kMaxParsedJsonDepth = 64;
/** Maximum number of elements permitted in any JSON array field during parsing. /** Maximum number of elements permitted in any JSON array field during parsing.
Requests exceeding this limit are rejected with an invalidParams error. */ Requests exceeding this limit are rejected with an invalidParams error. */
inline constexpr std::size_t kMAX_PARSED_JSON_ARRAY_SIZE = 512; inline constexpr std::size_t kMaxParsedJsonArraySize = 512;
/** Holds the serialized result of parsing an input JSON object. /** Holds the serialized result of parsing an input JSON object.
This does validation and checking on the provided JSON. This does validation and checking on the provided JSON.

View File

@@ -30,8 +30,8 @@ class STTx final : public STObject, public CountedObject<STTx>
TxType tx_type_; TxType tx_type_;
public: public:
static constexpr std::size_t kMIN_MULTI_SIGNERS = 1; static constexpr std::size_t kMinMultiSigners = 1;
static constexpr std::size_t kMAX_MULTI_SIGNERS = 32; static constexpr std::size_t kMaxMultiSigners = 32;
STTx() = delete; STTx() = delete;
STTx(STTx const& other) = default; STTx(STTx const& other) = default;

View File

@@ -16,10 +16,10 @@ namespace xrpl {
// Validation flags // Validation flags
// This is a full (as opposed to a partial) validation // This is a full (as opposed to a partial) validation
constexpr std::uint32_t kVF_FULL_VALIDATION = 0x00000001; constexpr std::uint32_t kVfFullValidation = 0x00000001;
// The signature is fully canonical // The signature is fully canonical
constexpr std::uint32_t kVF_FULLY_CANONICAL_SIG = 0x80000000; constexpr std::uint32_t kVfFullyCanonicalSig = 0x80000000;
class STValidation final : public STObject, public CountedObject<STValidation> class STValidation final : public STObject, public CountedObject<STValidation>
{ {
@@ -204,7 +204,7 @@ STValidation::STValidation(
f(*this); f(*this);
// Finally, sign the validation and mark it as trusted: // Finally, sign the validation and mark it as trusted:
setFlag(kVF_FULLY_CANONICAL_SIG); setFlag(kVfFullyCanonicalSig);
setFieldVL(sfSignature, signDigest(pk, sk, getSigningHash())); setFieldVL(sfSignature, signDigest(pk, sk, getSigningHash()));
setTrusted(); setTrusted();

View File

@@ -17,10 +17,10 @@ namespace xrpl {
class SecretKey class SecretKey
{ {
public: public:
static constexpr std::size_t kSIZE = 32; static constexpr std::size_t kSize = 32;
private: private:
std::uint8_t buf_[kSIZE]{}; std::uint8_t buf_[kSize]{};
public: public:
using const_iterator = std::uint8_t const*; using const_iterator = std::uint8_t const*;
@@ -37,7 +37,7 @@ public:
~SecretKey(); ~SecretKey();
SecretKey(std::array<std::uint8_t, kSIZE> const& data); SecretKey(std::array<std::uint8_t, kSize> const& data);
SecretKey(Slice const& slice); SecretKey(Slice const& slice);
[[nodiscard]] std::uint8_t const* [[nodiscard]] std::uint8_t const*

View File

@@ -134,13 +134,13 @@ public:
bool bool
getInteger(Integer& number, int offset) getInteger(Integer& number, int offset)
{ {
static auto const kBYTES = sizeof(Integer); static auto const kBytes = sizeof(Integer);
if ((offset + kBYTES) > data_.size()) if ((offset + kBytes) > data_.size())
return false; return false;
number = 0; number = 0;
auto ptr = &data_[offset]; auto ptr = &data_[offset];
for (auto i = 0; i < kBYTES; ++i) for (auto i = 0; i < kBytes; ++i)
{ {
if (i) if (i)
number <<= 8; number <<= 8;

View File

@@ -14,22 +14,22 @@ namespace xrpl {
static inline std::string const& static inline std::string const&
systemName() systemName()
{ {
static std::string const kNAME = "xrpld"; static std::string const kName = "xrpld";
return kNAME; return kName;
} }
/** Configure the native currency. */ /** Configure the native currency. */
/** Number of drops in the genesis account. */ /** Number of drops in the genesis account. */
constexpr XRPAmount kINITIAL_XRP{100'000'000'000 * kDROPS_PER_XRP}; constexpr XRPAmount kInitialXrp{100'000'000'000 * kDropsPerXrp};
static_assert(kINITIAL_XRP.drops() == 100'000'000'000'000'000); static_assert(kInitialXrp.drops() == 100'000'000'000'000'000);
static_assert(Number::kMAX_REP >= kINITIAL_XRP.drops()); static_assert(Number::kMaxRep >= kInitialXrp.drops());
/** Returns true if the amount does not exceed the initial XRP in existence. */ /** Returns true if the amount does not exceed the initial XRP in existence. */
inline bool inline bool
isLegalAmount(XRPAmount const& amount) isLegalAmount(XRPAmount const& amount)
{ {
return amount <= kINITIAL_XRP; return amount <= kInitialXrp;
} }
/** Returns true if the absolute value of the amount does not exceed the initial /** Returns true if the absolute value of the amount does not exceed the initial
@@ -37,31 +37,31 @@ isLegalAmount(XRPAmount const& amount)
inline bool inline bool
isLegalAmountSigned(XRPAmount const& amount) isLegalAmountSigned(XRPAmount const& amount)
{ {
return amount >= -kINITIAL_XRP && amount <= kINITIAL_XRP; return amount >= -kInitialXrp && amount <= kInitialXrp;
} }
/* The currency code for the native currency. */ /* The currency code for the native currency. */
static inline std::string const& static inline std::string const&
systemCurrencyCode() systemCurrencyCode()
{ {
static std::string const kCODE = "XRP"; static std::string const kCode = "XRP";
return kCODE; return kCode;
} }
/** The XRP ledger network's earliest allowed sequence */ /** The XRP ledger network's earliest allowed sequence */
static constexpr std::uint32_t kXRP_LEDGER_EARLIEST_SEQ{32570u}; static constexpr std::uint32_t kXrpLedgerEarliestSeq{32570u};
/** The XRP Ledger mainnet's earliest ledger with a FeeSettings object. Only /** The XRP Ledger mainnet's earliest ledger with a FeeSettings object. Only
* used in asserts and tests. */ * used in asserts and tests. */
static constexpr std::uint32_t kXRP_LEDGER_EARLIEST_FEES{562177u}; static constexpr std::uint32_t kXrpLedgerEarliestFees{562177u};
/** The minimum amount of support an amendment should have. */ /** The minimum amount of support an amendment should have. */
constexpr std::ratio<80, 100> kAMENDMENT_MAJORITY_CALC_THRESHOLD; constexpr std::ratio<80, 100> kAmendmentMajorityCalcThreshold;
/** The minimum amount of time an amendment must hold a majority */ /** The minimum amount of time an amendment must hold a majority */
constexpr std::chrono::seconds const kDEFAULT_AMENDMENT_MAJORITY_TIME = weeks{2}; constexpr std::chrono::seconds const kDefaultAmendmentMajorityTime = weeks{2};
} // namespace xrpl } // namespace xrpl
/** Default peer port (IANA registered) */ /** Default peer port (IANA registered) */
inline std::uint16_t constexpr kDEFAULT_PEER_PORT{2459}; inline constexpr std::uint16_t kDefaultPeerPort{2459};

View File

@@ -62,7 +62,7 @@ badCurrency();
inline bool inline bool
isXRP(Currency const& c) isXRP(Currency const& c)
{ {
return c == beast::kZERO; return c == beast::kZero;
} }
/** Returns "", "XRP", or three letter ISO code. */ /** Returns "", "XRP", or three letter ISO code. */

View File

@@ -300,13 +300,13 @@ public:
using jsontype = using jsontype =
std::conditional_t<std::is_signed_v<value_type>, json::Int, json::UInt>; std::conditional_t<std::is_signed_v<value_type>, json::Int, json::UInt>;
constexpr auto kMIN = std::numeric_limits<jsontype>::min(); constexpr auto kMin = std::numeric_limits<jsontype>::min();
constexpr auto kMAX = std::numeric_limits<jsontype>::max(); constexpr auto kMax = std::numeric_limits<jsontype>::max();
if (value_ < kMIN) if (value_ < kMin)
return kMIN; return kMin;
if (value_ > kMAX) if (value_ > kMax)
return kMAX; return kMax;
return static_cast<jsontype>(value_); return static_cast<jsontype>(value_);
} }
else else
@@ -392,14 +392,14 @@ mulDivU(Source1 value, Dest mul, Source2 div)
} }
using desttype = typename Dest::value_type; using desttype = typename Dest::value_type;
constexpr auto kMAX = std::numeric_limits<desttype>::max(); constexpr auto kMax = std::numeric_limits<desttype>::max();
// Shortcuts, since these happen a lot in the real world // Shortcuts, since these happen a lot in the real world
if (value == div) if (value == div)
return mul; return mul;
if (mul.value() == div.value()) if (mul.value() == div.value())
{ {
if (value.value() > kMAX) if (value.value() > kMax)
return std::nullopt; return std::nullopt;
return Dest{static_cast<desttype>(value.value())}; return Dest{static_cast<desttype>(value.value())};
} }
@@ -414,7 +414,7 @@ mulDivU(Source1 value, Dest mul, Source2 div)
auto quotient = product / div.value(); auto quotient = product / div.value();
if (quotient > kMAX) if (quotient > kMax)
return std::nullopt; return std::nullopt;
return Dest{static_cast<desttype>(quotient)}; return Dest{static_cast<desttype>(quotient)};

View File

@@ -357,7 +357,7 @@ private:
// Set a max number of allowed attestations to limit the amount of memory // Set a max number of allowed attestations to limit the amount of memory
// allocated and processing time. This number is much larger than the actual // allocated and processing time. This number is much larger than the actual
// number of attestation a server would ever expect. // number of attestation a server would ever expect.
static constexpr std::uint32_t kMAX_ATTESTATIONS = 256; static constexpr std::uint32_t kMaxAttestations = 256;
AttCollection attestations_; AttCollection attestations_;
protected: protected:

View File

@@ -202,13 +202,13 @@ public:
std::is_signed_v<value_type> && std::is_integral_v<value_type>, std::is_signed_v<value_type> && std::is_integral_v<value_type>,
"Expected XRPAmount to be a signed integral type"); "Expected XRPAmount to be a signed integral type");
constexpr auto kMIN = std::numeric_limits<json::Int>::min(); constexpr auto kMin = std::numeric_limits<json::Int>::min();
constexpr auto kMAX = std::numeric_limits<json::Int>::max(); constexpr auto kMax = std::numeric_limits<json::Int>::max();
if (drops_ < kMIN) if (drops_ < kMin)
return kMIN; return kMin;
if (drops_ > kMAX) if (drops_ > kMax)
return kMAX; return kMax;
return static_cast<json::Int>(drops_); return static_cast<json::Int>(drops_);
} }
@@ -237,12 +237,12 @@ public:
}; };
/** Number of drops per 1 XRP */ /** Number of drops per 1 XRP */
constexpr XRPAmount kDROPS_PER_XRP{1'000'000}; constexpr XRPAmount kDropsPerXrp{1'000'000};
constexpr double constexpr double
XRPAmount::decimalXRP() const XRPAmount::decimalXRP() const
{ {
return static_cast<double>(drops_) / kDROPS_PER_XRP.drops(); return static_cast<double>(drops_) / kDropsPerXrp.drops();
} }
// Output XRPAmount as just the drops value. // Output XRPAmount as just the drops value.

View File

@@ -35,9 +35,9 @@ class STVar
{ {
private: private:
// The largest "small object" we can accommodate // The largest "small object" we can accommodate
static std::size_t constexpr kMAX_SIZE = 72; static constexpr std::size_t kMaxSize = 72;
std::aligned_storage<kMAX_SIZE>::type d_ = {}; std::aligned_storage<kMaxSize>::type d_ = {};
STBase* p_ = nullptr; STBase* p_ = nullptr;
public: public:
@@ -51,12 +51,12 @@ public:
STVar(STBase&& t) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) STVar(STBase&& t) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
{ {
p_ = t.move(kMAX_SIZE, &d_); p_ = t.move(kMaxSize, &d_);
} }
STVar(STBase const& t) STVar(STBase const& t)
{ {
p_ = t.copy(kMAX_SIZE, &d_); p_ = t.copy(kMaxSize, &d_);
} }
STVar(DefaultObjectT, SField const& name); STVar(DefaultObjectT, SField const& name);
@@ -110,7 +110,7 @@ private:
void void
construct(Args&&... args) construct(Args&&... args)
{ {
if constexpr (sizeof(T) > kMAX_SIZE) if constexpr (sizeof(T) > kMaxSize)
{ {
p_ = new T(std::forward<Args>(args)...); p_ = new T(std::forward<Args>(args)...);
} }

View File

@@ -155,16 +155,16 @@ inplaceBigintDivRem(std::span<uint64_t> numerator, std::uint64_t divisor)
[[nodiscard]] inline std::array<std::uint8_t, 10> [[nodiscard]] inline std::array<std::uint8_t, 10>
b5810ToB58Be(std::uint64_t input) b5810ToB58Be(std::uint64_t input)
{ {
[[maybe_unused]] static constexpr std::uint64_t kB_58_10 = 430804206899405824; // 58^10; [[maybe_unused]] static constexpr std::uint64_t kB5810 = 430804206899405824; // 58^10;
XRPL_ASSERT(input < kB_58_10, "xrpl::b58_fast::detail::b5810ToB58Be : valid input"); XRPL_ASSERT(input < kB5810, "xrpl::b58_fast::detail::b5810ToB58Be : valid input");
constexpr std::size_t kRESULT_SIZE = 10; static constexpr std::size_t kResultSize = 10;
std::array<std::uint8_t, kRESULT_SIZE> result{}; std::array<std::uint8_t, kResultSize> result{};
int i = 0; int i = 0;
while (input > 0) while (input > 0)
{ {
std::uint64_t rem = 0; std::uint64_t rem = 0;
std::tie(input, rem) = divRem(input, 58); std::tie(input, rem) = divRem(input, 58);
result[kRESULT_SIZE - 1 - i] = rem; result[kResultSize - 1 - i] = rem;
i += 1; i += 1;
} }

View File

@@ -84,7 +84,7 @@ LEDGER_ENTRY(ltNEGATIVE_UNL, 0x004e, NegativeUNL, nunl, ({
/** A ledger object which contains a list of NFTs /** A ledger object which contains a list of NFTs
\sa keylet::nftpage_min, keylet::nftpage_max, keylet::nftpage \sa keylet::nftpageMin, keylet::nftpageMax, keylet::nftpage
*/ */
LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, nft_page, ({ LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, nft_page, ({
{sfPreviousPageMin, SoeOptional}, {sfPreviousPageMin, SoeOptional},
@@ -112,7 +112,7 @@ LEDGER_ENTRY(ltSIGNER_LIST, 0x0053, SignerList, signer_list, ({
/** A ledger object which describes a ticket. /** A ledger object which describes a ticket.
\sa keylet::ticket \sa keylet::kTicket
*/ */
LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ticket, ({ LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ticket, ({
{sfAccount, SoeRequired}, {sfAccount, SoeRequired},

View File

@@ -27,7 +27,7 @@ TYPED_SFIELD(sfWasLockingChainSend, UINT8, 19)
TYPED_SFIELD(sfWithdrawalPolicy, UINT8, 20) TYPED_SFIELD(sfWithdrawalPolicy, UINT8, 20)
// 16-bit integers (common) // 16-bit integers (common)
TYPED_SFIELD(sfLedgerEntryType, UINT16, 1, SField::kSMD_NEVER) TYPED_SFIELD(sfLedgerEntryType, UINT16, 1, SField::kSmdNever)
TYPED_SFIELD(sfTransactionType, UINT16, 2) TYPED_SFIELD(sfTransactionType, UINT16, 2)
TYPED_SFIELD(sfSignerWeight, UINT16, 3) TYPED_SFIELD(sfSignerWeight, UINT16, 3)
TYPED_SFIELD(sfTransferFee, UINT16, 4) TYPED_SFIELD(sfTransferFee, UINT16, 4)
@@ -48,7 +48,7 @@ TYPED_SFIELD(sfNetworkID, UINT32, 1)
TYPED_SFIELD(sfFlags, UINT32, 2) TYPED_SFIELD(sfFlags, UINT32, 2)
TYPED_SFIELD(sfSourceTag, UINT32, 3) TYPED_SFIELD(sfSourceTag, UINT32, 3)
TYPED_SFIELD(sfSequence, UINT32, 4) TYPED_SFIELD(sfSequence, UINT32, 4)
TYPED_SFIELD(sfPreviousTxnLgrSeq, UINT32, 5, SField::kSMD_DELETE_FINAL) TYPED_SFIELD(sfPreviousTxnLgrSeq, UINT32, 5, SField::kSmdDeleteFinal)
TYPED_SFIELD(sfLedgerSequence, UINT32, 6) TYPED_SFIELD(sfLedgerSequence, UINT32, 6)
TYPED_SFIELD(sfCloseTime, UINT32, 7) TYPED_SFIELD(sfCloseTime, UINT32, 7)
TYPED_SFIELD(sfParentCloseTime, UINT32, 8) TYPED_SFIELD(sfParentCloseTime, UINT32, 8)
@@ -138,12 +138,12 @@ TYPED_SFIELD(sfXChainClaimID, UINT64, 20)
TYPED_SFIELD(sfXChainAccountCreateCount, UINT64, 21) TYPED_SFIELD(sfXChainAccountCreateCount, UINT64, 21)
TYPED_SFIELD(sfXChainAccountClaimCount, UINT64, 22) TYPED_SFIELD(sfXChainAccountClaimCount, UINT64, 22)
TYPED_SFIELD(sfAssetPrice, UINT64, 23) TYPED_SFIELD(sfAssetPrice, UINT64, 23)
TYPED_SFIELD(sfMaximumAmount, UINT64, 24, SField::kSMD_BASE_TEN|SField::kSMD_DEFAULT) TYPED_SFIELD(sfMaximumAmount, UINT64, 24, SField::kSmdBaseTen|SField::kSmdDefault)
TYPED_SFIELD(sfOutstandingAmount, UINT64, 25, SField::kSMD_BASE_TEN|SField::kSMD_DEFAULT) TYPED_SFIELD(sfOutstandingAmount, UINT64, 25, SField::kSmdBaseTen|SField::kSmdDefault)
TYPED_SFIELD(sfMPTAmount, UINT64, 26, SField::kSMD_BASE_TEN|SField::kSMD_DEFAULT) TYPED_SFIELD(sfMPTAmount, UINT64, 26, SField::kSmdBaseTen|SField::kSmdDefault)
TYPED_SFIELD(sfIssuerNode, UINT64, 27) TYPED_SFIELD(sfIssuerNode, UINT64, 27)
TYPED_SFIELD(sfSubjectNode, UINT64, 28) TYPED_SFIELD(sfSubjectNode, UINT64, 28)
TYPED_SFIELD(sfLockedAmount, UINT64, 29, SField::kSMD_BASE_TEN|SField::kSMD_DEFAULT) TYPED_SFIELD(sfLockedAmount, UINT64, 29, SField::kSmdBaseTen|SField::kSmdDefault)
TYPED_SFIELD(sfVaultNode, UINT64, 30) TYPED_SFIELD(sfVaultNode, UINT64, 30)
TYPED_SFIELD(sfLoanBrokerNode, UINT64, 31) TYPED_SFIELD(sfLoanBrokerNode, UINT64, 31)
@@ -167,17 +167,17 @@ TYPED_SFIELD(sfLedgerHash, UINT256, 1)
TYPED_SFIELD(sfParentHash, UINT256, 2) TYPED_SFIELD(sfParentHash, UINT256, 2)
TYPED_SFIELD(sfTransactionHash, UINT256, 3) TYPED_SFIELD(sfTransactionHash, UINT256, 3)
TYPED_SFIELD(sfAccountHash, UINT256, 4) TYPED_SFIELD(sfAccountHash, UINT256, 4)
TYPED_SFIELD(sfPreviousTxnID, UINT256, 5, SField::kSMD_DELETE_FINAL) TYPED_SFIELD(sfPreviousTxnID, UINT256, 5, SField::kSmdDeleteFinal)
TYPED_SFIELD(sfLedgerIndex, UINT256, 6) TYPED_SFIELD(sfLedgerIndex, UINT256, 6)
TYPED_SFIELD(sfWalletLocator, UINT256, 7) TYPED_SFIELD(sfWalletLocator, UINT256, 7)
TYPED_SFIELD(sfRootIndex, UINT256, 8, SField::kSMD_ALWAYS) TYPED_SFIELD(sfRootIndex, UINT256, 8, SField::kSmdAlways)
TYPED_SFIELD(sfAccountTxnID, UINT256, 9) TYPED_SFIELD(sfAccountTxnID, UINT256, 9)
TYPED_SFIELD(sfNFTokenID, UINT256, 10) TYPED_SFIELD(sfNFTokenID, UINT256, 10)
TYPED_SFIELD(sfEmitParentTxnID, UINT256, 11) TYPED_SFIELD(sfEmitParentTxnID, UINT256, 11)
TYPED_SFIELD(sfEmitNonce, UINT256, 12) TYPED_SFIELD(sfEmitNonce, UINT256, 12)
TYPED_SFIELD(sfEmitHookHash, UINT256, 13) TYPED_SFIELD(sfEmitHookHash, UINT256, 13)
TYPED_SFIELD(sfAMMID, UINT256, 14, TYPED_SFIELD(sfAMMID, UINT256, 14,
SField::kSMD_PSEUDO_ACCOUNT | SField::kSMD_DEFAULT) SField::kSmdPseudoAccount | SField::kSmdDefault)
// 256-bit (uncommon) // 256-bit (uncommon)
TYPED_SFIELD(sfBookDirectory, UINT256, 16) TYPED_SFIELD(sfBookDirectory, UINT256, 16)
@@ -200,30 +200,30 @@ TYPED_SFIELD(sfHookNamespace, UINT256, 32)
TYPED_SFIELD(sfHookSetTxnID, UINT256, 33) TYPED_SFIELD(sfHookSetTxnID, UINT256, 33)
TYPED_SFIELD(sfDomainID, UINT256, 34) TYPED_SFIELD(sfDomainID, UINT256, 34)
TYPED_SFIELD(sfVaultID, UINT256, 35, TYPED_SFIELD(sfVaultID, UINT256, 35,
SField::kSMD_PSEUDO_ACCOUNT | SField::kSMD_DEFAULT) SField::kSmdPseudoAccount | SField::kSmdDefault)
TYPED_SFIELD(sfParentBatchID, UINT256, 36) TYPED_SFIELD(sfParentBatchID, UINT256, 36)
TYPED_SFIELD(sfLoanBrokerID, UINT256, 37, TYPED_SFIELD(sfLoanBrokerID, UINT256, 37,
SField::kSMD_PSEUDO_ACCOUNT | SField::kSMD_DEFAULT) SField::kSmdPseudoAccount | SField::kSmdDefault)
TYPED_SFIELD(sfLoanID, UINT256, 38) TYPED_SFIELD(sfLoanID, UINT256, 38)
// number (common) // number (common)
TYPED_SFIELD(sfNumber, NUMBER, 1) TYPED_SFIELD(sfNumber, NUMBER, 1)
TYPED_SFIELD(sfAssetsAvailable, NUMBER, 2, SField::kSMD_NEEDS_ASSET | SField::kSMD_DEFAULT) TYPED_SFIELD(sfAssetsAvailable, NUMBER, 2, SField::kSmdNeedsAsset | SField::kSmdDefault)
TYPED_SFIELD(sfAssetsMaximum, NUMBER, 3, SField::kSMD_NEEDS_ASSET | SField::kSMD_DEFAULT) TYPED_SFIELD(sfAssetsMaximum, NUMBER, 3, SField::kSmdNeedsAsset | SField::kSmdDefault)
TYPED_SFIELD(sfAssetsTotal, NUMBER, 4, SField::kSMD_NEEDS_ASSET | SField::kSMD_DEFAULT) TYPED_SFIELD(sfAssetsTotal, NUMBER, 4, SField::kSmdNeedsAsset | SField::kSmdDefault)
TYPED_SFIELD(sfLossUnrealized, NUMBER, 5, SField::kSMD_NEEDS_ASSET | SField::kSMD_DEFAULT) TYPED_SFIELD(sfLossUnrealized, NUMBER, 5, SField::kSmdNeedsAsset | SField::kSmdDefault)
TYPED_SFIELD(sfDebtTotal, NUMBER, 6, SField::kSMD_NEEDS_ASSET | SField::kSMD_DEFAULT) TYPED_SFIELD(sfDebtTotal, NUMBER, 6, SField::kSmdNeedsAsset | SField::kSmdDefault)
TYPED_SFIELD(sfDebtMaximum, NUMBER, 7, SField::kSMD_NEEDS_ASSET | SField::kSMD_DEFAULT) TYPED_SFIELD(sfDebtMaximum, NUMBER, 7, SField::kSmdNeedsAsset | SField::kSmdDefault)
TYPED_SFIELD(sfCoverAvailable, NUMBER, 8, SField::kSMD_NEEDS_ASSET | SField::kSMD_DEFAULT) TYPED_SFIELD(sfCoverAvailable, NUMBER, 8, SField::kSmdNeedsAsset | SField::kSmdDefault)
TYPED_SFIELD(sfLoanOriginationFee, NUMBER, 9) TYPED_SFIELD(sfLoanOriginationFee, NUMBER, 9)
TYPED_SFIELD(sfLoanServiceFee, NUMBER, 10) TYPED_SFIELD(sfLoanServiceFee, NUMBER, 10)
TYPED_SFIELD(sfLatePaymentFee, NUMBER, 11) TYPED_SFIELD(sfLatePaymentFee, NUMBER, 11)
TYPED_SFIELD(sfClosePaymentFee, NUMBER, 12) TYPED_SFIELD(sfClosePaymentFee, NUMBER, 12)
TYPED_SFIELD(sfPrincipalOutstanding, NUMBER, 13, SField::kSMD_NEEDS_ASSET | SField::kSMD_DEFAULT) TYPED_SFIELD(sfPrincipalOutstanding, NUMBER, 13, SField::kSmdNeedsAsset | SField::kSmdDefault)
TYPED_SFIELD(sfPrincipalRequested, NUMBER, 14) TYPED_SFIELD(sfPrincipalRequested, NUMBER, 14)
TYPED_SFIELD(sfTotalValueOutstanding, NUMBER, 15, SField::kSMD_NEEDS_ASSET | SField::kSMD_DEFAULT) TYPED_SFIELD(sfTotalValueOutstanding, NUMBER, 15, SField::kSmdNeedsAsset | SField::kSmdDefault)
TYPED_SFIELD(sfPeriodicPayment, NUMBER, 16) TYPED_SFIELD(sfPeriodicPayment, NUMBER, 16)
TYPED_SFIELD(sfManagementFeeOutstanding, NUMBER, 17, SField::kSMD_NEEDS_ASSET | SField::kSMD_DEFAULT) TYPED_SFIELD(sfManagementFeeOutstanding, NUMBER, 17, SField::kSmdNeedsAsset | SField::kSmdDefault)
// int32 // int32
TYPED_SFIELD(sfLoanScale, INT32, 1) TYPED_SFIELD(sfLoanScale, INT32, 1)
@@ -269,9 +269,9 @@ TYPED_SFIELD(sfLPTokenBalance, AMOUNT, 31)
TYPED_SFIELD(sfPublicKey, VL, 1) TYPED_SFIELD(sfPublicKey, VL, 1)
TYPED_SFIELD(sfMessageKey, VL, 2) TYPED_SFIELD(sfMessageKey, VL, 2)
TYPED_SFIELD(sfSigningPubKey, VL, 3) TYPED_SFIELD(sfSigningPubKey, VL, 3)
TYPED_SFIELD(sfTxnSignature, VL, 4, SField::kSMD_DEFAULT, SField::kNOT_SIGNING) TYPED_SFIELD(sfTxnSignature, VL, 4, SField::kSmdDefault, SField::kNotSigning)
TYPED_SFIELD(sfURI, VL, 5) TYPED_SFIELD(sfURI, VL, 5)
TYPED_SFIELD(sfSignature, VL, 6, SField::kSMD_DEFAULT, SField::kNOT_SIGNING) TYPED_SFIELD(sfSignature, VL, 6, SField::kSmdDefault, SField::kNotSigning)
TYPED_SFIELD(sfDomain, VL, 7) TYPED_SFIELD(sfDomain, VL, 7)
TYPED_SFIELD(sfFundCode, VL, 8) TYPED_SFIELD(sfFundCode, VL, 8)
TYPED_SFIELD(sfRemoveCode, VL, 9) TYPED_SFIELD(sfRemoveCode, VL, 9)
@@ -284,7 +284,7 @@ TYPED_SFIELD(sfMemoFormat, VL, 14)
// variable length (uncommon) // variable length (uncommon)
TYPED_SFIELD(sfFulfillment, VL, 16) TYPED_SFIELD(sfFulfillment, VL, 16)
TYPED_SFIELD(sfCondition, VL, 17) TYPED_SFIELD(sfCondition, VL, 17)
TYPED_SFIELD(sfMasterSignature, VL, 18, SField::kSMD_DEFAULT, SField::kNOT_SIGNING) TYPED_SFIELD(sfMasterSignature, VL, 18, SField::kSmdDefault, SField::kNotSigning)
TYPED_SFIELD(sfUNLModifyValidator, VL, 19) TYPED_SFIELD(sfUNLModifyValidator, VL, 19)
TYPED_SFIELD(sfValidatorToDisable, VL, 20) TYPED_SFIELD(sfValidatorToDisable, VL, 20)
TYPED_SFIELD(sfValidatorToReEnable, VL, 21) TYPED_SFIELD(sfValidatorToReEnable, VL, 21)
@@ -326,7 +326,7 @@ TYPED_SFIELD(sfBorrower, ACCOUNT, 25)
TYPED_SFIELD(sfCounterparty, ACCOUNT, 26) TYPED_SFIELD(sfCounterparty, ACCOUNT, 26)
// vector of 256-bit // vector of 256-bit
TYPED_SFIELD(sfIndexes, VECTOR256, 1, SField::kSMD_NEVER) TYPED_SFIELD(sfIndexes, VECTOR256, 1, SField::kSmdNever)
TYPED_SFIELD(sfHashes, VECTOR256, 2) TYPED_SFIELD(sfHashes, VECTOR256, 2)
TYPED_SFIELD(sfAmendments, VECTOR256, 3) TYPED_SFIELD(sfAmendments, VECTOR256, 3)
TYPED_SFIELD(sfNFTokenOffers, VECTOR256, 4) TYPED_SFIELD(sfNFTokenOffers, VECTOR256, 4)
@@ -387,13 +387,13 @@ UNTYPED_SFIELD(sfCredential, OBJECT, 33)
UNTYPED_SFIELD(sfRawTransaction, OBJECT, 34) UNTYPED_SFIELD(sfRawTransaction, OBJECT, 34)
UNTYPED_SFIELD(sfBatchSigner, OBJECT, 35) UNTYPED_SFIELD(sfBatchSigner, OBJECT, 35)
UNTYPED_SFIELD(sfBook, OBJECT, 36) UNTYPED_SFIELD(sfBook, OBJECT, 36)
UNTYPED_SFIELD(sfCounterpartySignature, OBJECT, 37, SField::kSMD_DEFAULT, SField::kNOT_SIGNING) UNTYPED_SFIELD(sfCounterpartySignature, OBJECT, 37, SField::kSmdDefault, SField::kNotSigning)
// array of objects (common) // array of objects (common)
// ARRAY/1 is reserved for end of array // ARRAY/1 is reserved for end of array
// sfSigningAccounts has never been used. // sfSigningAccounts has never been used.
//UNTYPED_SFIELD(sfSigningAccounts, ARRAY, 2) //UNTYPED_SFIELD(sfSigningAccounts, ARRAY, 2)
UNTYPED_SFIELD(sfSigners, ARRAY, 3, SField::kSMD_DEFAULT, SField::kNOT_SIGNING) UNTYPED_SFIELD(sfSigners, ARRAY, 3, SField::kSmdDefault, SField::kNotSigning)
UNTYPED_SFIELD(sfSignerEntries, ARRAY, 4) UNTYPED_SFIELD(sfSignerEntries, ARRAY, 4)
UNTYPED_SFIELD(sfTemplate, ARRAY, 5) UNTYPED_SFIELD(sfTemplate, ARRAY, 5)
UNTYPED_SFIELD(sfNecessary, ARRAY, 6) UNTYPED_SFIELD(sfNecessary, ARRAY, 6)
@@ -421,4 +421,4 @@ UNTYPED_SFIELD(sfUnauthorizeCredentials, ARRAY, 27)
UNTYPED_SFIELD(sfAcceptedCredentials, ARRAY, 28) UNTYPED_SFIELD(sfAcceptedCredentials, ARRAY, 28)
UNTYPED_SFIELD(sfPermissions, ARRAY, 29) UNTYPED_SFIELD(sfPermissions, ARRAY, 29)
UNTYPED_SFIELD(sfRawTransactions, ARRAY, 30) UNTYPED_SFIELD(sfRawTransactions, ARRAY, 30)
UNTYPED_SFIELD(sfBatchSigners, ARRAY, 31, SField::kSMD_DEFAULT, SField::kNOT_SIGNING) UNTYPED_SFIELD(sfBatchSigners, ARRAY, 31, SField::kSmdDefault, SField::kNotSigning)

View File

@@ -27,7 +27,7 @@ namespace xrpl {
struct OpensslRipemd160Hasher struct OpensslRipemd160Hasher
{ {
public: public:
static constexpr auto const kENDIAN = boost::endian::order::native; static constexpr auto kEndian = boost::endian::order::native;
using result_type = std::array<std::uint8_t, 20>; using result_type = std::array<std::uint8_t, 20>;
@@ -50,7 +50,7 @@ private:
struct OpensslSha512Hasher struct OpensslSha512Hasher
{ {
public: public:
static constexpr auto const kENDIAN = boost::endian::order::native; static constexpr auto kEndian = boost::endian::order::native;
using result_type = std::array<std::uint8_t, 64>; using result_type = std::array<std::uint8_t, 64>;
@@ -73,7 +73,7 @@ private:
struct OpensslSha256Hasher struct OpensslSha256Hasher
{ {
public: public:
static constexpr auto const kENDIAN = boost::endian::order::native; static constexpr auto kEndian = boost::endian::order::native;
using result_type = std::array<std::uint8_t, 32>; using result_type = std::array<std::uint8_t, 32>;
@@ -118,7 +118,7 @@ private:
sha256_hasher h_; sha256_hasher h_;
public: public:
static constexpr auto const kENDIAN = boost::endian::order::native; static constexpr auto kEndian = boost::endian::order::native;
using result_type = std::array<std::uint8_t, 20>; using result_type = std::array<std::uint8_t, 20>;
@@ -154,7 +154,7 @@ private:
sha512_hasher h_; sha512_hasher h_;
public: public:
static constexpr auto const kENDIAN = boost::endian::order::big; static constexpr auto kEndian = boost::endian::order::big;
using result_type = uint256; using result_type = uint256;

View File

@@ -29,11 +29,11 @@ toUInt32(Taxon t)
return static_cast<std::uint32_t>(t); return static_cast<std::uint32_t>(t);
} }
constexpr std::uint16_t const kFLAG_BURNABLE = 0x0001; constexpr std::uint16_t const kFlagBurnable = 0x0001;
constexpr std::uint16_t const kFLAG_ONLY_XRP = 0x0002; constexpr std::uint16_t const kFlagOnlyXrp = 0x0002;
constexpr std::uint16_t const kFLAG_CREATE_TRUST_LINES = 0x0004; constexpr std::uint16_t const kFlagCreateTrustLines = 0x0004;
constexpr std::uint16_t const kFLAG_TRANSFERABLE = 0x0008; constexpr std::uint16_t const kFlagTransferable = 0x0008;
constexpr std::uint16_t const kFLAG_MUTABLE = 0x0010; constexpr std::uint16_t const kFlagMutable = 0x0010;
inline std::uint16_t inline std::uint16_t
getFlags(uint256 const& id) getFlags(uint256 const& id)

View File

@@ -8,7 +8,7 @@ namespace xrpl::nft {
// NFT directory pages order their contents based only on the low 96 bits of // NFT directory pages order their contents based only on the low 96 bits of
// the NFToken value. This mask provides easy access to the necessary mask. // the NFToken value. This mask provides easy access to the necessary mask.
uint256 constexpr kPAGE_MASK( constexpr uint256 kPageMask(
std::string_view("0000000000000000000000000000000000000000ffffffffffffffffffffffff")); std::string_view("0000000000000000000000000000000000000000ffffffffffffffffffffffff"));
} // namespace xrpl::nft } // namespace xrpl::nft

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