Compare commits

...

36 Commits

Author SHA1 Message Date
dependabot[bot]
3542daa4cc ci: [DEPENDABOT] bump actions/upload-artifact from 4.6.2 to 6.0.0 (#6396)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.2 to 6.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](ea165f8d65...b7c566a772)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-20 22:48:01 +00:00
dependabot[bot]
fd9f57ec97 ci: [DEPENDABOT] bump actions/checkout from 4.3.0 to 6.0.2 (#6397)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.3.0 to 6.0.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4.3.0...de0fac2e4500dabe0009e67214ff5f5447ce83dd)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.2
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-20 22:09:48 +00:00
dependabot[bot]
625becff18 ci: [DEPENDABOT] bump actions/setup-python from 5.6.0 to 6.2.0 (#6395)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.6.0 to 6.2.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](a26af69be9...a309ff8b42)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 6.2.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-20 21:29:05 +00:00
dependabot[bot]
4bcbc6e50f ci: [DEPENDABOT] bump tj-actions/changed-files from 46.0.5 to 47.0.4 (#6394)
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 46.0.5 to 47.0.4.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](ed68ef82c0...7dee1b0c15)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-version: 47.0.4
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-20 19:59:37 +00:00
dependabot[bot]
0bc4a0cfe8 ci: [DEPENDABOT] bump codecov/codecov-action from 5.4.3 to 5.5.2 (#6398)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.3 to 5.5.2.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](18283e04ce...671740ac38)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 5.5.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-20 19:11:26 +00:00
Ayaz Salikhov
cb54adefed ci: Build docs in PRs and in private repos (#6400) 2026-02-20 13:41:43 -05:00
Ayaz Salikhov
d03d72bfd5 ci: Add dependabot config (#6379) 2026-02-20 09:19:00 +00:00
Ed Hennis
6f35d94b2f Fix tautological assertion (#6393) 2026-02-20 01:58:47 +00:00
Ayaz Salikhov
2c1fad1023 chore: Apply clang-format width 100 (#6387) 2026-02-19 23:30:00 +00:00
Ayaz Salikhov
25cca46553 chore: Set clang-format width to 100 in config file (#6387) 2026-02-19 23:29:46 +00:00
Ayaz Salikhov
469ce9f291 chore: Set cmake-format width to 100 (#6386) 2026-02-19 19:42:51 +00:00
Sergey Kuznetsov
31302877ab ci: Add clang tidy workflow to ci (#6369) 2026-02-19 14:06:44 -05:00
Jingchen
0976b2b68b refactor: Modularize app/tx (#6228) 2026-02-17 18:10:07 +00:00
Jingchen
36240116a5 refactor: Decouple app/tx from Application and Config (#6227)
This change decouples app/tx from `Application` and `Config` to clear the way to moving transactors to `libxrpl`.
2026-02-17 11:29:53 -05:00
Sergey Kuznetsov
958d8f3754 chore: Update clang-format to 21.1.8 (#6352) 2026-02-16 14:31:18 -05:00
Jingchen
ac0ad3627f refactor: Modularize HashRouter, Conditions, and OrderBookDB (#6226)
This change modularizes additional components by moving code to `libxrpl`.
2026-02-13 10:34:37 -05:00
nuxtreact
cd218346ff chore: Fix minor issues in comments (#6346) 2026-02-12 14:55:27 -05:00
Jingchen
5edd3566f7 refactor: Modularize the NetworkOPs interface (#6225)
This change moves the NetworkOPs interface into `libxrpl` and it leaves its implementation in `xrpld`.
2026-02-12 13:15:03 -05:00
Pratik Mankawde
11e8d1f8a2 chore: Fix gcov lib coverage build failure on macOS (#6350)
For coverage builds, we try to link against the `gcov` library (specific to the environment). But as macOS doesn't have this library and thus doesn't have the coverage tools to generate reports, the coverage builds on that platform were failing on linking.

We actually don't need to explicitly force this linking, as the `CodeCoverage` file already has correct detection logic (currently on lines 177-193), which is invoked when the `--coverage` flag is provided:
* AppleClang: Uses `xcrun -f llvm-cov` to set `GCOV_TOOL="llvm-cov gcov"`.
* Clang: Finds `llvm-cov` to set `GCOV_TOOL="llvm-cov gcov"`.
* GCC: Finds `gcov` to set `GCOV_TOOL="gcov"`.
The `GCOV_TOOL` is then passed to `gcovr` on line 416, so the correct tool is used for processing coverage data.

This change therefore removes the `gcov` suffix from lines 473 and 475 in the `CodeCoverage.cmake` file.
2026-02-12 06:11:26 -05:00
Jingchen
9f17d10348 refactor: Modularize RelationalDB (#6224)
The rdb module was not properly designed, which is fixed in this change. The module had three classes:
1) The abstract class `RelationalDB`.
2) The abstract class `SQLiteDatabase`, which inherited from `RelationalDB` and added some pure virtual methods.
3) The concrete class `SQLiteDatabaseImp`, which inherited from `SQLiteDatabase` and implemented all methods.

The updated code simplifies this as follows:
* The `SQLiteDatabaseImp` has become `SQLiteDatabase`, and
* The former `SQLiteDatabase `has merged with `RelationalDatabase`.
2026-02-11 16:22:01 +00:00
Jingchen
ef284692db refactor: Modularize WalletDB and Manifest (#6223)
This change modularizes the `WalletDB` and `Manifest`. Note that the wallet db has nothing to do with account wallets and it stores node configuration, which is why it depends on the manifest code.
2026-02-11 13:42:31 +00:00
Olek
e11f6190b7 fix: Update invariant checks for Permissioned Domains (#6134) 2026-02-10 14:02:53 -05:00
Valentin Balaschenko
db2734cbc9 refactor: Change main thread name to xrpld-main (#6336)
This change builds on the thread-renaming PR (#6212), by renaming the main thread name to reduce ambiguity in performance monitoring tools.
2026-02-06 16:33:42 -05:00
Mayukha Vadari
bf4674f42b refactor: Fix spelling issues in tests (#6199)
This change removes the `src/tests` exception from the `cspell` config and fixes all the issues that arise as a result. No functionality/test change.
2026-02-06 20:30:22 +00:00
Mayukha Vadari
f5208fc850 test: Add file and line location to Env (#6276)
This change uses `std::source_location` to output the file and line location of the call that triggered a failed transaction.
2026-02-06 18:37:01 +00:00
Ayaz Salikhov
2305bc98a4 chore: Remove CODEOWNERS (#6337) 2026-02-06 11:39:23 -05:00
Bart
677758b1cc perf: Remove unnecessary caches (#5439)
This change removes the cache in `DatabaseNodeImp` and simplifies the caching logic in `SHAMapStoreImp`. As NuDB and RocksDB internally already use caches, additional caches in the code are not very valuable or may even be unnecessary, as also confirmed during preliminary performance analyses.
2026-02-06 09:42:35 -05:00
Bart
25d7c2c4ec chore: Restore unity builds (#6328)
In certain cases, such as when modifying headers used by many compilation units, performing a unity build is slower than when performing a regular build with `ccache` enabled. There is also a benefit to a unity build in that it can detect things such as macro redefinitions within the group of files that are compiled together as a unit. This change therefore restores the ability to perform unity builds. However, instead of running every configuration with and without unity enabled, it is now only enabled for a single configuration to maintain lower computational use.

As part of restoring the code, it became clear that currently two configurations have coverage enabled, since the check doesn't focus specifically on Debian Bookworm so it also applies to Debian Trixie. This has been fixed too in this change.
2026-02-06 14:12:45 +00:00
Bart
0a626d95f4 refactor: Update secp256k1 to 0.7.1 (#6331)
The latest secp256k1 release, 0.7.1, contains bug fixes that we may benefit from, see https://github.com/bitcoin-core/secp256k1/blob/master/CHANGELOG.md.
2026-02-05 16:45:57 +00:00
Niq Dudfield
6006c281e2 fix: Increment sequence when accepting new manifests (#6059)
The `ManifestCache::applyManifest` function was returning early without incrementing `seq_`. `OverlayImpl `uses this sequence to identify/invalidate a cached `TMManifests` message, which is exchanged with peers on connection. Depending on network size, startup sequencing, and topology, this can cause syncing issues. This change therefore increments `seq_` when a new manifest is accepted.
2026-02-05 10:40:27 -05:00
Vito Tumas
e79673cf40 fix typo in LendingHelpers unit-test (#6215) 2026-02-05 10:23:44 +00:00
Ayaz Salikhov
7f41012e59 chore: Update secp256k1 and openssl (#6327) 2026-02-04 18:27:10 +00:00
Bart
b449a6ee84 chore: Remove unnecessary script (#6326) 2026-02-04 11:30:16 -05:00
Bart
34ef577604 refactor: Replace include guards by '#pragma once' (#6322)
This change replaces all include guards in the `src/` and `include/` directories by `#pragma once`.
2026-02-04 09:50:21 -05:00
Bart
3a172301ce chore: Remove unity builds (#6300)
Unity builds were intended to speed up builds, by bundling multiple files into compilation units. However, now that ccache is available on all platforms, there is no need for unity builds anymore, as ccache stores compiled individual build objects for reuse. This change therefore removes the ability to make unity builds.
2026-02-03 22:55:22 +00:00
Jingchen
6c1a92fe93 refactor: Add ServiceRegistry to help modularization (#6222)
Currently we're passing the `Application` object around, whereby the `Application` class acts more like a service registry that gives other classes access to other services. In order to allow modularization, we should replace `Application` with a service registry class so that modules depending on `Application` for other services can be moved easily. This change adds the `ServiceRegistry` class.
2026-02-03 19:08:27 +00:00
1276 changed files with 31930 additions and 18500 deletions

View File

@@ -37,7 +37,7 @@ BinPackParameters: false
BreakBeforeBinaryOperators: false BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true BreakConstructorInitializersBeforeComma: true
ColumnLimit: 120 ColumnLimit: 100
CommentPragmas: "^ IWYU pragma:" CommentPragmas: "^ IWYU pragma:"
ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4 ConstructorInitializerIndentWidth: 4

191
.clang-tidy Normal file
View File

@@ -0,0 +1,191 @@
---
Checks: "-*,
bugprone-argument-comment
"
# bugprone-assert-side-effect,
# bugprone-bad-signal-to-kill-thread,
# bugprone-bool-pointer-implicit-conversion,
# bugprone-casting-through-void,
# bugprone-chained-comparison,
# bugprone-compare-pointer-to-member-virtual-function,
# bugprone-copy-constructor-init,
# bugprone-crtp-constructor-accessibility,
# bugprone-dangling-handle,
# bugprone-dynamic-static-initializers,
# bugprone-empty-catch,
# bugprone-fold-init-type,
# bugprone-forward-declaration-namespace,
# bugprone-inaccurate-erase,
# bugprone-inc-dec-in-conditions,
# bugprone-incorrect-enable-if,
# bugprone-incorrect-roundings,
# bugprone-infinite-loop,
# bugprone-integer-division,
# bugprone-lambda-function-name,
# bugprone-macro-parentheses,
# bugprone-macro-repeated-side-effects,
# bugprone-misplaced-operator-in-strlen-in-alloc,
# bugprone-misplaced-pointer-arithmetic-in-alloc,
# bugprone-misplaced-widening-cast,
# bugprone-move-forwarding-reference,
# bugprone-multi-level-implicit-pointer-conversion,
# bugprone-multiple-new-in-one-expression,
# bugprone-multiple-statement-macro,
# bugprone-no-escape,
# bugprone-non-zero-enum-to-bool-conversion,
# bugprone-optional-value-conversion,
# bugprone-parent-virtual-call,
# bugprone-pointer-arithmetic-on-polymorphic-object,
# bugprone-posix-return,
# bugprone-redundant-branch-condition,
# bugprone-reserved-identifier,
# bugprone-return-const-ref-from-parameter,
# bugprone-shared-ptr-array-mismatch,
# bugprone-signal-handler,
# bugprone-signed-char-misuse,
# bugprone-sizeof-container,
# bugprone-sizeof-expression,
# bugprone-spuriously-wake-up-functions,
# bugprone-standalone-empty,
# bugprone-string-constructor,
# bugprone-string-integer-assignment,
# bugprone-string-literal-with-embedded-nul,
# bugprone-stringview-nullptr,
# bugprone-suspicious-enum-usage,
# bugprone-suspicious-include,
# bugprone-suspicious-memory-comparison,
# bugprone-suspicious-memset-usage,
# bugprone-suspicious-missing-comma,
# bugprone-suspicious-realloc-usage,
# bugprone-suspicious-semicolon,
# bugprone-suspicious-string-compare,
# bugprone-suspicious-stringview-data-usage,
# bugprone-swapped-arguments,
# bugprone-switch-missing-default-case,
# bugprone-terminating-continue,
# bugprone-throw-keyword-missing,
# bugprone-too-small-loop-variable,
# bugprone-undefined-memory-manipulation,
# bugprone-undelegated-constructor,
# bugprone-unhandled-exception-at-new,
# bugprone-unhandled-self-assignment,
# bugprone-unique-ptr-array-mismatch,
# bugprone-unsafe-functions,
# bugprone-unused-local-non-trivial-variable,
# bugprone-unused-raii,
# bugprone-unused-return-value,
# bugprone-use-after-move,
# bugprone-virtual-near-miss,
# cppcoreguidelines-init-variables,
# cppcoreguidelines-misleading-capture-default-by-value,
# cppcoreguidelines-no-suspend-with-lock,
# cppcoreguidelines-pro-type-member-init,
# cppcoreguidelines-pro-type-static-cast-downcast,
# cppcoreguidelines-rvalue-reference-param-not-moved,
# cppcoreguidelines-use-default-member-init,
# cppcoreguidelines-virtual-class-destructor,
# hicpp-ignored-remove-result,
# llvm-namespace-comment,
# misc-const-correctness,
# misc-definitions-in-headers,
# misc-header-include-cycle,
# misc-include-cleaner,
# misc-misplaced-const,
# misc-redundant-expression,
# misc-static-assert,
# misc-throw-by-value-catch-by-reference,
# misc-unused-alias-decls,
# misc-unused-using-decls,
# modernize-concat-nested-namespaces,
# modernize-deprecated-headers,
# modernize-make-shared,
# modernize-make-unique,
# modernize-pass-by-value,
# modernize-type-traits,
# modernize-use-designated-initializers,
# modernize-use-emplace,
# modernize-use-equals-default,
# modernize-use-equals-delete,
# modernize-use-override,
# modernize-use-ranges,
# modernize-use-starts-ends-with,
# modernize-use-std-numbers,
# modernize-use-using,
# performance-faster-string-find,
# performance-for-range-copy,
# performance-implicit-conversion-in-loop,
# performance-inefficient-vector-operation,
# performance-move-const-arg,
# performance-move-constructor-init,
# performance-no-automatic-move,
# performance-trivially-destructible,
# readability-avoid-nested-conditional-operator,
# readability-avoid-return-with-void-value,
# readability-braces-around-statements,
# readability-const-return-type,
# readability-container-contains,
# readability-container-size-empty,
# readability-convert-member-functions-to-static,
# readability-duplicate-include,
# readability-else-after-return,
# readability-enum-initial-value,
# readability-implicit-bool-conversion,
# readability-inconsistent-declaration-parameter-name,
# readability-identifier-naming,
# readability-make-member-function-const,
# readability-math-missing-parentheses,
# readability-misleading-indentation,
# readability-non-const-parameter,
# readability-redundant-casting,
# readability-redundant-declaration,
# readability-redundant-inline-specifier,
# readability-redundant-member-init,
# readability-redundant-string-init,
# readability-reference-to-constructed-temporary,
# readability-simplify-boolean-expr,
# readability-static-accessed-through-instance,
# readability-static-definition-in-anonymous-namespace,
# readability-suspicious-call-argument,
# readability-use-std-min-max
#
# CheckOptions:
# readability-braces-around-statements.ShortStatementLines: 2
# readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
# readability-identifier-naming.ClassCase: CamelCase
# readability-identifier-naming.StructCase: CamelCase
# readability-identifier-naming.UnionCase: CamelCase
# readability-identifier-naming.EnumCase: CamelCase
# readability-identifier-naming.EnumConstantCase: CamelCase
# readability-identifier-naming.ScopedEnumConstantCase: CamelCase
# readability-identifier-naming.GlobalConstantCase: UPPER_CASE
# readability-identifier-naming.GlobalConstantPrefix: "k"
# readability-identifier-naming.GlobalVariableCase: CamelCase
# readability-identifier-naming.GlobalVariablePrefix: "g"
# readability-identifier-naming.ConstexprFunctionCase: camelBack
# readability-identifier-naming.ConstexprMethodCase: camelBack
# readability-identifier-naming.ClassMethodCase: camelBack
# readability-identifier-naming.ClassMemberCase: camelBack
# readability-identifier-naming.ClassConstantCase: UPPER_CASE
# readability-identifier-naming.ClassConstantPrefix: "k"
# readability-identifier-naming.StaticConstantCase: UPPER_CASE
# readability-identifier-naming.StaticConstantPrefix: "k"
# readability-identifier-naming.StaticVariableCase: UPPER_CASE
# readability-identifier-naming.StaticVariablePrefix: "k"
# readability-identifier-naming.ConstexprVariableCase: UPPER_CASE
# readability-identifier-naming.ConstexprVariablePrefix: "k"
# readability-identifier-naming.LocalConstantCase: camelBack
# readability-identifier-naming.LocalVariableCase: camelBack
# readability-identifier-naming.TemplateParameterCase: CamelCase
# readability-identifier-naming.ParameterCase: camelBack
# readability-identifier-naming.FunctionCase: camelBack
# readability-identifier-naming.MemberCase: camelBack
# readability-identifier-naming.PrivateMemberSuffix: _
# readability-identifier-naming.ProtectedMemberSuffix: _
# readability-identifier-naming.PublicMemberSuffix: ""
# readability-identifier-naming.FunctionIgnoredRegexp: ".*tag_invoke.*"
# bugprone-unsafe-functions.ReportMoreUnsafeFunctions: true
# bugprone-unused-return-value.CheckedReturnTypes: ::std::error_code;::std::error_condition;::std::errc
# misc-include-cleaner.IgnoreHeaders: '.*/(detail|impl)/.*;.*(expected|unexpected).*;.*ranges_lower_bound\.h;time.h;stdlib.h;__chrono/.*;fmt/chrono.h;boost/uuid/uuid_hash.hpp'
#
# HeaderFilterRegex: '^.*/(src|tests)/.*\.(h|hpp)$'
WarningsAsErrors: "*"

View File

@@ -29,7 +29,7 @@ format:
disable: false disable: false
_help_line_width: _help_line_width:
- How wide to allow formatted cmake files - How wide to allow formatted cmake files
line_width: 120 line_width: 100
_help_tab_size: _help_tab_size:
- How many spaces to tab for indent - How many spaces to tab for indent
tab_size: 4 tab_size: 4

8
.github/CODEOWNERS vendored
View File

@@ -1,8 +0,0 @@
# Allow anyone to review any change by default.
*
# Require the rpc-reviewers team to review changes to the rpc code.
include/xrpl/protocol/ @xrplf/rpc-reviewers
src/libxrpl/protocol/ @xrplf/rpc-reviewers
src/xrpld/rpc/ @xrplf/rpc-reviewers
src/xrpld/app/misc/ @xrplf/rpc-reviewers

56
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,56 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
day: monday
time: "04:00"
timezone: Etc/GMT
commit-message:
prefix: "ci: [DEPENDABOT] "
target-branch: develop
- package-ecosystem: github-actions
directory: .github/actions/build-deps/
schedule:
interval: weekly
day: monday
time: "04:00"
timezone: Etc/GMT
commit-message:
prefix: "ci: [DEPENDABOT] "
target-branch: develop
- package-ecosystem: github-actions
directory: .github/actions/generate-version/
schedule:
interval: weekly
day: monday
time: "04:00"
timezone: Etc/GMT
commit-message:
prefix: "ci: [DEPENDABOT] "
target-branch: develop
- package-ecosystem: github-actions
directory: .github/actions/print-env/
schedule:
interval: weekly
day: monday
time: "04:00"
timezone: Etc/GMT
commit-message:
prefix: "ci: [DEPENDABOT] "
target-branch: develop
- package-ecosystem: github-actions
directory: .github/actions/setup-conan/
schedule:
interval: weekly
day: monday
time: "04:00"
timezone: Etc/GMT
commit-message:
prefix: "ci: [DEPENDABOT] "
target-branch: develop

View File

@@ -4,14 +4,11 @@ Loop: test.jtx test.toplevel
Loop: test.jtx test.unit_test Loop: test.jtx test.unit_test
test.unit_test == test.jtx test.unit_test == test.jtx
Loop: xrpld.app xrpld.core
xrpld.app > xrpld.core
Loop: xrpld.app xrpld.overlay Loop: xrpld.app xrpld.overlay
xrpld.overlay > xrpld.app xrpld.overlay ~= xrpld.app
Loop: xrpld.app xrpld.peerfinder Loop: xrpld.app xrpld.peerfinder
xrpld.peerfinder ~= xrpld.app xrpld.peerfinder == xrpld.app
Loop: xrpld.app xrpld.rpc Loop: xrpld.app xrpld.rpc
xrpld.rpc > xrpld.app xrpld.rpc > xrpld.app

View File

@@ -1,4 +1,6 @@
libxrpl.basics > xrpl.basics libxrpl.basics > xrpl.basics
libxrpl.conditions > xrpl.basics
libxrpl.conditions > xrpl.conditions
libxrpl.core > xrpl.basics libxrpl.core > xrpl.basics
libxrpl.core > xrpl.core libxrpl.core > xrpl.core
libxrpl.crypto > xrpl.basics libxrpl.crypto > xrpl.basics
@@ -17,16 +19,27 @@ libxrpl.nodestore > xrpl.protocol
libxrpl.protocol > xrpl.basics libxrpl.protocol > xrpl.basics
libxrpl.protocol > xrpl.json libxrpl.protocol > xrpl.json
libxrpl.protocol > xrpl.protocol libxrpl.protocol > xrpl.protocol
libxrpl.rdb > xrpl.basics
libxrpl.rdb > xrpl.rdb
libxrpl.resource > xrpl.basics libxrpl.resource > xrpl.basics
libxrpl.resource > xrpl.json libxrpl.resource > xrpl.json
libxrpl.resource > xrpl.resource libxrpl.resource > xrpl.resource
libxrpl.server > xrpl.basics libxrpl.server > xrpl.basics
libxrpl.server > xrpl.json libxrpl.server > xrpl.json
libxrpl.server > xrpl.protocol libxrpl.server > xrpl.protocol
libxrpl.server > xrpl.rdb
libxrpl.server > xrpl.server libxrpl.server > xrpl.server
libxrpl.shamap > xrpl.basics libxrpl.shamap > xrpl.basics
libxrpl.shamap > xrpl.protocol libxrpl.shamap > xrpl.protocol
libxrpl.shamap > xrpl.shamap libxrpl.shamap > xrpl.shamap
libxrpl.tx > xrpl.basics
libxrpl.tx > xrpl.conditions
libxrpl.tx > xrpl.core
libxrpl.tx > xrpl.json
libxrpl.tx > xrpl.ledger
libxrpl.tx > xrpl.protocol
libxrpl.tx > xrpl.server
libxrpl.tx > xrpl.tx
test.app > test.jtx test.app > test.jtx
test.app > test.rpc test.app > test.rpc
test.app > test.toplevel test.app > test.toplevel
@@ -41,7 +54,10 @@ test.app > xrpl.json
test.app > xrpl.ledger test.app > xrpl.ledger
test.app > xrpl.nodestore test.app > xrpl.nodestore
test.app > xrpl.protocol test.app > xrpl.protocol
test.app > xrpl.rdb
test.app > xrpl.resource test.app > xrpl.resource
test.app > xrpl.server
test.app > xrpl.tx
test.basics > test.jtx test.basics > test.jtx
test.basics > test.unit_test test.basics > test.unit_test
test.basics > xrpl.basics test.basics > xrpl.basics
@@ -51,7 +67,7 @@ test.basics > xrpl.json
test.basics > xrpl.protocol test.basics > xrpl.protocol
test.beast > xrpl.basics test.beast > xrpl.basics
test.conditions > xrpl.basics test.conditions > xrpl.basics
test.conditions > xrpld.conditions test.conditions > xrpl.conditions
test.consensus > test.csf test.consensus > test.csf
test.consensus > test.toplevel test.consensus > test.toplevel
test.consensus > test.unit_test test.consensus > test.unit_test
@@ -60,6 +76,7 @@ test.consensus > xrpld.app
test.consensus > xrpld.consensus test.consensus > xrpld.consensus
test.consensus > xrpl.json test.consensus > xrpl.json
test.consensus > xrpl.ledger test.consensus > xrpl.ledger
test.consensus > xrpl.tx
test.core > test.jtx test.core > test.jtx
test.core > test.toplevel test.core > test.toplevel
test.core > test.unit_test test.core > test.unit_test
@@ -67,6 +84,7 @@ test.core > xrpl.basics
test.core > xrpl.core test.core > xrpl.core
test.core > xrpld.core test.core > xrpld.core
test.core > xrpl.json test.core > xrpl.json
test.core > xrpl.rdb
test.core > xrpl.server test.core > xrpl.server
test.csf > xrpl.basics test.csf > xrpl.basics
test.csf > xrpld.consensus test.csf > xrpld.consensus
@@ -75,6 +93,7 @@ test.csf > xrpl.protocol
test.json > test.jtx test.json > test.jtx
test.json > xrpl.json test.json > xrpl.json
test.jtx > xrpl.basics test.jtx > xrpl.basics
test.jtx > xrpl.core
test.jtx > xrpld.app test.jtx > xrpld.app
test.jtx > xrpld.core test.jtx > xrpld.core
test.jtx > xrpld.rpc test.jtx > xrpld.rpc
@@ -84,6 +103,7 @@ test.jtx > xrpl.net
test.jtx > xrpl.protocol test.jtx > xrpl.protocol
test.jtx > xrpl.resource test.jtx > xrpl.resource
test.jtx > xrpl.server test.jtx > xrpl.server
test.jtx > xrpl.tx
test.ledger > test.jtx test.ledger > test.jtx
test.ledger > test.toplevel test.ledger > test.toplevel
test.ledger > xrpl.basics test.ledger > xrpl.basics
@@ -95,8 +115,8 @@ test.nodestore > test.jtx
test.nodestore > test.toplevel test.nodestore > test.toplevel
test.nodestore > test.unit_test test.nodestore > test.unit_test
test.nodestore > xrpl.basics test.nodestore > xrpl.basics
test.nodestore > xrpld.core
test.nodestore > xrpl.nodestore test.nodestore > xrpl.nodestore
test.nodestore > xrpl.rdb
test.overlay > test.jtx test.overlay > test.jtx
test.overlay > test.toplevel test.overlay > test.toplevel
test.overlay > test.unit_test test.overlay > test.unit_test
@@ -129,8 +149,11 @@ test.rpc > xrpld.core
test.rpc > xrpld.overlay test.rpc > xrpld.overlay
test.rpc > xrpld.rpc test.rpc > xrpld.rpc
test.rpc > xrpl.json test.rpc > xrpl.json
test.rpc > xrpl.ledger
test.rpc > xrpl.protocol test.rpc > xrpl.protocol
test.rpc > xrpl.resource test.rpc > xrpl.resource
test.rpc > xrpl.server
test.rpc > xrpl.tx
test.server > test.jtx test.server > test.jtx
test.server > test.toplevel test.server > test.toplevel
test.server > test.unit_test test.server > test.unit_test
@@ -151,39 +174,57 @@ test.unit_test > xrpl.basics
tests.libxrpl > xrpl.basics tests.libxrpl > xrpl.basics
tests.libxrpl > xrpl.json tests.libxrpl > xrpl.json
tests.libxrpl > xrpl.net tests.libxrpl > xrpl.net
xrpl.conditions > xrpl.basics
xrpl.conditions > xrpl.protocol
xrpl.core > xrpl.basics xrpl.core > xrpl.basics
xrpl.core > xrpl.json xrpl.core > xrpl.json
xrpl.core > xrpl.ledger
xrpl.core > xrpl.protocol
xrpl.json > xrpl.basics xrpl.json > xrpl.basics
xrpl.ledger > xrpl.basics xrpl.ledger > xrpl.basics
xrpl.ledger > xrpl.protocol xrpl.ledger > xrpl.protocol
xrpl.ledger > xrpl.server
xrpl.ledger > xrpl.shamap
xrpl.net > xrpl.basics xrpl.net > xrpl.basics
xrpl.nodestore > xrpl.basics xrpl.nodestore > xrpl.basics
xrpl.nodestore > xrpl.protocol xrpl.nodestore > xrpl.protocol
xrpl.protocol > xrpl.basics xrpl.protocol > xrpl.basics
xrpl.protocol > xrpl.json xrpl.protocol > xrpl.json
xrpl.rdb > xrpl.basics
xrpl.rdb > xrpl.core
xrpl.rdb > xrpl.protocol
xrpl.resource > xrpl.basics xrpl.resource > xrpl.basics
xrpl.resource > xrpl.json xrpl.resource > xrpl.json
xrpl.resource > xrpl.protocol xrpl.resource > xrpl.protocol
xrpl.server > xrpl.basics xrpl.server > xrpl.basics
xrpl.server > xrpl.core
xrpl.server > xrpl.json xrpl.server > xrpl.json
xrpl.server > xrpl.protocol xrpl.server > xrpl.protocol
xrpl.server > xrpl.rdb
xrpl.server > xrpl.resource
xrpl.server > xrpl.shamap
xrpl.shamap > xrpl.basics xrpl.shamap > xrpl.basics
xrpl.shamap > xrpl.nodestore xrpl.shamap > xrpl.nodestore
xrpl.shamap > xrpl.protocol xrpl.shamap > xrpl.protocol
xrpl.tx > xrpl.basics
xrpl.tx > xrpl.core
xrpl.tx > xrpl.ledger
xrpl.tx > xrpl.protocol
xrpld.app > test.unit_test xrpld.app > test.unit_test
xrpld.app > xrpl.basics xrpld.app > xrpl.basics
xrpld.app > xrpl.core xrpld.app > xrpl.core
xrpld.app > xrpld.conditions
xrpld.app > xrpld.consensus xrpld.app > xrpld.consensus
xrpld.app > xrpld.core
xrpld.app > xrpl.json xrpld.app > xrpl.json
xrpld.app > xrpl.ledger xrpld.app > xrpl.ledger
xrpld.app > xrpl.net xrpld.app > xrpl.net
xrpld.app > xrpl.nodestore xrpld.app > xrpl.nodestore
xrpld.app > xrpl.protocol xrpld.app > xrpl.protocol
xrpld.app > xrpl.rdb
xrpld.app > xrpl.resource xrpld.app > xrpl.resource
xrpld.app > xrpl.server
xrpld.app > xrpl.shamap xrpld.app > xrpl.shamap
xrpld.conditions > xrpl.basics xrpld.app > xrpl.tx
xrpld.conditions > xrpl.protocol
xrpld.consensus > xrpl.basics xrpld.consensus > xrpl.basics
xrpld.consensus > xrpl.json xrpld.consensus > xrpl.json
xrpld.consensus > xrpl.protocol xrpld.consensus > xrpl.protocol
@@ -192,17 +233,21 @@ xrpld.core > xrpl.core
xrpld.core > xrpl.json xrpld.core > xrpl.json
xrpld.core > xrpl.net xrpld.core > xrpl.net
xrpld.core > xrpl.protocol xrpld.core > xrpl.protocol
xrpld.core > xrpl.rdb
xrpld.overlay > xrpl.basics xrpld.overlay > xrpl.basics
xrpld.overlay > xrpl.core xrpld.overlay > xrpl.core
xrpld.overlay > xrpld.core xrpld.overlay > xrpld.core
xrpld.overlay > xrpld.peerfinder xrpld.overlay > xrpld.peerfinder
xrpld.overlay > xrpl.json xrpld.overlay > xrpl.json
xrpld.overlay > xrpl.protocol xrpld.overlay > xrpl.protocol
xrpld.overlay > xrpl.rdb
xrpld.overlay > xrpl.resource xrpld.overlay > xrpl.resource
xrpld.overlay > xrpl.server xrpld.overlay > xrpl.server
xrpld.overlay > xrpl.tx
xrpld.peerfinder > xrpl.basics xrpld.peerfinder > xrpl.basics
xrpld.peerfinder > xrpld.core xrpld.peerfinder > xrpld.core
xrpld.peerfinder > xrpl.protocol xrpld.peerfinder > xrpl.protocol
xrpld.peerfinder > xrpl.rdb
xrpld.perflog > xrpl.basics xrpld.perflog > xrpl.basics
xrpld.perflog > xrpl.core xrpld.perflog > xrpl.core
xrpld.perflog > xrpld.rpc xrpld.perflog > xrpld.rpc
@@ -215,6 +260,8 @@ xrpld.rpc > xrpl.ledger
xrpld.rpc > xrpl.net xrpld.rpc > xrpl.net
xrpld.rpc > xrpl.nodestore xrpld.rpc > xrpl.nodestore
xrpld.rpc > xrpl.protocol xrpld.rpc > xrpl.protocol
xrpld.rpc > xrpl.rdb
xrpld.rpc > xrpl.resource xrpld.rpc > xrpl.resource
xrpld.rpc > xrpl.server xrpld.rpc > xrpl.server
xrpld.rpc > xrpl.tx
xrpld.shamap > xrpl.shamap xrpld.shamap > xrpl.shamap

30
.github/scripts/rename/include.sh vendored Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Exit the script as soon as an error occurs.
set -e
# This script checks whether there are no new include guards introduced by a new
# PR, as header files should use "#pragma once" instead. The script assumes any
# include guards will use "XRPL_" as prefix.
# Usage: .github/scripts/rename/include.sh <repository directory>
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <repository directory>"
exit 1
fi
DIRECTORY=$1
echo "Processing directory: ${DIRECTORY}"
if [ ! -d "${DIRECTORY}" ]; then
echo "Error: Directory '${DIRECTORY}' does not exist."
exit 1
fi
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" \) | while read -r FILE; do
echo "Processing file: ${FILE}"
if grep -q "#ifndef XRPL_" "${FILE}"; then
echo "Please replace all include guards by #pragma once."
exit 1
fi
done
echo "Checking complete."

View File

@@ -51,22 +51,20 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
# Only generate a subset of configurations in PRs. # Only generate a subset of configurations in PRs.
if not all: if not all:
# Debian: # Debian:
# - Bookworm using GCC 13: Release and Unity on linux/amd64, set # - Bookworm using GCC 13: Release on linux/amd64, set the reference
# the reference fee to 500. # fee to 500.
# - Bookworm using GCC 15: Debug and no Unity on linux/amd64, enable # - Bookworm using GCC 15: Debug on linux/amd64, enable code
# code coverage (which will be done below). # coverage (which will be done below).
# - Bookworm using Clang 16: Debug and no Unity on linux/arm64, # - Bookworm using Clang 16: Debug on linux/arm64, enable voidstar.
# enable voidstar. # - Bookworm using Clang 17: Release on linux/amd64, set the
# - Bookworm using Clang 17: Release and no Unity on linux/amd64, # reference fee to 1000.
# set the reference fee to 1000. # - Bookworm using Clang 20: Debug on linux/amd64.
# - Bookworm using Clang 20: Debug and Unity on linux/amd64.
if os["distro_name"] == "debian": if os["distro_name"] == "debian":
skip = True skip = True
if os["distro_version"] == "bookworm": if os["distro_version"] == "bookworm":
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-13" f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-13"
and build_type == "Release" and build_type == "Release"
and "-Dunity=ON" in cmake_args
and architecture["platform"] == "linux/amd64" and architecture["platform"] == "linux/amd64"
): ):
cmake_args = f"-DUNIT_TEST_REFERENCE_FEE=500 {cmake_args}" cmake_args = f"-DUNIT_TEST_REFERENCE_FEE=500 {cmake_args}"
@@ -74,14 +72,12 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-15" f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-15"
and build_type == "Debug" and build_type == "Debug"
and "-Dunity=OFF" in cmake_args
and architecture["platform"] == "linux/amd64" and architecture["platform"] == "linux/amd64"
): ):
skip = False skip = False
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "clang-16" f"{os['compiler_name']}-{os['compiler_version']}" == "clang-16"
and build_type == "Debug" and build_type == "Debug"
and "-Dunity=OFF" in cmake_args
and architecture["platform"] == "linux/arm64" and architecture["platform"] == "linux/arm64"
): ):
cmake_args = f"-Dvoidstar=ON {cmake_args}" cmake_args = f"-Dvoidstar=ON {cmake_args}"
@@ -89,7 +85,6 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "clang-17" f"{os['compiler_name']}-{os['compiler_version']}" == "clang-17"
and build_type == "Release" and build_type == "Release"
and "-Dunity=ON" in cmake_args
and architecture["platform"] == "linux/amd64" and architecture["platform"] == "linux/amd64"
): ):
cmake_args = f"-DUNIT_TEST_REFERENCE_FEE=1000 {cmake_args}" cmake_args = f"-DUNIT_TEST_REFERENCE_FEE=1000 {cmake_args}"
@@ -97,7 +92,6 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "clang-20" f"{os['compiler_name']}-{os['compiler_version']}" == "clang-20"
and build_type == "Debug" and build_type == "Debug"
and "-Dunity=ON" in cmake_args
and architecture["platform"] == "linux/amd64" and architecture["platform"] == "linux/amd64"
): ):
skip = False skip = False
@@ -105,15 +99,14 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
continue continue
# RHEL: # RHEL:
# - 9 using GCC 12: Debug and Unity on linux/amd64. # - 9 using GCC 12: Debug on linux/amd64.
# - 10 using Clang: Release and no Unity 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 == "Debug"
and "-Dunity=ON" in cmake_args
and architecture["platform"] == "linux/amd64" and architecture["platform"] == "linux/amd64"
): ):
skip = False skip = False
@@ -121,7 +114,6 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "clang-any" f"{os['compiler_name']}-{os['compiler_version']}" == "clang-any"
and build_type == "Release" and build_type == "Release"
and "-Dunity=OFF" in cmake_args
and architecture["platform"] == "linux/amd64" and architecture["platform"] == "linux/amd64"
): ):
skip = False skip = False
@@ -129,17 +121,16 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
continue continue
# Ubuntu: # Ubuntu:
# - Jammy using GCC 12: Debug and no Unity on linux/arm64. # - Jammy using GCC 12: Debug on linux/arm64.
# - Noble using GCC 14: Release and Unity on linux/amd64. # - Noble using GCC 14: Release on linux/amd64.
# - Noble using Clang 18: Debug and no Unity on linux/amd64. # - Noble using Clang 18: Debug on linux/amd64.
# - Noble using Clang 19: Release and Unity on linux/arm64. # - Noble using Clang 19: Release on linux/arm64.
if os["distro_name"] == "ubuntu": if os["distro_name"] == "ubuntu":
skip = True skip = True
if os["distro_version"] == "jammy": if os["distro_version"] == "jammy":
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 == "Debug"
and "-Dunity=OFF" in cmake_args
and architecture["platform"] == "linux/arm64" and architecture["platform"] == "linux/arm64"
): ):
skip = False skip = False
@@ -147,21 +138,18 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-14" f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-14"
and build_type == "Release" and build_type == "Release"
and "-Dunity=ON" in cmake_args
and architecture["platform"] == "linux/amd64" and architecture["platform"] == "linux/amd64"
): ):
skip = False skip = False
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "clang-18" f"{os['compiler_name']}-{os['compiler_version']}" == "clang-18"
and build_type == "Debug" and build_type == "Debug"
and "-Dunity=OFF" in cmake_args
and architecture["platform"] == "linux/amd64" and architecture["platform"] == "linux/amd64"
): ):
skip = False skip = False
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "clang-19" f"{os['compiler_name']}-{os['compiler_version']}" == "clang-19"
and build_type == "Release" and build_type == "Release"
and "-Dunity=ON" in cmake_args
and architecture["platform"] == "linux/arm64" and architecture["platform"] == "linux/arm64"
): ):
skip = False skip = False
@@ -169,20 +157,16 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
continue continue
# MacOS: # MacOS:
# - Debug and no Unity on macos/arm64. # - Debug on macos/arm64.
if os["distro_name"] == "macos" and not ( if os["distro_name"] == "macos" and not (
build_type == "Debug" build_type == "Debug" and architecture["platform"] == "macos/arm64"
and "-Dunity=OFF" in cmake_args
and architecture["platform"] == "macos/arm64"
): ):
continue continue
# Windows: # Windows:
# - Release and Unity on windows/amd64. # - Release on windows/amd64.
if os["distro_name"] == "windows" and not ( if os["distro_name"] == "windows" and not (
build_type == "Release" build_type == "Release" and architecture["platform"] == "windows/amd64"
and "-Dunity=ON" in cmake_args
and architecture["platform"] == "windows/amd64"
): ):
continue continue
@@ -209,18 +193,28 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
): ):
continue continue
# Enable code coverage for Debian Bookworm using GCC 15 in Debug and no # Enable code coverage for Debian Bookworm using GCC 15 in Debug on
# Unity on linux/amd64 # linux/amd64
if ( if (
f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-15" f"{os['distro_name']}-{os['distro_version']}" == "debian-bookworm"
and f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-15"
and build_type == "Debug" and build_type == "Debug"
and "-Dunity=OFF" in cmake_args
and architecture["platform"] == "linux/amd64" and architecture["platform"] == "linux/amd64"
): ):
cmake_args = f"-Dcoverage=ON -Dcoverage_format=xml -DCODE_COVERAGE_VERBOSE=ON -DCMAKE_C_FLAGS=-O0 -DCMAKE_CXX_FLAGS=-O0 {cmake_args}" cmake_args = f"{cmake_args} -Dcoverage=ON -Dcoverage_format=xml -DCODE_COVERAGE_VERBOSE=ON -DCMAKE_C_FLAGS=-O0 -DCMAKE_CXX_FLAGS=-O0"
# Enable unity build for Ubuntu Jammy using GCC 12 in Debug on
# linux/amd64.
if (
f"{os['distro_name']}-{os['distro_version']}" == "ubuntu-jammy"
and f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-12"
and build_type == "Debug"
and architecture["platform"] == "linux/amd64"
):
cmake_args = f"{cmake_args} -Dunity=ON"
# 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-unity. # or debian-bookworm-gcc-12-amd64-release.
config_name = os["distro_name"] config_name = os["distro_name"]
if (n := os["distro_version"]) != "": if (n := os["distro_version"]) != "":
config_name += f"-{n}" config_name += f"-{n}"

View File

@@ -208,5 +208,5 @@
} }
], ],
"build_type": ["Debug", "Release"], "build_type": ["Debug", "Release"],
"cmake_args": ["-Dunity=OFF", "-Dunity=ON"] "cmake_args": [""]
} }

View File

@@ -15,8 +15,5 @@
} }
], ],
"build_type": ["Debug", "Release"], "build_type": ["Debug", "Release"],
"cmake_args": [ "cmake_args": ["-DCMAKE_POLICY_VERSION_MINIMUM=3.5"]
"-Dunity=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5",
"-Dunity=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5"
]
} }

View File

@@ -15,5 +15,5 @@
} }
], ],
"build_type": ["Debug", "Release"], "build_type": ["Debug", "Release"],
"cmake_args": ["-Dunity=OFF", "-Dunity=ON"] "cmake_args": [""]
} }

View File

@@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Determine changed files - name: Determine changed files
# This step checks whether any files have changed that should # This step checks whether any files have changed that should
# cause the next jobs to run. We do it this way rather than # cause the next jobs to run. We do it this way rather than
@@ -46,7 +46,7 @@ jobs:
# that Github considers any skipped jobs to have passed, and in # that Github considers any skipped jobs to have passed, and in
# turn the required checks as well. # turn the required checks as well.
id: changes id: changes
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 uses: tj-actions/changed-files@7dee1b0c1557f278e5c7dc244927139d78c0e22a # v47.0.4
with: with:
files: | files: |
# These paths are unique to `on-pr.yml`. # These paths are unique to `on-pr.yml`.
@@ -65,9 +65,12 @@ jobs:
.github/workflows/reusable-build.yml .github/workflows/reusable-build.yml
.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-files.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
.codecov.yml .codecov.yml
cmake/** cmake/**
conan/** conan/**
@@ -107,6 +110,17 @@ jobs:
if: ${{ needs.should-run.outputs.go == 'true' }} if: ${{ needs.should-run.outputs.go == 'true' }}
uses: ./.github/workflows/reusable-check-rename.yml uses: ./.github/workflows/reusable-check-rename.yml
clang-tidy:
needs: should-run
if: ${{ needs.should-run.outputs.go == 'true' }}
uses: ./.github/workflows/reusable-clang-tidy.yml
permissions:
issues: write
contents: read
with:
check_only_changed: true
create_issue_on_failure: false
build-test: build-test:
needs: should-run needs: should-run
if: ${{ needs.should-run.outputs.go == 'true' }} if: ${{ needs.should-run.outputs.go == 'true' }}
@@ -156,6 +170,7 @@ jobs:
needs: needs:
- check-levelization - check-levelization
- check-rename - check-rename
- clang-tidy
- build-test - build-test
- upload-recipe - upload-recipe
- notify-clio - notify-clio

View File

@@ -22,9 +22,12 @@ on:
- ".github/workflows/reusable-build.yml" - ".github/workflows/reusable-build.yml"
- ".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-files.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"
- ".codecov.yml" - ".codecov.yml"
- "cmake/**" - "cmake/**"
- "conan/**" - "conan/**"
@@ -60,6 +63,15 @@ defaults:
shell: bash shell: bash
jobs: jobs:
clang-tidy:
uses: ./.github/workflows/reusable-clang-tidy.yml
permissions:
issues: write
contents: read
with:
check_only_changed: false
create_issue_on_failure: ${{ github.event_name == 'schedule' }}
build-test: build-test:
uses: ./.github/workflows/reusable-build-test.yml uses: ./.github/workflows/reusable-build-test.yml
strategy: strategy:

View File

@@ -4,6 +4,18 @@ name: Build and publish documentation
on: on:
push: push:
branches:
- "develop"
- "release*"
paths:
- ".github/workflows/publish-docs.yml"
- "*.md"
- "**/*.md"
- "docs/**"
- "include/**"
- "src/libxrpl/**"
- "src/xrpld/**"
pull_request:
paths: paths:
- ".github/workflows/publish-docs.yml" - ".github/workflows/publish-docs.yml"
- "*.md" - "*.md"
@@ -23,7 +35,9 @@ defaults:
env: env:
BUILD_DIR: build BUILD_DIR: build
NPROC_SUBTRACT: 2 # ubuntu-latest has only 2 CPUs for private repositories
# https://docs.github.com/en/actions/reference/runners/github-hosted-runners#standard-github-hosted-runners-for--private-repositories
NPROC_SUBTRACT: ${{ github.event.repository.private && '1' || '2' }}
jobs: jobs:
publish: publish:
@@ -33,7 +47,7 @@ jobs:
contents: write contents: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get number of processors - name: Get number of processors
uses: XRPLF/actions/get-nproc@cf0433aa74563aead044a1e395610c96d65a37cf uses: XRPLF/actions/get-nproc@cf0433aa74563aead044a1e395610c96d65a37cf
@@ -65,7 +79,7 @@ jobs:
cmake --build . --target docs --parallel ${BUILD_NPROC} cmake --build . --target docs --parallel ${BUILD_NPROC}
- name: Publish documentation - name: Publish documentation
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }} if: ${{ github.event_name == 'push' }}
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -104,7 +104,7 @@ jobs:
uses: XRPLF/actions/cleanup-workspace@cf0433aa74563aead044a1e395610c96d65a37cf uses: XRPLF/actions/cleanup-workspace@cf0433aa74563aead044a1e395610c96d65a37cf
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Prepare runner - name: Prepare runner
uses: XRPLF/actions/prepare-runner@2cbf481018d930656e9276fcc20dc0e3a0be5b6d uses: XRPLF/actions/prepare-runner@2cbf481018d930656e9276fcc20dc0e3a0be5b6d
@@ -177,7 +177,7 @@ jobs:
- name: Upload the binary (Linux) - name: Upload the binary (Linux)
if: ${{ github.repository_owner == 'XRPLF' && runner.os == 'Linux' }} if: ${{ github.repository_owner == 'XRPLF' && runner.os == 'Linux' }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with: with:
name: xrpld-${{ inputs.config_name }} name: xrpld-${{ inputs.config_name }}
path: ${{ env.BUILD_DIR }}/xrpld path: ${{ env.BUILD_DIR }}/xrpld
@@ -254,7 +254,7 @@ jobs:
- name: Upload coverage report - name: Upload coverage report
if: ${{ github.repository_owner == 'XRPLF' && !inputs.build_only && env.COVERAGE_ENABLED == 'true' }} if: ${{ github.repository_owner == 'XRPLF' && !inputs.build_only && env.COVERAGE_ENABLED == 'true' }}
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3 uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with: with:
disable_search: true disable_search: true
disable_telem: true disable_telem: true

View File

@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check levelization - name: Check levelization
run: .github/scripts/levelization/generate.sh run: .github/scripts/levelization/generate.sh
- name: Check for differences - name: Check for differences

View File

@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check definitions - name: Check definitions
run: .github/scripts/rename/definitions.sh . run: .github/scripts/rename/definitions.sh .
- name: Check copyright notices - name: Check copyright notices
@@ -31,6 +31,8 @@ jobs:
run: .github/scripts/rename/namespace.sh . run: .github/scripts/rename/namespace.sh .
- name: Check config name - name: Check config name
run: .github/scripts/rename/config.sh . run: .github/scripts/rename/config.sh .
- name: Check include guards
run: .github/scripts/rename/include.sh .
- name: Check for differences - name: Check for differences
env: env:
MESSAGE: | MESSAGE: |

View File

@@ -0,0 +1,162 @@
name: Run clang-tidy on files
on:
workflow_call:
inputs:
files:
description: "List of files to check (empty means check all files)"
type: string
default: ""
create_issue_on_failure:
description: "Whether to create an issue if the check failed"
type: boolean
default: false
defaults:
run:
shell: bash
env:
# Conan installs the generators in the build/generators directory, see the
# layout() method in conanfile.py. We then run CMake from the build directory.
BUILD_DIR: build
BUILD_TYPE: Release
jobs:
run-clang-tidy:
name: Run clang tidy
runs-on: ["self-hosted", "Linux", "X64", "heavy"]
container: "ghcr.io/xrplf/ci/debian-trixie:clang-21-sha-53033a2"
permissions:
issues: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Prepare runner
uses: XRPLF/actions/prepare-runner@2cbf481018d930656e9276fcc20dc0e3a0be5b6d
with:
enable_ccache: false
- name: Print build environment
uses: ./.github/actions/print-env
- name: Get number of processors
uses: XRPLF/actions/get-nproc@cf0433aa74563aead044a1e395610c96d65a37cf
id: nproc
- name: Setup Conan
uses: ./.github/actions/setup-conan
- name: Build dependencies
uses: ./.github/actions/build-deps
with:
build_nproc: ${{ steps.nproc.outputs.nproc }}
build_type: ${{ env.BUILD_TYPE }}
log_verbosity: verbose
- name: Configure CMake
working-directory: ${{ env.BUILD_DIR }}
run: |
cmake \
-G 'Ninja' \
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-Dtests=ON \
-Dwerr=ON \
-Dxrpld=ON \
..
# clang-tidy needs headers generated from proto files
- name: Build libxrpl.libpb
working-directory: ${{ env.BUILD_DIR }}
run: |
ninja -j ${{ steps.nproc.outputs.nproc }} xrpl.libpb
- name: Run clang tidy
id: run_clang_tidy
continue-on-error: true
env:
FILES: ${{ inputs.files }}
run: |
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "$BUILD_DIR" $FILES 2>&1 | tee clang-tidy-output.txt
- name: Upload clang-tidy output
if: steps.run_clang_tidy.outcome != 'success'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: clang-tidy-results
path: clang-tidy-output.txt
retention-days: 30
- name: Create an issue
if: steps.run_clang_tidy.outcome != 'success' && inputs.create_issue_on_failure
id: create_issue
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
# Prepare issue body with clang-tidy output
cat > issue.md <<EOF
## Clang-tidy Check Failed
**Workflow:** ${{ github.workflow }}
**Run ID:** ${{ github.run_id }}
**Commit:** ${{ github.sha }}
**Branch/Ref:** ${{ github.ref }}
**Triggered by:** ${{ github.actor }}
### Clang-tidy Output:
\`\`\`
EOF
# Append clang-tidy output (filter for errors and warnings)
if [ -f clang-tidy-output.txt ]; then
# Extract lines containing 'error:', 'warning:', or 'note:'
grep -E '(error:|warning:|note:)' clang-tidy-output.txt > filtered-output.txt || true
# If filtered output is empty, use original (might be a different error format)
if [ ! -s filtered-output.txt ]; then
cp clang-tidy-output.txt filtered-output.txt
fi
# Truncate if too large
head -c 60000 filtered-output.txt >> issue.md
if [ "$(wc -c < filtered-output.txt)" -gt 60000 ]; then
echo "" >> issue.md
echo "... (output truncated, see artifacts for full output)" >> issue.md
fi
rm filtered-output.txt
else
echo "No output file found" >> issue.md
fi
cat >> issue.md <<EOF
\`\`\`
**Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
---
*This issue was automatically created by the clang-tidy workflow.*
EOF
# Create the issue
gh issue create \
--label "Bug,Clang-tidy" \
--title "Clang-tidy check failed" \
--body-file ./issue.md \
> create_issue.log
created_issue="$(sed 's|.*/||' create_issue.log)"
echo "created_issue=$created_issue" >> $GITHUB_OUTPUT
echo "Created issue #$created_issue"
rm -f create_issue.log issue.md clang-tidy-output.txt
- name: Fail the workflow if clang-tidy failed
if: steps.run_clang_tidy.outcome != 'success'
run: |
echo "Clang-tidy check failed!"
exit 1

View File

@@ -0,0 +1,47 @@
name: Clang-tidy check
on:
workflow_call:
inputs:
check_only_changed:
description: "Check only changed files in PR. If false, checks all files in the repository."
type: boolean
default: false
create_issue_on_failure:
description: "Whether to create an issue if the check failed"
type: boolean
default: false
defaults:
run:
shell: bash
jobs:
determine-files:
name: Determine files to check
if: ${{ inputs.check_only_changed }}
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.changed_files.outputs.any_changed }}
all_changed_files: ${{ steps.changed_files.outputs.all_changed_files }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get changed C++ files
id: changed_files
uses: tj-actions/changed-files@7dee1b0c1557f278e5c7dc244927139d78c0e22a # v47.0.4
with:
files: |
**/*.cpp
**/*.h
**/*.ipp
separator: " "
run-clang-tidy:
needs: [determine-files]
if: ${{ always() && !cancelled() && (!inputs.check_only_changed || needs.determine-files.outputs.any_changed == 'true') }}
uses: ./.github/workflows/reusable-clang-tidy-files.yml
with:
files: ${{ inputs.check_only_changed && needs.determine-files.outputs.all_changed_files || '' }}
create_issue_on_failure: ${{ inputs.create_issue_on_failure }}

View File

@@ -29,10 +29,10 @@ jobs:
matrix: ${{ steps.generate.outputs.matrix }} matrix: ${{ steps.generate.outputs.matrix }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python - name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with: with:
python-version: 3.13 python-version: 3.13

View File

@@ -43,7 +43,7 @@ jobs:
container: ghcr.io/xrplf/ci/ubuntu-noble:gcc-13-sha-5dd7158 container: ghcr.io/xrplf/ci/ubuntu-noble:gcc-13-sha-5dd7158
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Generate build version number - name: Generate build version number
id: version id: version

View File

@@ -67,7 +67,7 @@ jobs:
uses: XRPLF/actions/cleanup-workspace@cf0433aa74563aead044a1e395610c96d65a37cf uses: XRPLF/actions/cleanup-workspace@cf0433aa74563aead044a1e395610c96d65a37cf
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Prepare runner - name: Prepare runner
uses: XRPLF/actions/prepare-runner@2cbf481018d930656e9276fcc20dc0e3a0be5b6d uses: XRPLF/actions/prepare-runner@2cbf481018d930656e9276fcc20dc0e3a0be5b6d

3
.gitignore vendored
View File

@@ -71,3 +71,6 @@ DerivedData
/.augment /.augment
/.claude /.claude
/CLAUDE.md /CLAUDE.md
# clangd cache
/.cache

View File

@@ -20,7 +20,7 @@ repos:
args: [--assume-in-merge] args: [--assume-in-merge]
- repo: https://github.com/pre-commit/mirrors-clang-format - repo: https://github.com/pre-commit/mirrors-clang-format
rev: 7d85583be209cb547946c82fbe51f4bc5dd1d017 # frozen: v18.1.8 rev: 75ca4ad908dc4a99f57921f29b7e6c1521e10b26 # frozen: v21.1.8
hooks: hooks:
- id: clang-format - id: clang-format
args: [--style=file] args: [--style=file]

View File

@@ -368,6 +368,36 @@ The workaround for this error is to add two lines to your profile:
tools.build:cxxflags=['-DBOOST_ASIO_DISABLE_CONCEPTS'] tools.build:cxxflags=['-DBOOST_ASIO_DISABLE_CONCEPTS']
``` ```
### Set Up Ccache
To speed up repeated compilations, we recommend that you install
[ccache](https://ccache.dev), a tool that wraps your compiler so that it can
cache build objects locally.
#### Linux
You can install it using the package manager, e.g. `sudo apt install ccache`
(Ubuntu) or `sudo dnf install ccache` (RHEL).
#### macOS
You can install it using Homebrew, i.e. `brew install ccache`.
#### Windows
You can install it using Chocolatey, i.e. `choco install ccache`. If you already
have Ccache installed, then `choco upgrade ccache` will update it to the latest
version. However, if you see an error such as:
```
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(617,5): error MSB6006: "cl.exe" exited with code 3.
```
then please install a specific version of Ccache that we know works, via: `choco
install ccache --version 4.11.3 --allow-downgrade`.
### Build and Test ### Build and Test
1. Create a build directory and move into it. 1. Create a build directory and move into it.
@@ -550,10 +580,10 @@ See [Sanitizers docs](./docs/build/sanitizers.md) for more details.
| `werr` | OFF | Treat compilation warnings as errors | | `werr` | OFF | Treat compilation warnings as errors |
| `wextra` | OFF | Enable additional compilation warnings | | `wextra` | OFF | Enable additional compilation warnings |
[Unity builds][5] may be faster for the first build [Unity builds][5] may be faster for the first build (at the cost of much more
(at the cost of much more memory) since they concatenate sources into fewer memory) since they concatenate sources into fewer translation units. Non-unity
translation units. Non-unity builds may be faster for incremental builds, builds may be faster for incremental builds, and can be helpful for detecting
and can be helpful for detecting `#include` omissions. `#include` omissions.
## Troubleshooting ## Troubleshooting

View File

@@ -17,6 +17,7 @@ project(xrpl)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(CompilationEnv) include(CompilationEnv)
@@ -38,16 +39,16 @@ include(Ccache)
# make GIT_COMMIT_HASH define available to all sources # make GIT_COMMIT_HASH define available to all sources
find_package(Git) find_package(Git)
if (Git_FOUND) if (Git_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git rev-parse HEAD execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git rev-parse
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE gch) HEAD OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE gch)
if (gch) if (gch)
set(GIT_COMMIT_HASH "${gch}") set(GIT_COMMIT_HASH "${gch}")
message(STATUS gch: ${GIT_COMMIT_HASH}) message(STATUS gch: ${GIT_COMMIT_HASH})
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}") add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
endif () endif ()
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git rev-parse --abbrev-ref HEAD execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git rev-parse
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE gb) --abbrev-ref HEAD OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE gb)
if (gb) if (gb)
set(GIT_BRANCH "${gb}") set(GIT_BRANCH "${gb}")
message(STATUS gb: ${GIT_BRANCH}) message(STATUS gb: ${GIT_BRANCH})
@@ -67,7 +68,8 @@ include(FetchContent)
include(ExternalProject) include(ExternalProject)
include(CMakeFuncs) # must come *after* ExternalProject b/c it overrides one function in EP include(CMakeFuncs) # must come *after* ExternalProject b/c it overrides one function in EP
if (target) if (target)
message(FATAL_ERROR "The target option has been removed - use native cmake options to control build") message(FATAL_ERROR "The target option has been removed - use native cmake options to control build"
)
endif () endif ()
include(XrplSanity) include(XrplSanity)
@@ -76,7 +78,8 @@ include(XrplSettings)
# this check has to remain in the top-level cmake because of the early return statement # this check has to remain in the top-level cmake because of the early return statement
if (packages_only) if (packages_only)
if (NOT TARGET rpm) if (NOT TARGET rpm)
message(FATAL_ERROR "packages_only requested, but targets were not created - is docker installed?") message(FATAL_ERROR "packages_only requested, but targets were not created - is docker installed?"
)
endif () endif ()
return() return()
endif () endif ()
@@ -118,7 +121,8 @@ target_link_libraries(
option(rocksdb "Enable RocksDB" ON) option(rocksdb "Enable RocksDB" ON)
if (rocksdb) if (rocksdb)
find_package(RocksDB REQUIRED) find_package(RocksDB REQUIRED)
set_target_properties(RocksDB::rocksdb PROPERTIES INTERFACE_COMPILE_DEFINITIONS XRPL_ROCKSDB_AVAILABLE=1) set_target_properties(RocksDB::rocksdb PROPERTIES INTERFACE_COMPILE_DEFINITIONS
XRPL_ROCKSDB_AVAILABLE=1)
target_link_libraries(xrpl_libs INTERFACE RocksDB::rocksdb) target_link_libraries(xrpl_libs INTERFACE RocksDB::rocksdb)
endif () endif ()

View File

@@ -219,7 +219,7 @@ coherent rather than a set of _thou shalt not_ commandments.
## Formatting ## Formatting
All code must conform to `clang-format` version 18, All code must conform to `clang-format` version 21,
according to the settings in [`.clang-format`](./.clang-format), according to the settings in [`.clang-format`](./.clang-format),
unless the result would be unreasonably difficult to read or maintain. unless the result would be unreasonably difficult to read or maintain.
To demarcate lines that should be left as-is, surround them with comments like To demarcate lines that should be left as-is, surround them with comments like

View File

@@ -940,23 +940,7 @@
# #
# path Location to store the database # path Location to store the database
# #
# Optional keys # Optional keys for NuDB and RocksDB:
#
# cache_size Size of cache for database records. Default is 16384.
# Setting this value to 0 will use the default value.
#
# cache_age Length of time in minutes to keep database records
# cached. Default is 5 minutes. Setting this value to
# 0 will use the default value.
#
# Note: if neither cache_size nor cache_age is
# specified, the cache for database records will not
# be created. If only one of cache_size or cache_age
# is specified, the cache will be created using the
# default value for the unspecified parameter.
#
# Note: the cache will not be created if online_delete
# is specified.
# #
# fast_load Boolean. If set, load the last persisted ledger # fast_load Boolean. If set, load the last persisted ledger
# from disk upon process start before syncing to # from disk upon process start before syncing to
@@ -964,8 +948,6 @@
# if sufficient IOPS capacity is available. # if sufficient IOPS capacity is available.
# Default 0. # Default 0.
# #
# Optional keys for NuDB or RocksDB:
#
# earliest_seq The default is 32570 to match the XRP ledger # earliest_seq The default is 32570 to match the XRP ledger
# network's earliest allowed sequence. Alternate # network's earliest allowed sequence. Alternate
# networks may set this value. Minimum value of 1. # networks may set this value. Minimum value of 1.

View File

@@ -43,7 +43,8 @@ set(CMAKE_VS_GLOBALS "CLToolExe=cl.exe" "CLToolPath=${CMAKE_BINARY_DIR}" "TrackF
# By default Visual Studio generators will use /Zi to capture debug information, which is not compatible with ccache, so # By default Visual Studio generators will use /Zi to capture debug information, which is not compatible with ccache, so
# tell it to use /Z7 instead. # tell it to use /Z7 instead.
if (MSVC) if (MSVC)
foreach (var_ CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE) foreach (var_ CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE)
string(REPLACE "/Zi" "/Z7" ${var_} "${${var_}}") string(REPLACE "/Zi" "/Z7" ${var_} "${${var_}}")
endforeach () endforeach ()
endif () endif ()

View File

@@ -180,7 +180,8 @@ elseif (DEFINED ENV{CODE_COVERAGE_GCOV_TOOL})
set(GCOV_TOOL "$ENV{CODE_COVERAGE_GCOV_TOOL}") set(GCOV_TOOL "$ENV{CODE_COVERAGE_GCOV_TOOL}")
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang") elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
if (APPLE) if (APPLE)
execute_process(COMMAND xcrun -f llvm-cov OUTPUT_VARIABLE LLVMCOV_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND xcrun -f llvm-cov OUTPUT_VARIABLE LLVMCOV_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
else () else ()
find_program(LLVMCOV_PATH llvm-cov) find_program(LLVMCOV_PATH llvm-cov)
endif () endif ()
@@ -199,8 +200,8 @@ foreach (LANG ${LANGUAGES})
if ("${CMAKE_${LANG}_COMPILER_VERSION}" VERSION_LESS 3) if ("${CMAKE_${LANG}_COMPILER_VERSION}" VERSION_LESS 3)
message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...") message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
endif () endif ()
elseif (NOT "${CMAKE_${LANG}_COMPILER_ID}" MATCHES "GNU" AND NOT "${CMAKE_${LANG}_COMPILER_ID}" MATCHES elseif (NOT "${CMAKE_${LANG}_COMPILER_ID}" MATCHES "GNU" AND NOT "${CMAKE_${LANG}_COMPILER_ID}"
"(LLVM)?[Ff]lang") MATCHES "(LLVM)?[Ff]lang")
message(FATAL_ERROR "Compiler is not GNU or Flang! Aborting...") message(FATAL_ERROR "Compiler is not GNU or Flang! Aborting...")
endif () endif ()
endforeach () endforeach ()
@@ -321,14 +322,16 @@ function (setup_target_for_coverage_gcovr)
endif () endif ()
if ("--output" IN_LIST GCOVR_ADDITIONAL_ARGS) if ("--output" IN_LIST GCOVR_ADDITIONAL_ARGS)
message(FATAL_ERROR "Unsupported --output option detected in GCOVR_ADDITIONAL_ARGS! Aborting...") message(FATAL_ERROR "Unsupported --output option detected in GCOVR_ADDITIONAL_ARGS! Aborting..."
)
else () else ()
if ((Coverage_FORMAT STREQUAL "html-details") OR (Coverage_FORMAT STREQUAL "html-nested")) if ((Coverage_FORMAT STREQUAL "html-details") OR (Coverage_FORMAT STREQUAL "html-nested"))
set(GCOVR_OUTPUT_FILE ${PROJECT_BINARY_DIR}/${Coverage_NAME}/index.html) set(GCOVR_OUTPUT_FILE ${PROJECT_BINARY_DIR}/${Coverage_NAME}/index.html)
set(GCOVR_CREATE_FOLDER ${PROJECT_BINARY_DIR}/${Coverage_NAME}) set(GCOVR_CREATE_FOLDER ${PROJECT_BINARY_DIR}/${Coverage_NAME})
elseif (Coverage_FORMAT STREQUAL "html-single") elseif (Coverage_FORMAT STREQUAL "html-single")
set(GCOVR_OUTPUT_FILE ${Coverage_NAME}.html) set(GCOVR_OUTPUT_FILE ${Coverage_NAME}.html)
elseif ((Coverage_FORMAT STREQUAL "json-summary") OR (Coverage_FORMAT STREQUAL "json-details") elseif ((Coverage_FORMAT STREQUAL "json-summary") OR (Coverage_FORMAT STREQUAL
"json-details")
OR (Coverage_FORMAT STREQUAL "coveralls")) OR (Coverage_FORMAT STREQUAL "coveralls"))
set(GCOVR_OUTPUT_FILE ${Coverage_NAME}.json) set(GCOVR_OUTPUT_FILE ${Coverage_NAME}.json)
elseif (Coverage_FORMAT STREQUAL "txt") elseif (Coverage_FORMAT STREQUAL "txt")
@@ -452,8 +455,10 @@ function (setup_target_for_coverage_gcovr)
COMMENT "Running gcovr to produce code coverage report.") COMMENT "Running gcovr to produce code coverage report.")
# Show info where to find the report # Show info where to find the report
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD COMMAND echo add_custom_command(
COMMENT "Code coverage report saved in ${GCOVR_OUTPUT_FILE} formatted as ${Coverage_FORMAT}") TARGET ${Coverage_NAME} POST_BUILD COMMAND echo
COMMENT "Code coverage report saved in ${GCOVR_OUTPUT_FILE} formatted as ${Coverage_FORMAT}"
)
endfunction () # setup_target_for_coverage_gcovr endfunction () # setup_target_for_coverage_gcovr
function (add_code_coverage_to_target name scope) function (add_code_coverage_to_target name scope)
@@ -463,14 +468,10 @@ function (add_code_coverage_to_target name scope)
separate_arguments(COVERAGE_C_LINKER_FLAGS NATIVE_COMMAND "${COVERAGE_C_LINKER_FLAGS}") separate_arguments(COVERAGE_C_LINKER_FLAGS NATIVE_COMMAND "${COVERAGE_C_LINKER_FLAGS}")
# Add compiler options to the target # Add compiler options to the target
target_compile_options(${name} ${scope} $<$<COMPILE_LANGUAGE:CXX>:${COVERAGE_CXX_COMPILER_FLAGS}> target_compile_options(
$<$<COMPILE_LANGUAGE:C>:${COVERAGE_C_COMPILER_FLAGS}>) ${name} ${scope} $<$<COMPILE_LANGUAGE:CXX>:${COVERAGE_CXX_COMPILER_FLAGS}>
$<$<COMPILE_LANGUAGE:C>:${COVERAGE_C_COMPILER_FLAGS}>)
target_link_libraries( target_link_libraries(${name} ${scope} $<$<LINK_LANGUAGE:CXX>:${COVERAGE_CXX_LINKER_FLAGS}>
${name} $<$<LINK_LANGUAGE:C>:${COVERAGE_C_LINKER_FLAGS}>)
${scope}
$<$<LINK_LANGUAGE:CXX>:${COVERAGE_CXX_LINKER_FLAGS}
gcov>
$<$<LINK_LANGUAGE:C>:${COVERAGE_C_LINKER_FLAGS}
gcov>)
endfunction () # add_code_coverage_to_target endfunction () # add_code_coverage_to_target

View File

@@ -9,8 +9,5 @@ function (xrpl_add_test name)
isolate_headers(${target} "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/tests/${name}" PRIVATE) isolate_headers(${target} "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/tests/${name}" PRIVATE)
# Make sure the test isn't optimized away in unity builds
set_target_properties(${target} PROPERTIES UNITY_BUILD_MODE GROUP UNITY_BUILD_BATCH_SIZE 0) # Adjust as needed
add_test(NAME ${target} COMMAND ${target}) add_test(NAME ${target} COMMAND ${target})
endfunction () endfunction ()

View File

@@ -17,7 +17,8 @@ link_libraries(Xrpl::common)
if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif () endif ()
set_target_properties(common PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE}) set_target_properties(common PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE
${CMAKE_POSITION_INDEPENDENT_CODE})
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
target_compile_definitions( target_compile_definitions(
common common
@@ -37,7 +38,8 @@ if (MSVC)
# remove existing exception flag since we set it to -EHa # remove existing exception flag since we set it to -EHa
string(REGEX REPLACE "[-/]EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REGEX REPLACE "[-/]EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
foreach (var_ CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE) foreach (var_ CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE)
# also remove dynamic runtime # also remove dynamic runtime
string(REGEX REPLACE "[-/]MD[d]*" " " ${var_} "${${var_}}") string(REGEX REPLACE "[-/]MD[d]*" " " ${var_} "${${var_}}")
@@ -143,20 +145,23 @@ if (voidstar)
elseif (NOT is_linux) elseif (NOT is_linux)
message(FATAL_ERROR "Antithesis instrumentation requires Linux, aborting...") message(FATAL_ERROR "Antithesis instrumentation requires Linux, aborting...")
elseif (NOT (is_clang AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)) elseif (NOT (is_clang AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0))
message(FATAL_ERROR "Antithesis instrumentation requires Clang version 16 or later, aborting...") message(FATAL_ERROR "Antithesis instrumentation requires Clang version 16 or later, aborting..."
)
endif () endif ()
endif () endif ()
if (use_mold) if (use_mold)
# use mold linker if available # use mold linker if available
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=mold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=mold -Wl,--version ERROR_QUIET
OUTPUT_VARIABLE LD_VERSION)
if ("${LD_VERSION}" MATCHES "mold") if ("${LD_VERSION}" MATCHES "mold")
target_link_libraries(common INTERFACE -fuse-ld=mold) target_link_libraries(common INTERFACE -fuse-ld=mold)
endif () endif ()
unset(LD_VERSION) unset(LD_VERSION)
elseif (use_gold AND is_gcc) elseif (use_gold AND is_gcc)
# use gold linker if available # use gold linker if available
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET
OUTPUT_VARIABLE LD_VERSION)
#[=========================================================[ #[=========================================================[
NOTE: THE gold linker inserts -rpath as DT_RUNPATH by NOTE: THE gold linker inserts -rpath as DT_RUNPATH by
default instead of DT_RPATH, so you might have slightly default instead of DT_RPATH, so you might have slightly
@@ -186,7 +191,8 @@ elseif (use_gold AND is_gcc)
unset(LD_VERSION) unset(LD_VERSION)
elseif (use_lld) elseif (use_lld)
# use lld linker if available # use lld linker if available
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=lld -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=lld -Wl,--version ERROR_QUIET
OUTPUT_VARIABLE LD_VERSION)
if ("${LD_VERSION}" MATCHES "LLD") if ("${LD_VERSION}" MATCHES "LLD")
target_link_libraries(common INTERFACE -fuse-ld=lld) target_link_libraries(common INTERFACE -fuse-ld=lld)
endif () endif ()

View File

@@ -14,7 +14,8 @@ target_protobuf_sources(xrpl.libpb xrpl/proto LANGUAGE cpp IMPORT_DIRS include/x
PROTOS include/xrpl/proto/xrpl.proto) PROTOS include/xrpl/proto/xrpl.proto)
file(GLOB_RECURSE protos "include/xrpl/proto/org/*.proto") file(GLOB_RECURSE protos "include/xrpl/proto/org/*.proto")
target_protobuf_sources(xrpl.libpb xrpl/proto LANGUAGE cpp IMPORT_DIRS include/xrpl/proto PROTOS "${protos}") target_protobuf_sources(xrpl.libpb xrpl/proto LANGUAGE cpp IMPORT_DIRS include/xrpl/proto
PROTOS "${protos}")
target_protobuf_sources( target_protobuf_sources(
xrpl.libpb xrpl/proto xrpl.libpb xrpl/proto
LANGUAGE grpc LANGUAGE grpc
@@ -24,8 +25,9 @@ target_protobuf_sources(
GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc) GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc)
target_compile_options( target_compile_options(
xrpl.libpb PUBLIC $<$<BOOL:${is_msvc}>:-wd4996> $<$<BOOL:${is_xcode}>: --system-header-prefix="google/protobuf" xrpl.libpb
-Wno-deprecated-dynamic-exception-spec > PUBLIC $<$<BOOL:${is_msvc}>:-wd4996> $<$<BOOL:${is_xcode}>:
--system-header-prefix="google/protobuf" -Wno-deprecated-dynamic-exception-spec >
PRIVATE $<$<BOOL:${is_msvc}>:-wd4065> $<$<NOT:$<BOOL:${is_msvc}>>:-Wno-deprecated-declarations>) PRIVATE $<$<BOOL:${is_msvc}>:-wd4065> $<$<NOT:$<BOOL:${is_msvc}>>:-Wno-deprecated-declarations>)
target_link_libraries(xrpl.libpb PUBLIC protobuf::libprotobuf gRPC::grpc++) target_link_libraries(xrpl.libpb PUBLIC protobuf::libprotobuf gRPC::grpc++)
@@ -73,7 +75,8 @@ target_link_libraries(xrpl.libxrpl.protocol PUBLIC xrpl.libxrpl.crypto xrpl.libx
# Level 05 # Level 05
add_module(xrpl core) add_module(xrpl core)
target_link_libraries(xrpl.libxrpl.core PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol) target_link_libraries(xrpl.libxrpl.core PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json
xrpl.libxrpl.protocol)
# Level 06 # Level 06
add_module(xrpl resource) add_module(xrpl resource)
@@ -81,21 +84,40 @@ target_link_libraries(xrpl.libxrpl.resource PUBLIC xrpl.libxrpl.protocol)
# Level 07 # Level 07
add_module(xrpl net) add_module(xrpl net)
target_link_libraries(xrpl.libxrpl.net PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol target_link_libraries(xrpl.libxrpl.net PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json
xrpl.libxrpl.resource) xrpl.libxrpl.protocol xrpl.libxrpl.resource)
add_module(xrpl server)
target_link_libraries(xrpl.libxrpl.server PUBLIC xrpl.libxrpl.protocol)
add_module(xrpl nodestore) add_module(xrpl nodestore)
target_link_libraries(xrpl.libxrpl.nodestore PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol) target_link_libraries(xrpl.libxrpl.nodestore PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json
xrpl.libxrpl.protocol)
add_module(xrpl shamap) add_module(xrpl shamap)
target_link_libraries(xrpl.libxrpl.shamap PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.crypto xrpl.libxrpl.protocol target_link_libraries(xrpl.libxrpl.shamap PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.crypto
xrpl.libxrpl.nodestore) xrpl.libxrpl.protocol xrpl.libxrpl.nodestore)
add_module(xrpl rdb)
target_link_libraries(xrpl.libxrpl.rdb PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.core)
add_module(xrpl server)
target_link_libraries(xrpl.libxrpl.server PUBLIC xrpl.libxrpl.protocol xrpl.libxrpl.core
xrpl.libxrpl.rdb xrpl.libxrpl.resource)
add_module(xrpl conditions)
target_link_libraries(xrpl.libxrpl.conditions PUBLIC xrpl.libxrpl.server)
add_module(xrpl ledger) add_module(xrpl ledger)
target_link_libraries(xrpl.libxrpl.ledger PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol) target_link_libraries(
xrpl.libxrpl.ledger
PUBLIC xrpl.libxrpl.basics
xrpl.libxrpl.json
xrpl.libxrpl.protocol
xrpl.libxrpl.rdb
xrpl.libxrpl.server
xrpl.libxrpl.shamap
xrpl.libxrpl.conditions)
add_module(xrpl tx)
target_link_libraries(xrpl.libxrpl.tx PUBLIC xrpl.libxrpl.ledger)
add_library(xrpl.libxrpl) add_library(xrpl.libxrpl)
set_target_properties(xrpl.libxrpl PROPERTIES OUTPUT_NAME xrpl) set_target_properties(xrpl.libxrpl PROPERTIES OUTPUT_NAME xrpl)
@@ -110,16 +132,19 @@ target_link_modules(
PUBLIC PUBLIC
basics basics
beast beast
conditions
core core
crypto crypto
json json
ledger
net
nodestore
protocol protocol
rdb
resource resource
server server
nodestore
shamap shamap
net tx)
ledger)
# All headers in libxrpl are in modules. # All headers in libxrpl are in modules.
# Uncomment this stanza if you have not yet moved new headers into a module. # Uncomment this stanza if you have not yet moved new headers into a module.
@@ -160,12 +185,4 @@ if (xrpld)
# antithesis_instrumentation.h, which is not exported as INTERFACE # antithesis_instrumentation.h, which is not exported as INTERFACE
target_include_directories(xrpld PRIVATE ${CMAKE_SOURCE_DIR}/external/antithesis-sdk) target_include_directories(xrpld PRIVATE ${CMAKE_SOURCE_DIR}/external/antithesis-sdk)
endif () endif ()
# any files that don't play well with unity should be added here
if (tests)
set_source_files_properties(
# these two seem to produce conflicts in beast teardown template methods
src/test/rpc/ValidatorRPC_test.cpp src/test/ledger/Invariants_test.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION
TRUE)
endif ()
endif () endif ()

View File

@@ -65,8 +65,8 @@ add_custom_command(
OUTPUT "${doxygen_index_file}" OUTPUT "${doxygen_index_file}"
COMMAND "${CMAKE_COMMAND}" -E env "DOXYGEN_OUTPUT_DIRECTORY=${doxygen_output_directory}" COMMAND "${CMAKE_COMMAND}" -E env "DOXYGEN_OUTPUT_DIRECTORY=${doxygen_output_directory}"
"DOXYGEN_INCLUDE_PATH=${doxygen_include_path}" "DOXYGEN_TAGFILES=${doxygen_tagfiles}" "DOXYGEN_INCLUDE_PATH=${doxygen_include_path}" "DOXYGEN_TAGFILES=${doxygen_tagfiles}"
"DOXYGEN_PLANTUML_JAR_PATH=${doxygen_plantuml_jar_path}" "DOXYGEN_DOT_PATH=${doxygen_dot_path}" "DOXYGEN_PLANTUML_JAR_PATH=${doxygen_plantuml_jar_path}"
"${DOXYGEN_EXECUTABLE}" "${doxyfile}" "DOXYGEN_DOT_PATH=${doxygen_dot_path}" "${DOXYGEN_EXECUTABLE}" "${doxyfile}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS "${dependencies}" "${tagfile}") DEPENDS "${dependencies}" "${tagfile}")
add_custom_target(docs DEPENDS "${doxygen_index_file}" SOURCES "${dependencies}") add_custom_target(docs DEPENDS "${doxygen_index_file}" SOURCES "${dependencies}")

View File

@@ -20,9 +20,11 @@ install(TARGETS common
xrpl.libxrpl xrpl.libxrpl
xrpl.libxrpl.basics xrpl.libxrpl.basics
xrpl.libxrpl.beast xrpl.libxrpl.beast
xrpl.libxrpl.conditions
xrpl.libxrpl.core xrpl.libxrpl.core
xrpl.libxrpl.crypto xrpl.libxrpl.crypto
xrpl.libxrpl.json xrpl.libxrpl.json
xrpl.libxrpl.rdb
xrpl.libxrpl.ledger xrpl.libxrpl.ledger
xrpl.libxrpl.net xrpl.libxrpl.net
xrpl.libxrpl.nodestore xrpl.libxrpl.nodestore
@@ -30,6 +32,7 @@ install(TARGETS common
xrpl.libxrpl.resource xrpl.libxrpl.resource
xrpl.libxrpl.server xrpl.libxrpl.server
xrpl.libxrpl.shamap xrpl.libxrpl.shamap
xrpl.libxrpl.tx
antithesis-sdk-cpp antithesis-sdk-cpp
EXPORT XrplExports EXPORT XrplExports
LIBRARY DESTINATION lib LIBRARY DESTINATION lib
@@ -38,11 +41,13 @@ install(TARGETS common
INCLUDES INCLUDES
DESTINATION include) DESTINATION include)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/xrpl" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/xrpl"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(EXPORT XrplExports FILE XrplTargets.cmake NAMESPACE Xrpl:: DESTINATION lib/cmake/xrpl) install(EXPORT XrplExports FILE XrplTargets.cmake NAMESPACE Xrpl:: DESTINATION lib/cmake/xrpl)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
write_basic_package_version_file(XrplConfigVersion.cmake VERSION ${xrpld_version} COMPATIBILITY SameMajorVersion) write_basic_package_version_file(XrplConfigVersion.cmake VERSION ${xrpld_version}
COMPATIBILITY SameMajorVersion)
if (is_root_project AND TARGET xrpld) if (is_root_project AND TARGET xrpld)
install(TARGETS xrpld RUNTIME DESTINATION bin) install(TARGETS xrpld RUNTIME DESTINATION bin)
@@ -69,5 +74,5 @@ if (is_root_project AND TARGET xrpld)
") ")
endif () endif ()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/XrplConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/XrplConfigVersion.cmake install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/XrplConfig.cmake
DESTINATION lib/cmake/xrpl) ${CMAKE_CURRENT_BINARY_DIR}/XrplConfigVersion.cmake DESTINATION lib/cmake/xrpl)

View File

@@ -33,10 +33,13 @@ target_compile_definitions(
target_compile_options( target_compile_options(
opts opts
INTERFACE $<$<AND:$<BOOL:${is_gcc}>,$<COMPILE_LANGUAGE:CXX>>:-Wsuggest-override> INTERFACE $<$<AND:$<BOOL:${is_gcc}>,$<COMPILE_LANGUAGE:CXX>>:-Wsuggest-override>
$<$<BOOL:${is_gcc}>:-Wno-maybe-uninitialized> $<$<BOOL:${perf}>:-fno-omit-frame-pointer> $<$<BOOL:${is_gcc}>:-Wno-maybe-uninitialized>
$<$<BOOL:${profile}>:-pg> $<$<AND:$<BOOL:${is_gcc}>,$<BOOL:${profile}>>:-p>) $<$<BOOL:${perf}>:-fno-omit-frame-pointer>
$<$<BOOL:${profile}>:-pg>
$<$<AND:$<BOOL:${is_gcc}>,$<BOOL:${profile}>>:-p>)
target_link_libraries(opts INTERFACE $<$<BOOL:${profile}>:-pg> $<$<AND:$<BOOL:${is_gcc}>,$<BOOL:${profile}>>:-p>) target_link_libraries(opts INTERFACE $<$<BOOL:${profile}>:-pg>
$<$<AND:$<BOOL:${is_gcc}>,$<BOOL:${profile}>>:-p>)
if (jemalloc) if (jemalloc)
find_package(jemalloc REQUIRED) find_package(jemalloc REQUIRED)

View File

@@ -19,7 +19,8 @@ if (NOT is_multiconfig)
endif () endif ()
if (is_clang) # both Clang and AppleClang if (is_clang) # both Clang and AppleClang
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS
16.0)
message(FATAL_ERROR "This project requires clang 16 or later") message(FATAL_ERROR "This project requires clang 16 or later")
endif () endif ()
elseif (is_gcc) elseif (is_gcc)
@@ -32,7 +33,8 @@ endif ()
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "Builds (in-source) are not allowed in " message(FATAL_ERROR "Builds (in-source) are not allowed in "
"${CMAKE_CURRENT_SOURCE_DIR}. Please remove CMakeCache.txt and the CMakeFiles " "${CMAKE_CURRENT_SOURCE_DIR}. Please remove CMakeCache.txt and the CMakeFiles "
"directory from ${CMAKE_CURRENT_SOURCE_DIR} and try building in a separate directory.") "directory from ${CMAKE_CURRENT_SOURCE_DIR} and try building in a separate directory."
)
endif () endif ()
if (MSVC AND CMAKE_GENERATOR_PLATFORM STREQUAL "Win32") if (MSVC AND CMAKE_GENERATOR_PLATFORM STREQUAL "Win32")

View File

@@ -70,7 +70,8 @@ if (is_linux AND NOT SANITIZER)
else () else ()
set(TRUNCATED_LOGS_DEFAULT OFF) set(TRUNCATED_LOGS_DEFAULT OFF)
endif () endif ()
option(TRUNCATED_THREAD_NAME_LOGS "Show warnings about truncated thread names on Linux." ${TRUNCATED_LOGS_DEFAULT}) option(TRUNCATED_THREAD_NAME_LOGS "Show warnings about truncated thread names on Linux."
${TRUNCATED_LOGS_DEFAULT})
if (TRUNCATED_THREAD_NAME_LOGS) if (TRUNCATED_THREAD_NAME_LOGS)
add_compile_definitions(TRUNCATED_THREAD_NAME_LOGS) add_compile_definitions(TRUNCATED_THREAD_NAME_LOGS)
endif () endif ()
@@ -92,11 +93,13 @@ endif ()
option(jemalloc "Enables jemalloc for heap profiling" OFF) option(jemalloc "Enables jemalloc for heap profiling" OFF)
option(werr "treat warnings as errors" OFF) option(werr "treat warnings as errors" OFF)
option(local_protobuf "Force a local build of protobuf instead of looking for an installed version." OFF) option(local_protobuf
"Force a local build of protobuf instead of looking for an installed version." OFF)
option(local_grpc "Force a local build of gRPC instead of looking for an installed version." OFF) option(local_grpc "Force a local build of gRPC instead of looking for an installed version." OFF)
# the remaining options are obscure and rarely used # the remaining options are obscure and rarely used
option(beast_no_unit_test_inline "Prevents unit test definitions from being inserted into global table" OFF) option(beast_no_unit_test_inline
"Prevents unit test definitions from being inserted into global table" OFF)
option(single_io_service_thread "Restricts the number of threads calling io_context::run to one. \ option(single_io_service_thread "Restricts the number of threads calling io_context::run to one. \
This can be useful when debugging." OFF) This can be useful when debugging." OFF)
option(boost_show_deprecated "Allow boost to fail on deprecated usage. Only useful if you're trying\ option(boost_show_deprecated "Allow boost to fail on deprecated usage. Only useful if you're trying\

View File

@@ -1,4 +1,6 @@
option(validator_keys "Enables building of validator-keys tool as a separate target (imported via FetchContent)" OFF) option(validator_keys
"Enables building of validator-keys tool as a separate target (imported via FetchContent)"
OFF)
if (validator_keys) if (validator_keys)
git_branch(current_branch) git_branch(current_branch)
@@ -8,8 +10,9 @@ if (validator_keys)
endif () endif ()
message(STATUS "Tracking ValidatorKeys branch: ${current_branch}") message(STATUS "Tracking ValidatorKeys branch: ${current_branch}")
FetchContent_Declare(validator_keys GIT_REPOSITORY https://github.com/ripple/validator-keys-tool.git FetchContent_Declare(
GIT_TAG "${current_branch}") validator_keys GIT_REPOSITORY https://github.com/ripple/validator-keys-tool.git
GIT_TAG "${current_branch}")
FetchContent_MakeAvailable(validator_keys) FetchContent_MakeAvailable(validator_keys)
set_target_properties(validator-keys PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") set_target_properties(validator-keys PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
install(TARGETS validator-keys RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS validator-keys RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View File

@@ -15,11 +15,12 @@ include(isolate_headers)
function (add_module parent name) function (add_module parent name)
set(target ${PROJECT_NAME}.lib${parent}.${name}) set(target ${PROJECT_NAME}.lib${parent}.${name})
add_library(${target} OBJECT) add_library(${target} OBJECT)
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/lib${parent}/${name}/*.cpp") file(GLOB_RECURSE sources CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/src/lib${parent}/${name}/*.cpp")
target_sources(${target} PRIVATE ${sources}) target_sources(${target} PRIVATE ${sources})
target_include_directories(${target} PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>") target_include_directories(${target} PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
isolate_headers(${target} "${CMAKE_CURRENT_SOURCE_DIR}/include" isolate_headers(${target} "${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/include/${parent}/${name}" PUBLIC) "${CMAKE_CURRENT_SOURCE_DIR}/include/${parent}/${name}" PUBLIC)
isolate_headers(${target} "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/src/lib${parent}/${name}" isolate_headers(${target} "${CMAKE_CURRENT_SOURCE_DIR}/src"
PRIVATE) "${CMAKE_CURRENT_SOURCE_DIR}/src/lib${parent}/${name}" PRIVATE)
endfunction () endfunction ()

View File

@@ -39,6 +39,7 @@ if (SANITIZERS_ENABLED AND is_clang)
endif () endif ()
message(STATUS "Adding [${Boost_INCLUDE_DIRS}] to sanitizer blacklist") message(STATUS "Adding [${Boost_INCLUDE_DIRS}] to sanitizer blacklist")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/san_bl.txt "src:${Boost_INCLUDE_DIRS}/*") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/san_bl.txt "src:${Boost_INCLUDE_DIRS}/*")
target_compile_options(opts INTERFACE # ignore boost headers for sanitizing target_compile_options(
-fsanitize-blacklist=${CMAKE_CURRENT_BINARY_DIR}/san_bl.txt) opts INTERFACE # ignore boost headers for sanitizing
-fsanitize-blacklist=${CMAKE_CURRENT_BINARY_DIR}/san_bl.txt)
endif () endif ()

View File

@@ -6,11 +6,11 @@
"sqlite3/3.49.1#8631739a4c9b93bd3d6b753bac548a63%1765850149.926", "sqlite3/3.49.1#8631739a4c9b93bd3d6b753bac548a63%1765850149.926",
"soci/4.0.3#a9f8d773cd33e356b5879a4b0564f287%1765850149.46", "soci/4.0.3#a9f8d773cd33e356b5879a4b0564f287%1765850149.46",
"snappy/1.1.10#968fef506ff261592ec30c574d4a7809%1765850147.878", "snappy/1.1.10#968fef506ff261592ec30c574d4a7809%1765850147.878",
"secp256k1/0.7.0#9c4ab67bdc3860c16ea5b36aed8f74ea%1765850147.928", "secp256k1/0.7.1#3a61e95e220062ef32c48d019e9c81f7%1770306721.686",
"rocksdb/10.5.1#4a197eca381a3e5ae8adf8cffa5aacd0%1765850186.86", "rocksdb/10.5.1#4a197eca381a3e5ae8adf8cffa5aacd0%1765850186.86",
"re2/20230301#ca3b241baec15bd31ea9187150e0b333%1765850148.103", "re2/20230301#ca3b241baec15bd31ea9187150e0b333%1765850148.103",
"protobuf/6.32.1#f481fd276fc23a33b85a3ed1e898b693%1765850161.038", "protobuf/6.32.1#f481fd276fc23a33b85a3ed1e898b693%1765850161.038",
"openssl/3.5.4#1b986e61b38fdfda3b40bebc1b234393%1768312656.257", "openssl/3.5.5#05a4ac5b7323f7a329b2db1391d9941f%1769599205.414",
"nudb/2.0.9#0432758a24204da08fee953ec9ea03cb%1769436073.32", "nudb/2.0.9#0432758a24204da08fee953ec9ea03cb%1769436073.32",
"lz4/1.10.0#59fc63cac7f10fbe8e05c7e62c2f3504%1765850143.914", "lz4/1.10.0#59fc63cac7f10fbe8e05c7e62c2f3504%1765850143.914",
"libiconv/1.17#1e65319e945f2d31941a9d28cc13c058%1765842973.492", "libiconv/1.17#1e65319e945f2d31941a9d28cc13c058%1765842973.492",
@@ -23,7 +23,7 @@
"date/3.0.4#862e11e80030356b53c2c38599ceb32b%1765850143.772", "date/3.0.4#862e11e80030356b53c2c38599ceb32b%1765850143.772",
"c-ares/1.34.5#5581c2b62a608b40bb85d965ab3ec7c8%1765850144.336", "c-ares/1.34.5#5581c2b62a608b40bb85d965ab3ec7c8%1765850144.336",
"bzip2/1.0.8#c470882369c2d95c5c77e970c0c7e321%1765850143.837", "bzip2/1.0.8#c470882369c2d95c5c77e970c0c7e321%1765850143.837",
"boost/1.90.0#d5e8defe7355494953be18524a7f135b%1765955095.179", "boost/1.90.0#d5e8defe7355494953be18524a7f135b%1769454080.269",
"abseil/20250127.0#99262a368bd01c0ccca8790dfced9719%1766517936.993" "abseil/20250127.0#99262a368bd01c0ccca8790dfced9719%1766517936.993"
], ],
"build_requires": [ "build_requires": [
@@ -31,7 +31,7 @@
"strawberryperl/5.32.1.1#707032463aa0620fa17ec0d887f5fe41%1765850165.196", "strawberryperl/5.32.1.1#707032463aa0620fa17ec0d887f5fe41%1765850165.196",
"protobuf/6.32.1#f481fd276fc23a33b85a3ed1e898b693%1765850161.038", "protobuf/6.32.1#f481fd276fc23a33b85a3ed1e898b693%1765850161.038",
"nasm/2.16.01#31e26f2ee3c4346ecd347911bd126904%1765850144.707", "nasm/2.16.01#31e26f2ee3c4346ecd347911bd126904%1765850144.707",
"msys2/cci.latest#1996656c3c98e5765b25b60ff5cf77b4%1764840888.758", "msys2/cci.latest#eea83308ad7e9023f7318c60d5a9e6cb%1770199879.083",
"m4/1.4.19#70dc8bbb33e981d119d2acc0175cf381%1763158052.846", "m4/1.4.19#70dc8bbb33e981d119d2acc0175cf381%1763158052.846",
"cmake/4.2.0#ae0a44f44a1ef9ab68fd4b3e9a1f8671%1765850153.937", "cmake/4.2.0#ae0a44f44a1ef9ab68fd4b3e9a1f8671%1765850153.937",
"cmake/3.31.10#313d16a1aa16bbdb2ca0792467214b76%1765850153.479", "cmake/3.31.10#313d16a1aa16bbdb2ca0792467214b76%1765850153.479",

View File

@@ -32,8 +32,8 @@ class Xrpl(ConanFile):
"grpc/1.72.0", "grpc/1.72.0",
"libarchive/3.8.1", "libarchive/3.8.1",
"nudb/2.0.9", "nudb/2.0.9",
"openssl/3.5.4", "openssl/3.5.5",
"secp256k1/0.7.0", "secp256k1/0.7.1",
"soci/4.0.3", "soci/4.0.3",
"zlib/1.3.1", "zlib/1.3.1",
] ]

View File

@@ -1,14 +1,14 @@
ignorePaths: ignorePaths:
- build/** - build/**
- src/libxrpl/crypto - src/libxrpl/crypto
- src/test/** # Will be removed in the future
- CMakeUserPresets.json - CMakeUserPresets.json
- Doxyfile - Doxyfile
- docs/**/*.puml - docs/**/*.puml
- cmake/** - cmake/**
- LICENSE.md - LICENSE.md
- .clang-tidy
language: en language: en
allowCompoundWords: true allowCompoundWords: true # TODO (#6334)
ignoreRandomStrings: true ignoreRandomStrings: true
minWordLength: 5 minWordLength: 5
dictionaries: dictionaries:
@@ -16,20 +16,29 @@ dictionaries:
- en_US - en_US
- en_GB - en_GB
ignoreRegExpList: ignoreRegExpList:
- /[rs][1-9A-HJ-NP-Za-km-z]{25,34}/g # addresses and seeds - /\b[rs][1-9A-HJ-NP-Za-km-z]{25,34}/g # addresses and seeds
- /(XRPL|BEAST)_[A-Z_0-9]+_H_INCLUDED+/g # include guards - /\bC[A-Z0-9]{15}/g # CTIDs
- /(XRPL|BEAST)_[A-Z_0-9]+_H+/g # include guards - /\b(XRPL|BEAST)_[A-Z_0-9]+_H_INCLUDED+/g # include guards
- /\b(XRPL|BEAST)_[A-Z_0-9]+_H+/g # include guards
- /::[a-z:_]+/g # things from other namespaces - /::[a-z:_]+/g # things from other namespaces
- /lib[a-z]+/g # libraries - /\blib[a-z]+/g # libraries
- /[0-9]{4}-[0-9]{2}-[0-9]{2}[,:][A-Za-zÀ-ÖØ-öø-ÿ.\s]+/g # copyright dates - /\b[0-9]{4}-[0-9]{2}-[0-9]{2}[,:][A-Za-zÀ-ÖØ-öø-ÿ.\s]+/g # copyright dates
- /[0-9]{4}[,:]?\s*[A-Za-zÀ-ÖØ-öø-ÿ.\s]+/g # copyright years - /\b[0-9]{4}[,:]?\s*[A-Za-zÀ-ÖØ-öø-ÿ.\s]+/g # copyright years
- /\[[A-Za-z0-9-]+\]\(https:\/\/github.com\/[A-Za-z0-9-]+\)/g # Github usernames - /\[[A-Za-z0-9-]+\]\(https:\/\/github.com\/[A-Za-z0-9-]+\)/g # Github usernames
- /-[DWw][a-zA-Z0-9_-]+=/g # compile flags - /-[DWw][a-zA-Z0-9_-]+=/g # compile flags
- /[\['"`]-[DWw][a-zA-Z0-9_-]+['"`\]]/g # compile flags - /[\['"`]-[DWw][a-zA-Z0-9_-]+['"`\]]/g # compile flags
- ABCDEFGHIJKLMNOPQRSTUVWXYZ
- ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
overrides:
- filename: "**/*_test.cpp" # all test files
ignoreRegExpList:
- /"[^"]*"/g # double-quoted strings
- /'[^']*'/g # single-quoted strings
- /`[^`]*`/g # backtick strings
suggestWords: suggestWords:
- xprl->xrpl - xprl->xrpl
- xprld->xrpld - xprld->xrpld # cspell: disable-line not sure what this problem is....
- unsynched->unsynced - unsynched->unsynced # cspell: disable-line not sure what this problem is....
- synched->synced - synched->synced
- synch->sync - synch->sync
words: words:
@@ -51,6 +60,7 @@ words:
- Britto - Britto
- Btrfs - Btrfs
- canonicality - canonicality
- changespq
- checkme - checkme
- choco - choco
- chrono - chrono
@@ -106,12 +116,14 @@ words:
- inequation - inequation
- insuf - insuf
- insuff - insuff
- invasively
- iou - iou
- ious - ious
- isrdc - isrdc
- itype - itype
- jemalloc - jemalloc
- jlog - jlog
- jtnofill
- keylet - keylet
- keylets - keylets
- keyvadb - keyvadb
@@ -138,6 +150,7 @@ words:
- Metafuncton - Metafuncton
- misprediction - misprediction
- mptbalance - mptbalance
- MPTDEX
- mptflags - mptflags
- mptid - mptid
- mptissuance - mptissuance
@@ -147,6 +160,7 @@ words:
- mptokenissuance - mptokenissuance
- mptokens - mptokens
- mpts - mpts
- mtgox
- multisig - multisig
- multisign - multisign
- multisigned - multisigned
@@ -174,6 +188,7 @@ words:
- perminute - perminute
- permissioned - permissioned
- pointee - pointee
- populator
- preauth - preauth
- preauthorization - preauthorization
- preauthorize - preauthorize
@@ -182,6 +197,7 @@ words:
- protobuf - protobuf
- protos - protos
- ptrs - ptrs
- pushd
- pyenv - pyenv
- qalloc - qalloc
- queuable - queuable

View File

@@ -17,8 +17,8 @@ guideline is to maintain the standards that are used in those libraries.
## Guidelines ## Guidelines
If you want to do something contrary to these guidelines, understand If you want to do something contrary to these guidelines, understand
why you're doing it. Think, use common sense, and consider that this why you're doing it. Think, use common sense, and consider that these
your changes will probably need to be maintained long after you've changes will probably need to be maintained long after you've
moved on to other projects. moved on to other projects.
- Use white space and blank lines to guide the eye and keep your intent clear. - Use white space and blank lines to guide the eye and keep your intent clear.

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_ARCHIVE_H_INCLUDED #pragma once
#define XRPL_BASICS_ARCHIVE_H_INCLUDED
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
@@ -16,5 +15,3 @@ void
extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const& dst); extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const& dst);
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_BASICCONFIG_H_INCLUDED #pragma once
#define XRPL_BASICS_BASICCONFIG_H_INCLUDED
#include <xrpl/basics/contract.h> #include <xrpl/basics/contract.h>
@@ -85,7 +84,8 @@ public:
if (lines_.empty()) if (lines_.empty())
return ""; return "";
if (lines_.size() > 1) if (lines_.size() > 1)
Throw<std::runtime_error>("A legacy value must have exactly one line. Section: " + name_); Throw<std::runtime_error>(
"A legacy value must have exactly one line. Section: " + name_);
return lines_[0]; return lines_[0];
} }
@@ -269,7 +269,8 @@ public:
bool bool
had_trailing_comments() const had_trailing_comments() const
{ {
return std::any_of(map_.cbegin(), map_.cend(), [](auto s) { return s.second.had_trailing_comments(); }); return std::any_of(
map_.cbegin(), map_.cend(), [](auto s) { return s.second.had_trailing_comments(); });
} }
protected: protected:
@@ -369,5 +370,3 @@ get_if_exists<bool>(Section const& section, std::string const& name, bool& v)
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_BLOB_H_INCLUDED #pragma once
#define XRPL_BASICS_BLOB_H_INCLUDED
#include <vector> #include <vector>
@@ -11,5 +10,3 @@ namespace xrpl {
using Blob = std::vector<unsigned char>; using Blob = std::vector<unsigned char>;
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_BUFFER_H_INCLUDED #pragma once
#define XRPL_BASICS_BUFFER_H_INCLUDED
#include <xrpl/basics/Slice.h> #include <xrpl/basics/Slice.h>
#include <xrpl/beast/utility/instrumentation.h> #include <xrpl/beast/utility/instrumentation.h>
@@ -213,5 +212,3 @@ operator!=(Buffer const& lhs, Buffer const& rhs) noexcept
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_BYTEUTILITIES_H_INCLUDED #pragma once
#define XRPL_BASICS_BYTEUTILITIES_H_INCLUDED
namespace xrpl { namespace xrpl {
@@ -20,5 +19,3 @@ megabytes(T value) noexcept
static_assert(kilobytes(2) == 2048, "kilobytes(2) == 2048"); static_assert(kilobytes(2) == 2048, "kilobytes(2) == 2048");
static_assert(megabytes(3) == 3145728, "megabytes(3) == 3145728"); static_assert(megabytes(3) == 3145728, "megabytes(3) == 3145728");
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_COMPRESSIONALGORITHMS_H_INCLUDED #pragma once
#define XRPL_COMPRESSIONALGORITHMS_H_INCLUDED
#include <xrpl/basics/contract.h> #include <xrpl/basics/contract.h>
@@ -36,7 +35,10 @@ lz4Compress(void const* in, std::size_t inSize, BufferFactory&& bf)
auto compressed = bf(outCapacity); auto compressed = bf(outCapacity);
auto compressedSize = LZ4_compress_default( auto compressedSize = LZ4_compress_default(
reinterpret_cast<char const*>(in), reinterpret_cast<char*>(compressed), inSize, outCapacity); reinterpret_cast<char const*>(in),
reinterpret_cast<char*>(compressed),
inSize,
outCapacity);
if (compressedSize == 0) if (compressedSize == 0)
Throw<std::runtime_error>("lz4 compress: failed"); Throw<std::runtime_error>("lz4 compress: failed");
@@ -67,8 +69,10 @@ lz4Decompress(
Throw<std::runtime_error>("lz4Decompress: integer overflow (output)"); Throw<std::runtime_error>("lz4Decompress: integer overflow (output)");
if (LZ4_decompress_safe( if (LZ4_decompress_safe(
reinterpret_cast<char const*>(in), reinterpret_cast<char*>(decompressed), inSize, decompressedSize) != reinterpret_cast<char const*>(in),
decompressedSize) reinterpret_cast<char*>(decompressed),
inSize,
decompressedSize) != decompressedSize)
Throw<std::runtime_error>("lz4Decompress: failed"); Throw<std::runtime_error>("lz4Decompress: failed");
return decompressedSize; return decompressedSize;
@@ -84,7 +88,11 @@ lz4Decompress(
*/ */
template <typename InputStream> template <typename InputStream>
std::size_t std::size_t
lz4Decompress(InputStream& in, std::size_t inSize, std::uint8_t* decompressed, std::size_t decompressedSize) lz4Decompress(
InputStream& in,
std::size_t inSize,
std::uint8_t* decompressed,
std::size_t decompressedSize)
{ {
std::vector<std::uint8_t> compressed; std::vector<std::uint8_t> compressed;
std::uint8_t const* chunk = nullptr; std::uint8_t const* chunk = nullptr;
@@ -133,5 +141,3 @@ lz4Decompress(InputStream& in, std::size_t inSize, std::uint8_t* decompressed, s
} // namespace compression_algorithms } // namespace compression_algorithms
} // namespace xrpl } // namespace xrpl
#endif // XRPL_COMPRESSIONALGORITHMS_H_INCLUDED

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_COUNTEDOBJECT_H_INCLUDED #pragma once
#define XRPL_BASICS_COUNTEDOBJECT_H_INCLUDED
#include <xrpl/beast/type_name.h> #include <xrpl/beast/type_name.h>
@@ -134,5 +133,3 @@ public:
}; };
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_DECAYINGSAMPLE_H_INCLUDED #pragma once
#define XRPL_BASICS_DECAYINGSAMPLE_H_INCLUDED
#include <chrono> #include <chrono>
#include <cmath> #include <cmath>
@@ -56,7 +55,8 @@ private:
if (m_value != value_type()) if (m_value != value_type())
{ {
std::size_t elapsed = std::chrono::duration_cast<std::chrono::seconds>(now - m_when).count(); std::size_t elapsed =
std::chrono::duration_cast<std::chrono::seconds>(now - m_when).count();
// A span larger than four times the window decays the // A span larger than four times the window decays the
// value to an insignificant amount so just reset it. // value to an insignificant amount so just reset it.
@@ -130,5 +130,3 @@ private:
}; };
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_EXPECTED_H_INCLUDED #pragma once
#define XRPL_BASICS_EXPECTED_H_INCLUDED
#include <xrpl/basics/contract.h> #include <xrpl/basics/contract.h>
@@ -121,7 +120,8 @@ public:
template <typename U> template <typename U>
requires std::convertible_to<U, E> && (!std::is_reference_v<U>) requires std::convertible_to<U, E> && (!std::is_reference_v<U>)
constexpr Expected(Unexpected<U> e) : Base(boost::outcome_v2::in_place_type_t<E>{}, std::move(e.value())) constexpr Expected(Unexpected<U> e)
: Base(boost::outcome_v2::in_place_type_t<E>{}, std::move(e.value()))
{ {
} }
@@ -192,7 +192,8 @@ public:
// Specialization of Expected<void, E>. Allows returning either success // Specialization of Expected<void, E>. Allows returning either success
// (without a value) or the reason for the failure. // (without a value) or the reason for the failure.
template <class E> template <class E>
class [[nodiscard]] Expected<void, E> : private boost::outcome_v2::result<void, E, detail::throw_policy> class [[nodiscard]]
Expected<void, E> : private boost::outcome_v2::result<void, E, detail::throw_policy>
{ {
using Base = boost::outcome_v2::result<void, E, detail::throw_policy>; using Base = boost::outcome_v2::result<void, E, detail::throw_policy>;
@@ -229,5 +230,3 @@ public:
}; };
} // namespace xrpl } // namespace xrpl
#endif // XRPL_BASICS_EXPECTED_H_INCLUDED

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_FILEUTILITIES_H_INCLUDED #pragma once
#define XRPL_BASICS_FILEUTILITIES_H_INCLUDED
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/system/error_code.hpp> #include <boost/system/error_code.hpp>
@@ -15,8 +14,9 @@ getFileContents(
std::optional<std::size_t> maxSize = std::nullopt); std::optional<std::size_t> maxSize = std::nullopt);
void void
writeFileContents(boost::system::error_code& ec, boost::filesystem::path const& destPath, std::string const& contents); writeFileContents(
boost::system::error_code& ec,
boost::filesystem::path const& destPath,
std::string const& contents);
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_INTRUSIVEPOINTER_H_INCLUDED #pragma once
#define XRPL_BASICS_INTRUSIVEPOINTER_H_INCLUDED
#include <concepts> #include <concepts>
#include <cstdint> #include <cstdint>
@@ -45,8 +44,8 @@ struct SharedIntrusiveAdoptNoIncrementTag
// //
template <class T> template <class T>
concept CAdoptTag = concept CAdoptTag = std::is_same_v<T, SharedIntrusiveAdoptIncrementStrongTag> ||
std::is_same_v<T, SharedIntrusiveAdoptIncrementStrongTag> || std::is_same_v<T, SharedIntrusiveAdoptNoIncrementTag>; std::is_same_v<T, SharedIntrusiveAdoptNoIncrementTag>;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -444,7 +443,8 @@ make_SharedIntrusive(Args&&... args)
auto p = new TT(std::forward<Args>(args)...); auto p = new TT(std::forward<Args>(args)...);
static_assert( static_assert(
noexcept(SharedIntrusive<TT>(std::declval<TT*>(), std::declval<SharedIntrusiveAdoptNoIncrementTag>())), noexcept(SharedIntrusive<TT>(
std::declval<TT*>(), std::declval<SharedIntrusiveAdoptNoIncrementTag>())),
"SharedIntrusive constructor should not throw or this can leak " "SharedIntrusive constructor should not throw or this can leak "
"memory"); "memory");
@@ -485,4 +485,3 @@ dynamic_pointer_cast(TT const& v)
} }
} // namespace intr_ptr } // namespace intr_ptr
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_INTRUSIVEPOINTER_IPP_INCLUDED #pragma once
#define XRPL_BASICS_INTRUSIVEPOINTER_IPP_INCLUDED
#include <xrpl/basics/IntrusivePointer.h> #include <xrpl/basics/IntrusivePointer.h>
#include <xrpl/basics/IntrusiveRefCounts.h> #include <xrpl/basics/IntrusiveRefCounts.h>
@@ -209,7 +208,8 @@ SharedIntrusive<T>::operator->() const noexcept
} }
template <class T> template <class T>
SharedIntrusive<T>::operator bool() const noexcept SharedIntrusive<T>::
operator bool() const noexcept
{ {
return bool(unsafeGetRawPtr()); return bool(unsafeGetRawPtr());
} }
@@ -504,7 +504,8 @@ SharedWeakUnion<T>::getStrong() const
} }
template <class T> template <class T>
SharedWeakUnion<T>::operator bool() const noexcept SharedWeakUnion<T>::
operator bool() const noexcept
{ {
return bool(get()); return bool(get());
} }
@@ -703,4 +704,3 @@ SharedWeakUnion<T>::unsafeReleaseNoStore()
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_INTRUSIVEREFCOUNTS_H_INCLUDED #pragma once
#define XRPL_BASICS_INTRUSIVEREFCOUNTS_H_INCLUDED
#include <xrpl/beast/utility/instrumentation.h> #include <xrpl/beast/utility/instrumentation.h>
@@ -185,7 +184,8 @@ private:
/** Mask that will zero out everything except the weak count. /** Mask that will zero out everything except the weak count.
*/ */
static constexpr FieldType weakMask = (((one << WeakCountNumBits) - 1) << StrongCountNumBits) & valueMask; static constexpr FieldType weakMask =
(((one << WeakCountNumBits) - 1) << StrongCountNumBits) & valueMask;
/** 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
@@ -210,8 +210,10 @@ private:
FieldType FieldType
combinedValue() const noexcept; combinedValue() const noexcept;
static constexpr CountType maxStrongValue = static_cast<CountType>((one << StrongCountNumBits) - 1); static constexpr CountType maxStrongValue =
static constexpr CountType maxWeakValue = static_cast<CountType>((one << WeakCountNumBits) - 1); static_cast<CountType>((one << StrongCountNumBits) - 1);
static constexpr CountType maxWeakValue =
static_cast<CountType>((one << WeakCountNumBits) - 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).
@@ -396,7 +398,8 @@ 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((!(v & valueMask)), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : count must be zero"); XRPL_ASSERT(
(!(v & valueMask)), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : count must be zero");
auto t = v & tagMask; auto t = v & tagMask;
XRPL_ASSERT((!t || t == tagMask), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : valid tag"); XRPL_ASSERT((!t || t == tagMask), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : valid tag");
#endif #endif
@@ -434,8 +437,10 @@ IntrusiveRefCounts::RefCountPair::combinedValue() const noexcept
(strong < checkStrongMaxValue && weak < checkWeakMaxValue), (strong < checkStrongMaxValue && weak < checkWeakMaxValue),
"xrpl::IntrusiveRefCounts::RefCountPair::combinedValue : inputs " "xrpl::IntrusiveRefCounts::RefCountPair::combinedValue : inputs "
"inside range"); "inside range");
return (static_cast<IntrusiveRefCounts::FieldType>(weak) << IntrusiveRefCounts::StrongCountNumBits) | return (static_cast<IntrusiveRefCounts::FieldType>(weak)
static_cast<IntrusiveRefCounts::FieldType>(strong) | partialDestroyStartedBit | partialDestroyFinishedBit; << IntrusiveRefCounts::StrongCountNumBits) |
static_cast<IntrusiveRefCounts::FieldType>(strong) | partialDestroyStartedBit |
partialDestroyFinishedBit;
} }
template <class T> template <class T>
@@ -443,7 +448,8 @@ inline void
partialDestructorFinished(T** o) partialDestructorFinished(T** o)
{ {
T& self = **o; T& self = **o;
IntrusiveRefCounts::RefCountPair p = self.refCounts.fetch_or(IntrusiveRefCounts::partialDestroyFinishedMask); IntrusiveRefCounts::RefCountPair p =
self.refCounts.fetch_or(IntrusiveRefCounts::partialDestroyFinishedMask);
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");
@@ -461,4 +467,3 @@ partialDestructorFinished(T** o)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_KEYCACHE_H #pragma once
#define XRPL_BASICS_KEYCACHE_H
#include <xrpl/basics/TaggedCache.h> #include <xrpl/basics/TaggedCache.h>
#include <xrpl/basics/base_uint.h> #include <xrpl/basics/base_uint.h>
@@ -9,5 +8,3 @@ namespace xrpl {
using KeyCache = TaggedCache<uint256, int, true>; using KeyCache = TaggedCache<uint256, int, true>;
} // namespace xrpl } // namespace xrpl
#endif // XRPL_BASICS_KEYCACHE_H

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_LOCALVALUE_H_INCLUDED #pragma once
#define XRPL_BASICS_LOCALVALUE_H_INCLUDED
#include <boost/thread/tss.hpp> #include <boost/thread/tss.hpp>
@@ -104,8 +103,7 @@ LocalValue<T>::operator*()
} }
return *reinterpret_cast<T*>( return *reinterpret_cast<T*>(
lvs->values.emplace(this, std::make_unique<detail::LocalValues::Value<T>>(t_)).first->second->get()); lvs->values.emplace(this, std::make_unique<detail::LocalValues::Value<T>>(t_))
.first->second->get());
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_LOG_H_INCLUDED #pragma once
#define XRPL_BASICS_LOG_H_INCLUDED
#include <xrpl/basics/UnorderedContainers.h> #include <xrpl/basics/UnorderedContainers.h>
#include <xrpl/beast/utility/Journal.h> #include <xrpl/beast/utility/Journal.h>
@@ -171,7 +170,11 @@ public:
partition_severities() const; partition_severities() const;
void void
write(beast::severities::Severity level, std::string const& partition, std::string const& text, bool console); write(
beast::severities::Severity level,
std::string const& partition,
std::string const& text,
bool console);
std::string std::string
rotate(); rotate();
@@ -258,5 +261,3 @@ beast::Journal
debugLog(); debugLog();
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_MATHUTILITIES_H_INCLUDED #pragma once
#define XRPL_BASICS_MATHUTILITIES_H_INCLUDED
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@@ -45,5 +44,3 @@ static_assert(calculatePercent(50'000'001, 100'000'000) == 51);
static_assert(calculatePercent(99'999'999, 100'000'000) == 100); static_assert(calculatePercent(99'999'999, 100'000'000) == 100);
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_NUMBER_H_INCLUDED #pragma once
#define XRPL_BASICS_NUMBER_H_INCLUDED
#include <xrpl/beast/utility/instrumentation.h> #include <xrpl/beast/utility/instrumentation.h>
@@ -241,7 +240,11 @@ public:
Number(rep mantissa); Number(rep mantissa);
explicit Number(rep mantissa, int exponent); explicit Number(rep mantissa, int exponent);
explicit constexpr Number(bool negative, internalrep mantissa, int exponent, unchecked) noexcept; explicit constexpr Number(
bool negative,
internalrep mantissa,
int exponent,
unchecked) noexcept;
// Assume unsigned values are... unsigned. i.e. positive // Assume unsigned values are... unsigned. i.e. positive
explicit constexpr Number(internalrep mantissa, int exponent, unchecked) noexcept; explicit constexpr Number(internalrep mantissa, int exponent, unchecked) noexcept;
// Only unit tests are expected to use this ctor // Only unit tests are expected to use this ctor
@@ -295,7 +298,8 @@ public:
friend constexpr bool friend constexpr bool
operator==(Number const& x, Number const& y) noexcept operator==(Number const& x, Number const& y) noexcept
{ {
return x.negative_ == y.negative_ && x.mantissa_ == y.mantissa_ && x.exponent_ == y.exponent_; return x.negative_ == y.negative_ && x.mantissa_ == y.mantissa_ &&
x.exponent_ == y.exponent_;
} }
friend constexpr bool friend constexpr bool
@@ -503,7 +507,11 @@ private:
class Guard; class Guard;
}; };
inline constexpr Number::Number(bool negative, internalrep mantissa, int exponent, unchecked) noexcept inline constexpr Number::Number(
bool negative,
internalrep mantissa,
int exponent,
unchecked) noexcept
: negative_(negative), mantissa_{mantissa}, exponent_{exponent} : negative_(negative), mantissa_{mantissa}, exponent_{exponent}
{ {
} }
@@ -521,7 +529,8 @@ inline Number::Number(bool negative, internalrep mantissa, int exponent, normali
normalize(); normalize();
} }
inline Number::Number(internalrep mantissa, int exponent, normalized) : Number(false, mantissa, exponent, normalized{}) inline Number::Number(internalrep mantissa, int exponent, normalized)
: Number(false, mantissa, exponent, normalized{})
{ {
} }
@@ -683,8 +692,8 @@ Number::isnormal() const noexcept
MantissaRange const& range = range_; MantissaRange const& range = range_;
auto const abs_m = mantissa_; auto const abs_m = mantissa_;
return *this == Number{} || return *this == Number{} ||
(range.min <= abs_m && abs_m <= range.max && (abs_m <= maxRep || abs_m % 10 == 0) && minExponent <= exponent_ && (range.min <= abs_m && abs_m <= range.max && (abs_m <= maxRep || abs_m % 10 == 0) &&
exponent_ <= maxExponent); minExponent <= exponent_ && exponent_ <= maxExponent);
} }
template <Integral64 T> template <Integral64 T>
@@ -696,7 +705,10 @@ Number::normalizeToRange(T minMantissa, T maxMantissa) const
int exponent = exponent_; int exponent = exponent_;
if constexpr (std::is_unsigned_v<T>) if constexpr (std::is_unsigned_v<T>)
XRPL_ASSERT_PARTS(!negative, "xrpl::Number::normalizeToRange", "Number is non-negative for unsigned range."); XRPL_ASSERT_PARTS(
!negative,
"xrpl::Number::normalizeToRange",
"Number is non-negative for unsigned range.");
Number::normalize(negative, mantissa, exponent, minMantissa, maxMantissa); Number::normalize(negative, mantissa, exponent, minMantissa, maxMantissa);
auto const sign = negative ? -1 : 1; auto const sign = negative ? -1 : 1;
@@ -782,7 +794,8 @@ class NumberRoundModeGuard
saveNumberRoundMode saved_; saveNumberRoundMode saved_;
public: public:
explicit NumberRoundModeGuard(Number::rounding_mode mode) noexcept : saved_{Number::setround(mode)} explicit NumberRoundModeGuard(Number::rounding_mode mode) noexcept
: saved_{Number::setround(mode)}
{ {
} }
@@ -802,7 +815,8 @@ class NumberMantissaScaleGuard
MantissaRange::mantissa_scale const saved_; MantissaRange::mantissa_scale const saved_;
public: public:
explicit NumberMantissaScaleGuard(MantissaRange::mantissa_scale scale) noexcept : saved_{Number::getMantissaScale()} explicit NumberMantissaScaleGuard(MantissaRange::mantissa_scale scale) noexcept
: saved_{Number::getMantissaScale()}
{ {
Number::setMantissaScale(scale); Number::setMantissaScale(scale);
} }
@@ -819,5 +833,3 @@ public:
}; };
} // namespace xrpl } // namespace xrpl
#endif // XRPL_BASICS_NUMBER_H_INCLUDED

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_RANGESET_H_INCLUDED #pragma once
#define XRPL_BASICS_RANGESET_H_INCLUDED
#include <xrpl/beast/core/LexicalCast.h> #include <xrpl/beast/core/LexicalCast.h>
@@ -173,5 +172,3 @@ prevMissing(RangeSet<T> const& rs, T t, T minVal = 0)
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_RESOLVER_H_INCLUDED #pragma once
#define XRPL_BASICS_RESOLVER_H_INCLUDED
#include <xrpl/beast/net/IPEndpoint.h> #include <xrpl/beast/net/IPEndpoint.h>
@@ -45,5 +44,3 @@ public:
}; };
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_RESOLVERASIO_H_INCLUDED #pragma once
#define XRPL_BASICS_RESOLVERASIO_H_INCLUDED
#include <xrpl/basics/Resolver.h> #include <xrpl/basics/Resolver.h>
#include <xrpl/beast/utility/Journal.h> #include <xrpl/beast/utility/Journal.h>
@@ -18,5 +17,3 @@ public:
}; };
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_SHAMAP_HASH_H_INCLUDED #pragma once
#define XRPL_BASICS_SHAMAP_HASH_H_INCLUDED
#include <xrpl/basics/base_uint.h> #include <xrpl/basics/base_uint.h>
#include <xrpl/basics/partitioned_unordered_map.h> #include <xrpl/basics/partitioned_unordered_map.h>
@@ -98,5 +97,3 @@ extract(SHAMapHash const& key)
} }
} // namespace xrpl } // namespace xrpl
#endif // XRPL_BASICS_SHAMAP_HASH_H_INCLUDED

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_SHAREDWEAKCACHEPOINTER_H_INCLUDED #pragma once
#define XRPL_BASICS_SHAREDWEAKCACHEPOINTER_H_INCLUDED
#include <memory> #include <memory>
#include <variant> #include <variant>
@@ -113,4 +112,3 @@ private:
std::variant<std::shared_ptr<T>, std::weak_ptr<T>> combo_; std::variant<std::shared_ptr<T>, std::weak_ptr<T>> combo_;
}; };
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_SHAREDWEAKCACHEPOINTER_IPP_INCLUDED #pragma once
#define XRPL_BASICS_SHAREDWEAKCACHEPOINTER_IPP_INCLUDED
#include <xrpl/basics/SharedWeakCachePointer.h> #include <xrpl/basics/SharedWeakCachePointer.h>
@@ -20,7 +19,8 @@ SharedWeakCachePointer<T>::SharedWeakCachePointer(SharedWeakCachePointer&& rhs)
template <class T> template <class T>
template <class TT> template <class TT>
requires std::convertible_to<TT*, T*> requires std::convertible_to<TT*, T*>
SharedWeakCachePointer<T>::SharedWeakCachePointer(std::shared_ptr<TT>&& rhs) : combo_{std::move(rhs)} SharedWeakCachePointer<T>::SharedWeakCachePointer(std::shared_ptr<TT>&& rhs)
: combo_{std::move(rhs)}
{ {
} }
@@ -64,7 +64,8 @@ SharedWeakCachePointer<T>::getStrong() const
} }
template <class T> template <class T>
SharedWeakCachePointer<T>::operator bool() const noexcept SharedWeakCachePointer<T>::
operator bool() const noexcept
{ {
return !!std::get_if<std::shared_ptr<T>>(&combo_); return !!std::get_if<std::shared_ptr<T>>(&combo_);
} }
@@ -164,4 +165,3 @@ SharedWeakCachePointer<T>::convertToWeak()
return false; return false;
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,7 +1,6 @@
// Copyright (c) 2022, Nikolaos D. Bougalis <nikb@bougalis.net> // Copyright (c) 2022, Nikolaos D. Bougalis <nikb@bougalis.net>
#ifndef XRPL_BASICS_SLABALLOCATOR_H_INCLUDED #pragma once
#define XRPL_BASICS_SLABALLOCATOR_H_INCLUDED
#include <xrpl/basics/ByteUtilities.h> #include <xrpl/basics/ByteUtilities.h>
#include <xrpl/beast/type_name.h> #include <xrpl/beast/type_name.h>
@@ -156,13 +155,17 @@ public:
contexts (e.g. when minimal memory usage is needed) and contexts (e.g. when minimal memory usage is needed) and
allows for graceful failure. allows for graceful failure.
*/ */
constexpr explicit SlabAllocator(std::size_t extra, std::size_t alloc = 0, std::size_t align = 0) constexpr explicit SlabAllocator(
std::size_t extra,
std::size_t alloc = 0,
std::size_t align = 0)
: itemAlignment_(align ? align : alignof(Type)) : itemAlignment_(align ? align : alignof(Type))
, itemSize_(boost::alignment::align_up(sizeof(Type) + extra, itemAlignment_)) , itemSize_(boost::alignment::align_up(sizeof(Type) + extra, itemAlignment_))
, slabSize_(alloc) , slabSize_(alloc)
{ {
XRPL_ASSERT( XRPL_ASSERT(
(itemAlignment_ & (itemAlignment_ - 1)) == 0, "xrpl::SlabAllocator::SlabAllocator : valid alignment"); (itemAlignment_ & (itemAlignment_ - 1)) == 0,
"xrpl::SlabAllocator::SlabAllocator : valid alignment");
} }
SlabAllocator(SlabAllocator const& other) = delete; SlabAllocator(SlabAllocator const& other) = delete;
@@ -216,7 +219,7 @@ public:
// clang-format off // clang-format off
if (!buf) [[unlikely]] if (!buf) [[unlikely]]
return nullptr; return nullptr;
// clang-format on // clang-format on
#if BOOST_OS_LINUX #if BOOST_OS_LINUX
// When allocating large blocks, attempt to leverage Linux's // When allocating large blocks, attempt to leverage Linux's
@@ -229,7 +232,8 @@ public:
// We need to carve out a bit of memory for the slab header // We need to carve out a bit of memory for the slab header
// and then align the rest appropriately: // and then align the rest appropriately:
auto slabData = reinterpret_cast<void*>(reinterpret_cast<std::uint8_t*>(buf) + sizeof(SlabBlock)); auto slabData =
reinterpret_cast<void*>(reinterpret_cast<std::uint8_t*>(buf) + sizeof(SlabBlock));
auto slabSize = size - sizeof(SlabBlock); auto slabSize = size - sizeof(SlabBlock);
// This operation is essentially guaranteed not to fail but // This operation is essentially guaranteed not to fail but
@@ -240,10 +244,12 @@ public:
return nullptr; return nullptr;
} }
slab = new (buf) SlabBlock(slabs_.load(), reinterpret_cast<std::uint8_t*>(slabData), slabSize, itemSize_); slab = new (buf) SlabBlock(
slabs_.load(), reinterpret_cast<std::uint8_t*>(slabData), slabSize, itemSize_);
// Link the new slab // Link the new slab
while (!slabs_.compare_exchange_weak(slab->next_, slab, std::memory_order_release, std::memory_order_relaxed)) while (!slabs_.compare_exchange_weak(
slab->next_, slab, std::memory_order_release, std::memory_order_relaxed))
{ {
; // Nothing to do ; // Nothing to do
} }
@@ -300,7 +306,10 @@ public:
std::size_t align; std::size_t align;
public: public:
constexpr SlabConfig(std::size_t extra_, std::size_t alloc_ = 0, std::size_t align_ = alignof(Type)) constexpr SlabConfig(
std::size_t extra_,
std::size_t alloc_ = 0,
std::size_t align_ = alignof(Type))
: extra(extra_), alloc(alloc_), align(align_) : extra(extra_), alloc(alloc_), align(align_)
{ {
} }
@@ -310,15 +319,18 @@ public:
{ {
// Ensure that the specified allocators are sorted from smallest to // Ensure that the specified allocators are sorted from smallest to
// largest by size: // largest by size:
std::sort( std::sort(std::begin(cfg), std::end(cfg), [](SlabConfig const& a, SlabConfig const& b) {
std::begin(cfg), std::end(cfg), [](SlabConfig const& a, SlabConfig const& b) { return a.extra < b.extra; }); return a.extra < b.extra;
});
// We should never have two slabs of the same size // We should never have two slabs of the same size
if (std::adjacent_find(std::begin(cfg), std::end(cfg), [](SlabConfig const& a, SlabConfig const& b) { if (std::adjacent_find(
return a.extra == b.extra; std::begin(cfg), std::end(cfg), [](SlabConfig const& a, SlabConfig const& b) {
}) != cfg.end()) return a.extra == b.extra;
}) != cfg.end())
{ {
throw std::runtime_error("SlabAllocatorSet<" + beast::type_name<Type>() + ">: duplicate slab size"); throw std::runtime_error(
"SlabAllocatorSet<" + beast::type_name<Type>() + ">: duplicate slab size");
} }
for (auto const& c : cfg) for (auto const& c : cfg)
@@ -386,5 +398,3 @@ public:
}; };
} // namespace xrpl } // namespace xrpl
#endif // XRPL_BASICS_SLABALLOCATOR_H_INCLUDED

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_SLICE_H_INCLUDED #pragma once
#define XRPL_BASICS_SLICE_H_INCLUDED
#include <xrpl/basics/contract.h> #include <xrpl/basics/contract.h>
#include <xrpl/basics/strHex.h> #include <xrpl/basics/strHex.h>
@@ -41,7 +40,8 @@ public:
operator=(Slice const&) noexcept = default; operator=(Slice const&) noexcept = default;
/** Create a slice pointing to existing memory. */ /** Create a slice pointing to existing memory. */
Slice(void const* data, std::size_t size) noexcept : data_(reinterpret_cast<std::uint8_t const*>(data)), size_(size) Slice(void const* data, std::size_t size) noexcept
: data_(reinterpret_cast<std::uint8_t const*>(data)), size_(size)
{ {
} }
@@ -198,7 +198,8 @@ operator!=(Slice const& lhs, Slice const& rhs) noexcept
inline bool inline bool
operator<(Slice const& lhs, Slice const& rhs) noexcept operator<(Slice const& lhs, Slice const& rhs) noexcept
{ {
return std::lexicographical_compare(lhs.data(), lhs.data() + lhs.size(), rhs.data(), rhs.data() + rhs.size()); return std::lexicographical_compare(
lhs.data(), lhs.data() + lhs.size(), rhs.data(), rhs.data() + rhs.size());
} }
template <class Stream> template <class Stream>
@@ -231,5 +232,3 @@ makeSlice(std::basic_string<char, Traits, Alloc> const& s)
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_STRINGUTILITIES_H_INCLUDED #pragma once
#define XRPL_BASICS_STRINGUTILITIES_H_INCLUDED
#include <xrpl/basics/Blob.h> #include <xrpl/basics/Blob.h>
#include <xrpl/basics/strHex.h> #include <xrpl/basics/strHex.h>
@@ -109,7 +108,8 @@ struct parsedURL
bool bool
operator==(parsedURL const& other) const operator==(parsedURL const& other) const
{ {
return scheme == other.scheme && domain == other.domain && port == other.port && path == other.path; return scheme == other.scheme && domain == other.domain && port == other.port &&
path == other.path;
} }
}; };
@@ -132,5 +132,3 @@ bool
isProperlyFormedTomlDomain(std::string_view domain); isProperlyFormedTomlDomain(std::string_view domain);
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_TAGGEDCACHE_H_INCLUDED #pragma once
#define XRPL_BASICS_TAGGEDCACHE_H_INCLUDED
#include <xrpl/basics/IntrusivePointer.h> #include <xrpl/basics/IntrusivePointer.h>
#include <xrpl/basics/Log.h> #include <xrpl/basics/Log.h>
@@ -176,7 +175,10 @@ private:
struct Stats struct Stats
{ {
template <class Handler> template <class Handler>
Stats(std::string const& prefix, Handler const& handler, beast::insight::Collector::ptr const& collector) Stats(
std::string const& prefix,
Handler const& handler,
beast::insight::Collector::ptr const& collector)
: hook(collector->make_hook(handler)) : hook(collector->make_hook(handler))
, size(collector->make_gauge(prefix, "size")) , size(collector->make_gauge(prefix, "size"))
, hit_rate(collector->make_gauge(prefix, "hit_rate")) , hit_rate(collector->make_gauge(prefix, "hit_rate"))
@@ -198,7 +200,8 @@ private:
public: public:
clock_type::time_point last_access; clock_type::time_point last_access;
explicit KeyOnlyEntry(clock_type::time_point const& last_access_) : last_access(last_access_) explicit KeyOnlyEntry(clock_type::time_point const& last_access_)
: last_access(last_access_)
{ {
} }
@@ -298,5 +301,3 @@ private:
}; };
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_TAGGEDCACHE_IPP_INCLUDED #pragma once
#define XRPL_BASICS_TAGGEDCACHE_IPP_INCLUDED
#include <xrpl/basics/IntrusivePointer.ipp> #include <xrpl/basics/IntrusivePointer.ipp>
#include <xrpl/basics/TaggedCache.h> #include <xrpl/basics/TaggedCache.h>
@@ -15,13 +14,22 @@ template <
class Hash, class Hash,
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::TaggedCache( inline TaggedCache<
std::string const& name, Key,
int size, T,
clock_type::duration expiration, IsKeyCache,
clock_type& clock, SharedWeakUnionPointer,
beast::Journal journal, SharedPointerType,
beast::insight::Collector::ptr const& collector) Hash,
KeyEqual,
Mutex>::
TaggedCache(
std::string const& name,
int size,
clock_type::duration expiration,
clock_type& clock,
beast::Journal journal,
beast::insight::Collector::ptr const& collector)
: m_journal(journal) : m_journal(journal)
, m_clock(clock) , m_clock(clock)
, m_stats(name, std::bind(&TaggedCache::collect_metrics, this), collector) , m_stats(name, std::bind(&TaggedCache::collect_metrics, this), collector)
@@ -44,8 +52,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline auto inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::clock() TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
-> clock_type& clock() -> clock_type&
{ {
return m_clock; return m_clock;
} }
@@ -60,7 +68,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline std::size_t inline std::size_t
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::size() const TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
size() const
{ {
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
return m_cache.size(); return m_cache.size();
@@ -76,7 +85,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline int inline int
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::getCacheSize() const TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
getCacheSize() const
{ {
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
return m_cache_count; return m_cache_count;
@@ -92,7 +102,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline int inline int
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::getTrackSize() const TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
getTrackSize() const
{ {
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
return m_cache.size(); return m_cache.size();
@@ -108,7 +119,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline float inline float
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::getHitRate() TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
getHitRate()
{ {
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
auto const total = static_cast<float>(m_hits + m_misses); auto const total = static_cast<float>(m_hits + m_misses);
@@ -125,7 +137,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline void inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::clear() TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
clear()
{ {
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
m_cache.clear(); m_cache.clear();
@@ -142,7 +155,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline void inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::reset() TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
reset()
{ {
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
m_cache.clear(); m_cache.clear();
@@ -162,8 +176,8 @@ template <
class Mutex> class Mutex>
template <class KeyComparable> template <class KeyComparable>
inline bool inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::touch_if_exists( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
KeyComparable const& key) touch_if_exists(KeyComparable const& key)
{ {
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
auto const iter(m_cache.find(key)); auto const iter(m_cache.find(key));
@@ -187,7 +201,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline void inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::sweep() TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
sweep()
{ {
// Keep references to all the stuff we sweep // Keep references to all the stuff we sweep
// For performance, each worker thread should exit before the swept data // For performance, each worker thread should exit before the swept data
@@ -213,8 +228,9 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (when_expire > (now - minimumAge)) if (when_expire > (now - minimumAge))
when_expire = now - minimumAge; when_expire = now - minimumAge;
JLOG(m_journal.trace()) << m_name << " is growing fast " << m_cache.size() << " of " << m_target_size JLOG(m_journal.trace())
<< " aging at " << (now - when_expire).count() << " of " << m_target_age.count(); << m_name << " is growing fast " << m_cache.size() << " of " << m_target_size
<< " aging at " << (now - when_expire).count() << " of " << m_target_age.count();
} }
std::vector<std::thread> workers; std::vector<std::thread> workers;
@@ -223,7 +239,8 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
for (std::size_t p = 0; p < m_cache.partitions(); ++p) for (std::size_t p = 0; p < m_cache.partitions(); ++p)
{ {
workers.push_back(sweepHelper(when_expire, now, m_cache.map()[p], allStuffToSweep[p], allRemovals, lock)); workers.push_back(sweepHelper(
when_expire, now, m_cache.map()[p], allStuffToSweep[p], allRemovals, lock));
} }
for (std::thread& worker : workers) for (std::thread& worker : workers)
worker.join(); worker.join();
@@ -232,10 +249,11 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
} }
// At this point allStuffToSweep will go out of scope outside the lock // At this point allStuffToSweep will go out of scope outside the lock
// and decrement the reference count on each strong pointer. // and decrement the reference count on each strong pointer.
JLOG(m_journal.debug()) JLOG(m_journal.debug()) << m_name << " TaggedCache sweep lock duration "
<< m_name << " TaggedCache sweep lock duration " << std::chrono::duration_cast<std::chrono::milliseconds>(
<< std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count() std::chrono::steady_clock::now() - start)
<< "ms"; .count()
<< "ms";
} }
template < template <
@@ -248,9 +266,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline bool inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::del( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
key_type const& key, del(key_type const& key, bool valid)
bool valid)
{ {
// Remove from cache, if !valid, remove from map too. Returns true if // Remove from cache, if !valid, remove from map too. Returns true if
// removed from cache // removed from cache
@@ -289,10 +306,8 @@ template <
class Mutex> class Mutex>
template <class R> template <class R>
inline bool inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::canonicalize( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
key_type const& key, canonicalize(key_type const& key, SharedPointerType& data, R&& replaceCallback)
SharedPointerType& data,
R&& replaceCallback)
{ {
// Return canonical value, store if needed, refresh in cache // Return canonical value, store if needed, refresh in cache
// Return values: true=we had the data already // Return values: true=we had the data already
@@ -303,7 +318,9 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (cit == m_cache.end()) if (cit == m_cache.end())
{ {
m_cache.emplace( m_cache.emplace(
std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(m_clock.now(), data)); std::piecewise_construct,
std::forward_as_tuple(key),
std::forward_as_tuple(m_clock.now(), data));
++m_cache_count; ++m_cache_count;
return false; return false;
} }
@@ -405,8 +422,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline SharedPointerType inline SharedPointerType
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::fetch( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
key_type const& key) fetch(key_type const& key)
{ {
std::lock_guard<mutex_type> l(m_mutex); std::lock_guard<mutex_type> l(m_mutex);
auto ret = initialFetch(key, l); auto ret = initialFetch(key, l);
@@ -426,9 +443,8 @@ template <
class Mutex> class Mutex>
template <class ReturnType> template <class ReturnType>
inline auto inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::insert( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
key_type const& key, insert(key_type const& key, T const& value) -> std::enable_if_t<!IsKeyCache, ReturnType>
T const& value) -> std::enable_if_t<!IsKeyCache, ReturnType>
{ {
static_assert( static_assert(
std::is_same_v<std::shared_ptr<T>, SharedPointerType> || std::is_same_v<std::shared_ptr<T>, SharedPointerType> ||
@@ -457,13 +473,13 @@ template <
class Mutex> class Mutex>
template <class ReturnType> template <class ReturnType>
inline auto inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::insert( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
key_type const& key) -> std::enable_if_t<IsKeyCache, ReturnType> insert(key_type const& key) -> std::enable_if_t<IsKeyCache, ReturnType>
{ {
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
clock_type::time_point const now(m_clock.now()); clock_type::time_point const now(m_clock.now());
auto [it, inserted] = auto [it, inserted] = m_cache.emplace(
m_cache.emplace(std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(now)); std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(now));
if (!inserted) if (!inserted)
it->second.last_access = now; it->second.last_access = now;
return inserted; return inserted;
@@ -479,9 +495,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline bool inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::retrieve( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
key_type const& key, retrieve(key_type const& key, T& data)
T& data)
{ {
// retrieve the value of the stored data // retrieve the value of the stored data
auto entry = fetch(key); auto entry = fetch(key);
@@ -503,8 +518,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline auto inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::peekMutex() TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
-> mutex_type& peekMutex() -> mutex_type&
{ {
return m_mutex; return m_mutex;
} }
@@ -519,8 +534,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline auto inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::getKeys() const TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
-> std::vector<key_type> getKeys() const -> std::vector<key_type>
{ {
std::vector<key_type> v; std::vector<key_type> v;
@@ -544,7 +559,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline double inline double
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::rate() const TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
rate() const
{ {
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
auto const tot = m_hits + m_misses; auto const tot = m_hits + m_misses;
@@ -564,9 +580,8 @@ template <
class Mutex> class Mutex>
template <class Handler> template <class Handler>
inline SharedPointerType inline SharedPointerType
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::fetch( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
key_type const& digest, fetch(key_type const& digest, Handler const& h)
Handler const& h)
{ {
{ {
std::lock_guard l(m_mutex); std::lock_guard l(m_mutex);
@@ -597,9 +612,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline SharedPointerType inline SharedPointerType
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::initialFetch( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
key_type const& key, initialFetch(key_type const& key, std::lock_guard<mutex_type> const& l)
std::lock_guard<mutex_type> const& l)
{ {
auto cit = m_cache.find(key); auto cit = m_cache.find(key);
if (cit == m_cache.end()) if (cit == m_cache.end())
@@ -635,7 +649,8 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline void inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::collect_metrics() TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
collect_metrics()
{ {
m_stats.size.set(getCacheSize()); m_stats.size.set(getCacheSize());
@@ -661,13 +676,14 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline std::thread inline std::thread
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::sweepHelper( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
clock_type::time_point const& when_expire, sweepHelper(
[[maybe_unused]] clock_type::time_point const& now, clock_type::time_point const& when_expire,
typename KeyValueCacheType::map_type& partition, [[maybe_unused]] clock_type::time_point const& now,
SweptPointersVector& stuffToSweep, typename KeyValueCacheType::map_type& partition,
std::atomic<int>& allRemovals, SweptPointersVector& stuffToSweep,
std::lock_guard<std::recursive_mutex> const&) std::atomic<int>& allRemovals,
std::lock_guard<std::recursive_mutex> const&)
{ {
return std::thread([&, this]() { return std::thread([&, this]() {
int cacheRemovals = 0; int cacheRemovals = 0;
@@ -721,8 +737,9 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (mapRemovals || cacheRemovals) if (mapRemovals || cacheRemovals)
{ {
JLOG(m_journal.debug()) << "TaggedCache partition sweep " << m_name << ": cache = " << partition.size() JLOG(m_journal.debug())
<< "-" << cacheRemovals << ", map-=" << mapRemovals; << "TaggedCache partition sweep " << m_name << ": cache = " << partition.size()
<< "-" << cacheRemovals << ", map-=" << mapRemovals;
} }
allRemovals += cacheRemovals; allRemovals += cacheRemovals;
@@ -739,13 +756,14 @@ template <
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
inline std::thread inline std::thread
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::sweepHelper( TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
clock_type::time_point const& when_expire, sweepHelper(
clock_type::time_point const& now, clock_type::time_point const& when_expire,
typename KeyOnlyCacheType::map_type& partition, clock_type::time_point const& now,
SweptPointersVector&, typename KeyOnlyCacheType::map_type& partition,
std::atomic<int>& allRemovals, SweptPointersVector&,
std::lock_guard<std::recursive_mutex> const&) std::atomic<int>& allRemovals,
std::lock_guard<std::recursive_mutex> const&)
{ {
return std::thread([&, this]() { return std::thread([&, this]() {
int cacheRemovals = 0; int cacheRemovals = 0;
@@ -775,8 +793,9 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (mapRemovals || cacheRemovals) if (mapRemovals || cacheRemovals)
{ {
JLOG(m_journal.debug()) << "TaggedCache partition sweep " << m_name << ": cache = " << partition.size() JLOG(m_journal.debug())
<< "-" << cacheRemovals << ", map-=" << mapRemovals; << "TaggedCache partition sweep " << m_name << ": cache = " << partition.size()
<< "-" << cacheRemovals << ", map-=" << mapRemovals;
} }
allRemovals += cacheRemovals; allRemovals += cacheRemovals;
@@ -784,5 +803,3 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_TOSTRING_H_INCLUDED #pragma once
#define XRPL_BASICS_TOSTRING_H_INCLUDED
#include <string> #include <string>
#include <type_traits> #include <type_traits>
@@ -44,5 +43,3 @@ to_string(char const* s)
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_UNORDEREDCONTAINERS_H_INCLUDED #pragma once
#define XRPL_BASICS_UNORDEREDCONTAINERS_H_INCLUDED
#include <xrpl/basics/hardened_hash.h> #include <xrpl/basics/hardened_hash.h>
#include <xrpl/basics/partitioned_unordered_map.h> #include <xrpl/basics/partitioned_unordered_map.h>
@@ -99,5 +98,3 @@ template <
using hardened_hash_multiset = std::unordered_multiset<Value, Hash, Pred, Allocator>; using hardened_hash_multiset = std::unordered_multiset<Value, Hash, Pred, Allocator>;
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_UPTIMETIMER_H_INCLUDED #pragma once
#define XRPL_BASICS_UPTIMETIMER_H_INCLUDED
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
@@ -46,5 +45,3 @@ private:
}; };
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_ALGORITHM_H_INCLUDED #pragma once
#define XRPL_ALGORITHM_H_INCLUDED
#include <utility> #include <utility>
@@ -52,7 +51,13 @@ generalized_set_intersection(
// std::set_intersection. // std::set_intersection.
template <class FwdIter1, class InputIter2, class Pred, class Comp> template <class FwdIter1, class InputIter2, class Pred, class Comp>
FwdIter1 FwdIter1
remove_if_intersect_or_match(FwdIter1 first1, FwdIter1 last1, InputIter2 first2, InputIter2 last2, Pred pred, Comp comp) remove_if_intersect_or_match(
FwdIter1 first1,
FwdIter1 last1,
InputIter2 first2,
InputIter2 last2,
Pred pred,
Comp comp)
{ {
// [original-first1, current-first1) is the set of elements to be preserved. // [original-first1, current-first1) is the set of elements to be preserved.
// [current-first1, i) is the set of elements that have been removed. // [current-first1, i) is the set of elements that have been removed.
@@ -90,5 +95,3 @@ remove_if_intersect_or_match(FwdIter1 first1, FwdIter1 last1, InputIter2 first2,
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -32,8 +32,7 @@
*/ */
#ifndef XRPL_BASICS_BASE64_H_INCLUDED #pragma once
#define XRPL_BASICS_BASE64_H_INCLUDED
#include <cstdint> #include <cstdint>
#include <string> #include <string>
@@ -53,5 +52,3 @@ std::string
base64_decode(std::string_view data); base64_decode(std::string_view data);
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -3,8 +3,7 @@
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
#ifndef XRPL_BASICS_BASE_UINT_H_INCLUDED #pragma once
#define XRPL_BASICS_BASE_UINT_H_INCLUDED
#include <xrpl/basics/Expected.h> #include <xrpl/basics/Expected.h>
#include <xrpl/basics/Slice.h> #include <xrpl/basics/Slice.h>
@@ -215,7 +214,8 @@ private:
std::uint32_t accum = {}; std::uint32_t accum = {};
for (std::uint32_t shift : {4u, 0u, 12u, 8u, 20u, 16u, 28u, 24u}) for (std::uint32_t shift : {4u, 0u, 12u, 8u, 20u, 16u, 28u, 24u})
{ {
if (auto const result = hexCharToUInt(*in++, shift, accum); result != ParseResult::okay) if (auto const result = hexCharToUInt(*in++, shift, accum);
result != ParseResult::okay)
return Unexpected(result); return Unexpected(result);
} }
ret[i++] = accum; ret[i++] = accum;
@@ -254,7 +254,8 @@ public:
// This constructor is intended to be used at compile time since it might // This constructor is intended to be used at compile time since it might
// throw at runtime. Consider declaring this constructor consteval once // throw at runtime. Consider declaring this constructor consteval once
// we get to C++23. // we get to C++23.
explicit constexpr base_uint(std::string_view sv) noexcept(false) : data_(parseFromStringViewThrows(sv)) explicit constexpr base_uint(std::string_view sv) noexcept(false)
: data_(parseFromStringViewThrows(sv))
{ {
} }
@@ -443,7 +444,8 @@ public:
for (int i = WIDTH; i--;) for (int i = WIDTH; i--;)
{ {
std::uint64_t n = carry + boost::endian::big_to_native(data_[i]) + boost::endian::big_to_native(b.data_[i]); std::uint64_t n = carry + boost::endian::big_to_native(data_[i]) +
boost::endian::big_to_native(b.data_[i]);
data_[i] = boost::endian::native_to_big(static_cast<std::uint32_t>(n)); data_[i] = boost::endian::native_to_big(static_cast<std::uint32_t>(n));
carry = n >> 32; carry = n >> 32;
@@ -644,5 +646,3 @@ struct is_uniquely_represented<xrpl::base_uint<Bits, Tag>> : public std::true_ty
}; };
} // namespace beast } // namespace beast
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_CHRONO_H_INCLUDED #pragma once
#define XRPL_BASICS_CHRONO_H_INCLUDED
#include <xrpl/beast/clock/abstract_clock.h> #include <xrpl/beast/clock/abstract_clock.h>
#include <xrpl/beast/clock/basic_seconds_clock.h> #include <xrpl/beast/clock/basic_seconds_clock.h>
@@ -16,7 +15,8 @@ namespace xrpl {
// A few handy aliases // A few handy aliases
using days = std::chrono::duration<int, std::ratio_multiply<std::chrono::hours::period, std::ratio<24>>>; using days =
std::chrono::duration<int, std::ratio_multiply<std::chrono::hours::period, std::ratio<24>>>;
using weeks = std::chrono::duration<int, std::ratio_multiply<days::period, std::ratio<7>>>; using weeks = std::chrono::duration<int, std::ratio_multiply<days::period, std::ratio<7>>>;
@@ -99,5 +99,3 @@ stopwatch()
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_COMPARATORS_H_INCLUDED #pragma once
#define XRPL_BASICS_COMPARATORS_H_INCLUDED
#include <functional> #include <functional>
@@ -53,5 +52,3 @@ using equal_to = std::equal_to<T>;
#endif #endif
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_CONTRACT_H_INCLUDED #pragma once
#define XRPL_BASICS_CONTRACT_H_INCLUDED
#include <xrpl/beast/type_name.h> #include <xrpl/beast/type_name.h>
@@ -36,7 +35,9 @@ template <class E, class... Args>
[[noreturn]] inline void [[noreturn]] inline void
Throw(Args&&... args) Throw(Args&&... args)
{ {
static_assert(std::is_convertible<E*, std::exception*>::value, "Exception must derive from std::exception."); static_assert(
std::is_convertible<E*, std::exception*>::value,
"Exception must derive from std::exception.");
E e(std::forward<Args>(args)...); E e(std::forward<Args>(args)...);
LogThrow(std::string("Throwing exception of type " + beast::type_name<E>() + ": ") + e.what()); LogThrow(std::string("Throwing exception of type " + beast::type_name<E>() + ": ") + e.what());
@@ -48,5 +49,3 @@ Throw(Args&&... args)
LogicError(std::string const& how) noexcept; LogicError(std::string const& how) noexcept;
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_HARDENED_HASH_H_INCLUDED #pragma once
#define XRPL_BASICS_HARDENED_HASH_H_INCLUDED
#include <xrpl/beast/hash/hash_append.h> #include <xrpl/beast/hash/hash_append.h>
#include <xrpl/beast/hash/xxhasher.h> #include <xrpl/beast/hash/xxhasher.h>
@@ -93,5 +92,3 @@ public:
}; };
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef JOIN_H_INCLUDED #pragma once
#define JOIN_H_INCLUDED
#include <string> #include <string>
@@ -24,7 +23,8 @@ public:
Collection const& collection; Collection const& collection;
std::string const delimiter; std::string const delimiter;
explicit CollectionAndDelimiter(Collection const& c, std::string delim) : collection(c), delimiter(std::move(delim)) explicit CollectionAndDelimiter(Collection const& c, std::string delim)
: collection(c), delimiter(std::move(delim))
{ {
} }
@@ -64,7 +64,8 @@ public:
char const* collection; char const* collection;
std::string const delimiter; std::string const delimiter;
explicit CollectionAndDelimiter(char const c[N], std::string delim) : collection(c), delimiter(std::move(delim)) explicit CollectionAndDelimiter(char const c[N], std::string delim)
: collection(c), delimiter(std::move(delim))
{ {
} }
@@ -80,5 +81,3 @@ public:
}; };
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_MAKE_SSLCONTEXT_H_INCLUDED #pragma once
#define XRPL_BASICS_MAKE_SSLCONTEXT_H_INCLUDED
#include <boost/asio/ssl/context.hpp> #include <boost/asio/ssl/context.hpp>
@@ -20,5 +19,3 @@ make_SSLContextAuthed(
std::string const& cipherList); std::string const& cipherList);
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_MULDIV_H_INCLUDED #pragma once
#define XRPL_BASICS_MULDIV_H_INCLUDED
#include <cstdint> #include <cstdint>
#include <limits> #include <limits>
@@ -22,5 +21,3 @@ std::optional<std::uint64_t>
mulDiv(std::uint64_t value, std::uint64_t mul, std::uint64_t div); mulDiv(std::uint64_t value, std::uint64_t mul, std::uint64_t div);
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_PARTITIONED_UNORDERED_MAP_H #pragma once
#define XRPL_BASICS_PARTITIONED_UNORDERED_MAP_H
#include <xrpl/beast/hash/uhash.h> #include <xrpl/beast/hash/uhash.h>
#include <xrpl/beast/utility/instrumentation.h> #include <xrpl/beast/utility/instrumentation.h>
@@ -331,8 +330,8 @@ public:
auto const& key = std::get<0>(keyTuple); auto const& key = std::get<0>(keyTuple);
iterator it(&map_); iterator it(&map_);
it.ait_ = it.map_->begin() + partitioner(key); it.ait_ = it.map_->begin() + partitioner(key);
auto [eit, inserted] = auto [eit, inserted] = it.ait_->emplace(
it.ait_->emplace(std::piecewise_construct, std::forward<T>(keyTuple), std::forward<U>(valueTuple)); std::piecewise_construct, std::forward<T>(keyTuple), std::forward<U>(valueTuple));
it.mit_ = eit; it.mit_ = eit;
return {it, inserted}; return {it, inserted};
} }
@@ -393,5 +392,3 @@ private:
}; };
} // namespace xrpl } // namespace xrpl
#endif // XRPL_BASICS_PARTITIONED_UNORDERED_MAP_H

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_RANDOM_H_INCLUDED #pragma once
#define XRPL_BASICS_RANDOM_H_INCLUDED
#include <xrpl/beast/utility/instrumentation.h> #include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/beast/xor_shift_engine.h> #include <xrpl/beast/xor_shift_engine.h>
@@ -20,7 +19,8 @@ static_assert(
"The Ripple default PRNG engine must return an unsigned integral type."); "The Ripple default PRNG engine must return an unsigned integral type.");
static_assert( static_assert(
std::numeric_limits<beast::xor_shift_engine::result_type>::max() >= std::numeric_limits<std::uint64_t>::max(), std::numeric_limits<beast::xor_shift_engine::result_type>::max() >=
std::numeric_limits<std::uint64_t>::max(),
"The Ripple default PRNG engine return must be at least 64 bits wide."); "The Ripple default PRNG engine return must be at least 64 bits wide.");
#endif #endif
@@ -145,12 +145,14 @@ std::enable_if_t<
Byte> Byte>
rand_byte(Engine& engine) rand_byte(Engine& engine)
{ {
return static_cast<Byte>( return static_cast<Byte>(rand_int<Engine, std::uint32_t>(
rand_int<Engine, std::uint32_t>(engine, std::numeric_limits<Byte>::min(), std::numeric_limits<Byte>::max())); engine, std::numeric_limits<Byte>::min(), std::numeric_limits<Byte>::max()));
} }
template <class Byte = std::uint8_t> template <class Byte = std::uint8_t>
std::enable_if_t<(std::is_same<Byte, unsigned char>::value || std::is_same<Byte, std::uint8_t>::value), Byte> std::enable_if_t<
(std::is_same<Byte, unsigned char>::value || std::is_same<Byte, std::uint8_t>::value),
Byte>
rand_byte() rand_byte()
{ {
return rand_byte<Byte>(default_prng()); return rand_byte<Byte>(default_prng());
@@ -174,5 +176,3 @@ rand_bool()
/** @} */ /** @} */
} // namespace xrpl } // namespace xrpl
#endif // XRPL_BASICS_RANDOM_H_INCLUDED

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_UNITY_ROCKSDB_H_INCLUDED #pragma once
#define XRPL_UNITY_ROCKSDB_H_INCLUDED
#if XRPL_ROCKSDB_AVAILABLE #if XRPL_ROCKSDB_AVAILABLE
// #include <rocksdb2/port/port_posix.h> // #include <rocksdb2/port/port_posix.h>
@@ -28,5 +27,3 @@
#include <rocksdb/write_batch.h> #include <rocksdb/write_batch.h>
#endif #endif
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_SAFE_CAST_H_INCLUDED #pragma once
#define XRPL_BASICS_SAFE_CAST_H_INCLUDED
#include <type_traits> #include <type_traits>
@@ -19,9 +18,12 @@ template <class Dest, class Src>
inline constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest> inline constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest>
safe_cast(Src s) noexcept safe_cast(Src s) noexcept
{ {
static_assert(std::is_signed_v<Dest> || std::is_unsigned_v<Src>, "Cannot cast signed to unsigned"); static_assert(
std::is_signed_v<Dest> || std::is_unsigned_v<Src>, "Cannot cast signed to unsigned");
constexpr unsigned not_same = std::is_signed_v<Dest> != std::is_signed_v<Src>; constexpr unsigned not_same = std::is_signed_v<Dest> != std::is_signed_v<Src>;
static_assert(sizeof(Dest) >= sizeof(Src) + not_same, "Destination is too small to hold all values of source"); static_assert(
sizeof(Dest) >= sizeof(Src) + not_same,
"Destination is too small to hold all values of source");
return static_cast<Dest>(s); return static_cast<Dest>(s);
} }
@@ -69,5 +71,3 @@ unsafe_cast(Src s) noexcept
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_SCOPE_H_INCLUDED #pragma once
#define XRPL_BASICS_SCOPE_H_INCLUDED
#include <xrpl/beast/utility/instrumentation.h> #include <xrpl/beast/utility/instrumentation.h>
@@ -37,7 +36,8 @@ public:
scope_exit(scope_exit&& rhs) noexcept( scope_exit(scope_exit&& rhs) noexcept(
std::is_nothrow_move_constructible_v<EF> || std::is_nothrow_copy_constructible_v<EF>) std::is_nothrow_move_constructible_v<EF> || std::is_nothrow_copy_constructible_v<EF>)
: exit_function_{std::forward<EF>(rhs.exit_function_)}, execute_on_destruction_{rhs.execute_on_destruction_} : exit_function_{std::forward<EF>(rhs.exit_function_)}
, execute_on_destruction_{rhs.execute_on_destruction_}
{ {
rhs.release(); rhs.release();
} }
@@ -48,8 +48,9 @@ public:
template <class EFP> template <class EFP>
explicit scope_exit( explicit scope_exit(
EFP&& f, EFP&& f,
std::enable_if_t<!std::is_same_v<std::remove_cv_t<EFP>, scope_exit> && std::is_constructible_v<EF, EFP>>* = std::enable_if_t<
0) noexcept !std::is_same_v<std::remove_cv_t<EFP>, scope_exit> &&
std::is_constructible_v<EF, EFP>>* = 0) noexcept
: exit_function_{std::forward<EFP>(f)} : exit_function_{std::forward<EFP>(f)}
{ {
static_assert(std::is_nothrow_constructible_v<EF, decltype(std::forward<EFP>(f))>); static_assert(std::is_nothrow_constructible_v<EF, decltype(std::forward<EFP>(f))>);
@@ -94,8 +95,9 @@ public:
template <class EFP> template <class EFP>
explicit scope_fail( explicit scope_fail(
EFP&& f, EFP&& f,
std::enable_if_t<!std::is_same_v<std::remove_cv_t<EFP>, scope_fail> && std::is_constructible_v<EF, EFP>>* = std::enable_if_t<
0) noexcept !std::is_same_v<std::remove_cv_t<EFP>, scope_fail> &&
std::is_constructible_v<EF, EFP>>* = 0) noexcept
: exit_function_{std::forward<EFP>(f)} : exit_function_{std::forward<EFP>(f)}
{ {
static_assert(std::is_nothrow_constructible_v<EF, decltype(std::forward<EFP>(f))>); static_assert(std::is_nothrow_constructible_v<EF, decltype(std::forward<EFP>(f))>);
@@ -140,7 +142,9 @@ public:
template <class EFP> template <class EFP>
explicit scope_success( explicit scope_success(
EFP&& f, EFP&& f,
std::enable_if_t<!std::is_same_v<std::remove_cv_t<EFP>, scope_success> && std::is_constructible_v<EF, EFP>>* = std::enable_if_t<
!std::is_same_v<std::remove_cv_t<EFP>, scope_success> &&
std::is_constructible_v<EF, EFP>>* =
0) noexcept(std::is_nothrow_constructible_v<EF, EFP> || std::is_nothrow_constructible_v<EF, EFP&>) 0) noexcept(std::is_nothrow_constructible_v<EF, EFP> || std::is_nothrow_constructible_v<EF, EFP&>)
: exit_function_{std::forward<EFP>(f)} : exit_function_{std::forward<EFP>(f)}
{ {
@@ -220,5 +224,3 @@ template <class Mutex>
scope_unlock(std::unique_lock<Mutex>&) -> scope_unlock<Mutex>; scope_unlock(std::unique_lock<Mutex>&) -> scope_unlock<Mutex>;
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,7 +1,6 @@
// Copyright (c) 2022, Nikolaos D. Bougalis <nikb@bougalis.net> // Copyright (c) 2022, Nikolaos D. Bougalis <nikb@bougalis.net>
#ifndef XRPL_BASICS_SPINLOCK_H_INCLUDED #pragma once
#define XRPL_BASICS_SPINLOCK_H_INCLUDED
#include <xrpl/beast/utility/instrumentation.h> #include <xrpl/beast/utility/instrumentation.h>
@@ -100,9 +99,12 @@ public:
@note For performance reasons, you should strive to have `lock` be @note For performance reasons, you should strive to have `lock` be
on a cacheline by itself. on a cacheline by itself.
*/ */
packed_spinlock(std::atomic<T>& lock, int index) : bits_(lock), mask_(static_cast<T>(1) << index) packed_spinlock(std::atomic<T>& lock, int index)
: bits_(lock), mask_(static_cast<T>(1) << index)
{ {
XRPL_ASSERT(index >= 0 && (mask_ != 0), "xrpl::packed_spinlock::packed_spinlock : valid index and mask"); XRPL_ASSERT(
index >= 0 && (mask_ != 0),
"xrpl::packed_spinlock::packed_spinlock : valid index and mask");
} }
[[nodiscard]] bool [[nodiscard]] bool
@@ -175,7 +177,10 @@ public:
T expected = 0; T expected = 0;
return lock_.compare_exchange_weak( return lock_.compare_exchange_weak(
expected, std::numeric_limits<T>::max(), std::memory_order_acquire, std::memory_order_relaxed); expected,
std::numeric_limits<T>::max(),
std::memory_order_acquire,
std::memory_order_relaxed);
} }
void void
@@ -201,5 +206,3 @@ public:
/** @} */ /** @} */
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,5 +1,4 @@
#ifndef XRPL_BASICS_STRHEX_H_INCLUDED #pragma once
#define XRPL_BASICS_STRHEX_H_INCLUDED
#include <boost/algorithm/hex.hpp> #include <boost/algorithm/hex.hpp>
#include <boost/endian/conversion.hpp> #include <boost/endian/conversion.hpp>
@@ -11,7 +10,9 @@ std::string
strHex(FwdIt begin, FwdIt end) strHex(FwdIt begin, FwdIt end)
{ {
static_assert( static_assert(
std::is_convertible<typename std::iterator_traits<FwdIt>::iterator_category, std::forward_iterator_tag>::value, std::is_convertible<
typename std::iterator_traits<FwdIt>::iterator_category,
std::forward_iterator_tag>::value,
"FwdIt must be a forward iterator"); "FwdIt must be a forward iterator");
std::string result; std::string result;
result.reserve(2 * std::distance(begin, end)); result.reserve(2 * std::distance(begin, end));
@@ -27,5 +28,3 @@ strHex(T const& from)
} }
} // namespace xrpl } // namespace xrpl
#endif

View File

@@ -1,7 +1,6 @@
// Copyright (c) 2014, Nikolaos D. Bougalis <nikb@bougalis.net> // Copyright (c) 2014, Nikolaos D. Bougalis <nikb@bougalis.net>
#ifndef BEAST_UTILITY_TAGGED_INTEGER_H_INCLUDED #pragma once
#define BEAST_UTILITY_TAGGED_INTEGER_H_INCLUDED
#include <xrpl/beast/hash/hash_append.h> #include <xrpl/beast/hash/hash_append.h>
@@ -24,14 +23,15 @@ namespace xrpl {
allowed arithmetic operations. allowed arithmetic operations.
*/ */
template <class Int, class Tag> template <class Int, class Tag>
class tagged_integer class tagged_integer : boost::totally_ordered<
: boost::totally_ordered< tagged_integer<Int, Tag>,
tagged_integer<Int, Tag>, boost::integer_arithmetic<
boost::integer_arithmetic< tagged_integer<Int, Tag>,
tagged_integer<Int, Tag>, boost::bitwise<
boost::bitwise< tagged_integer<Int, Tag>,
tagged_integer<Int, Tag>, boost::unit_steppable<
boost::unit_steppable<tagged_integer<Int, Tag>, boost::shiftable<tagged_integer<Int, Tag>>>>>> tagged_integer<Int, Tag>,
boost::shiftable<tagged_integer<Int, Tag>>>>>>
{ {
private: private:
Int m_value; Int m_value;
@@ -44,7 +44,8 @@ public:
template < template <
class OtherInt, class OtherInt,
class = typename std::enable_if<std::is_integral<OtherInt>::value && sizeof(OtherInt) <= sizeof(Int)>::type> class = typename std::enable_if<
std::is_integral<OtherInt>::value && sizeof(OtherInt) <= sizeof(Int)>::type>
explicit constexpr tagged_integer(OtherInt value) noexcept : m_value(value) explicit constexpr tagged_integer(OtherInt value) noexcept : m_value(value)
{ {
static_assert(sizeof(tagged_integer) == sizeof(Int), "tagged_integer is adding padding"); static_assert(sizeof(tagged_integer) == sizeof(Int), "tagged_integer is adding padding");
@@ -202,4 +203,3 @@ struct is_contiguously_hashable<xrpl::tagged_integer<Int, Tag>, HashAlgorithm>
}; };
} // namespace beast } // namespace beast
#endif

View File

@@ -1,5 +1,4 @@
#ifndef BEAST_ASIO_IO_LATENCY_PROBE_H_INCLUDED #pragma once
#define BEAST_ASIO_IO_LATENCY_PROBE_H_INCLUDED
#include <xrpl/beast/utility/instrumentation.h> #include <xrpl/beast/utility/instrumentation.h>
@@ -87,7 +86,8 @@ public:
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
if (m_cancel) if (m_cancel)
throw std::logic_error("io_latency_probe is canceled"); throw std::logic_error("io_latency_probe is canceled");
boost::asio::post(m_ios, sample_op<Handler>(std::forward<Handler>(handler), Clock::now(), false, this)); boost::asio::post(
m_ios, sample_op<Handler>(std::forward<Handler>(handler), Clock::now(), false, this));
} }
/** Initiate continuous i/o latency sampling. /** Initiate continuous i/o latency sampling.
@@ -101,7 +101,8 @@ public:
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
if (m_cancel) if (m_cancel)
throw std::logic_error("io_latency_probe is canceled"); throw std::logic_error("io_latency_probe is canceled");
boost::asio::post(m_ios, sample_op<Handler>(std::forward<Handler>(handler), Clock::now(), true, this)); boost::asio::post(
m_ios, sample_op<Handler>(std::forward<Handler>(handler), Clock::now(), true, this));
} }
private: private:
@@ -141,7 +142,11 @@ private:
bool m_repeat; bool m_repeat;
io_latency_probe* m_probe; io_latency_probe* m_probe;
sample_op(Handler const& handler, time_point const& start, bool repeat, io_latency_probe* probe) sample_op(
Handler const& handler,
time_point const& start,
bool repeat,
io_latency_probe* probe)
: m_handler(handler), m_start(start), m_repeat(repeat), m_probe(probe) : m_handler(handler), m_start(start), m_repeat(repeat), m_probe(probe)
{ {
XRPL_ASSERT( XRPL_ASSERT(
@@ -204,12 +209,14 @@ private:
// The latency is too high to maintain the desired // The latency is too high to maintain the desired
// period so don't bother with a timer. // period so don't bother with a timer.
// //
boost::asio::post(m_probe->m_ios, sample_op<Handler>(m_handler, now, m_repeat, m_probe)); boost::asio::post(
m_probe->m_ios, sample_op<Handler>(m_handler, now, m_repeat, m_probe));
} }
else else
{ {
m_probe->m_timer.expires_after(when - now); m_probe->m_timer.expires_after(when - now);
m_probe->m_timer.async_wait(sample_op<Handler>(m_handler, now, m_repeat, m_probe)); m_probe->m_timer.async_wait(
sample_op<Handler>(m_handler, now, m_repeat, m_probe));
} }
} }
} }
@@ -220,11 +227,10 @@ private:
if (!m_probe) if (!m_probe)
return; return;
typename Clock::time_point const now(Clock::now()); typename Clock::time_point const now(Clock::now());
boost::asio::post(m_probe->m_ios, sample_op<Handler>(m_handler, now, m_repeat, m_probe)); boost::asio::post(
m_probe->m_ios, sample_op<Handler>(m_handler, now, m_repeat, m_probe));
} }
}; };
}; };
} // namespace beast } // namespace beast
#endif

View File

@@ -1,5 +1,4 @@
#ifndef BEAST_CHRONO_ABSTRACT_CLOCK_H_INCLUDED #pragma once
#define BEAST_CHRONO_ABSTRACT_CLOCK_H_INCLUDED
namespace beast { namespace beast {
@@ -89,5 +88,3 @@ get_abstract_clock()
} }
} // namespace beast } // namespace beast
#endif

View File

@@ -1,5 +1,4 @@
#ifndef BEAST_CHRONO_BASIC_SECONDS_CLOCK_H_INCLUDED #pragma once
#define BEAST_CHRONO_BASIC_SECONDS_CLOCK_H_INCLUDED
#include <chrono> #include <chrono>
@@ -33,5 +32,3 @@ public:
}; };
} // namespace beast } // namespace beast
#endif

View File

@@ -1,5 +1,4 @@
#ifndef BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED #pragma once
#define BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED
#include <xrpl/beast/clock/abstract_clock.h> #include <xrpl/beast/clock/abstract_clock.h>
#include <xrpl/beast/utility/instrumentation.h> #include <xrpl/beast/utility/instrumentation.h>
@@ -43,7 +42,9 @@ public:
void void
set(time_point const& when) set(time_point const& when)
{ {
XRPL_ASSERT(!Clock::is_steady || when >= now_, "beast::manual_clock::set(time_point) : forward input"); XRPL_ASSERT(
!Clock::is_steady || when >= now_,
"beast::manual_clock::set(time_point) : forward input");
now_ = when; now_ = when;
} }
@@ -61,7 +62,8 @@ public:
advance(std::chrono::duration<Rep, Period> const& elapsed) advance(std::chrono::duration<Rep, Period> const& elapsed)
{ {
XRPL_ASSERT( XRPL_ASSERT(
!Clock::is_steady || (now_ + elapsed) >= now_, "beast::manual_clock::advance(duration) : forward input"); !Clock::is_steady || (now_ + elapsed) >= now_,
"beast::manual_clock::advance(duration) : forward input");
now_ += elapsed; now_ += elapsed;
} }
@@ -75,5 +77,3 @@ public:
}; };
} // namespace beast } // namespace beast
#endif

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