mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Compare commits
55 Commits
copilot/re
...
mvadari/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d2e0788cc | ||
|
|
d7b6c8e098 | ||
|
|
d10bb71eea | ||
|
|
5dbbd9ba8d | ||
|
|
fb37cc2f42 | ||
|
|
fabf328485 | ||
|
|
dc2430ea86 | ||
|
|
0de37c2cad | ||
|
|
3d9eba73e8 | ||
|
|
ea3ca12894 | ||
|
|
7b27096aac | ||
|
|
c00491baa1 | ||
|
|
d616aff4e2 | ||
|
|
be9913f16f | ||
|
|
b99a7666ab | ||
|
|
683ff84ee0 | ||
|
|
9c9281e5d9 | ||
|
|
2d6450904d | ||
|
|
8269964c76 | ||
|
|
945b4f77cd | ||
|
|
03863d91ad | ||
|
|
737d128cca | ||
|
|
97629e7477 | ||
|
|
b0ca6adf7a | ||
|
|
e2238b13de | ||
|
|
27e9d0d695 | ||
|
|
b3829e5e61 | ||
|
|
50968111da | ||
|
|
fa77338bdc | ||
|
|
ffd96e354f | ||
|
|
e9287812ef | ||
|
|
819d3fcdfc | ||
|
|
dcdc5e1b52 | ||
|
|
c0895c6e2e | ||
|
|
5b0b1ff1f6 | ||
|
|
e9c4ed6a74 | ||
|
|
deaa23f4e5 | ||
|
|
638477c824 | ||
|
|
9b42e178a2 | ||
|
|
f41c02d486 | ||
|
|
a423813098 | ||
|
|
56c173a097 | ||
|
|
7900fa9ead | ||
|
|
0ffb3e2227 | ||
|
|
add3d7e68d | ||
|
|
c24432f43a | ||
|
|
1ccd84e43a | ||
|
|
1cc7424934 | ||
|
|
b5562cc81e | ||
|
|
e6369c0faa | ||
|
|
43caa7d47a | ||
|
|
e0f487bb2e | ||
|
|
a8987cf271 | ||
|
|
4157e3684c | ||
|
|
659f455335 |
@@ -66,14 +66,14 @@ Checks: "-*,
|
||||
bugprone-terminating-continue,
|
||||
bugprone-throw-keyword-missing,
|
||||
bugprone-too-small-loop-variable,
|
||||
bugprone-unchecked-optional-access,
|
||||
# bugprone-unchecked-optional-access, # see https://github.com/XRPLF/rippled/pull/6502
|
||||
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-use-after-move,
|
||||
bugprone-use-after-move, # has issues
|
||||
bugprone-unused-raii,
|
||||
bugprone-unused-return-value,
|
||||
bugprone-unused-local-non-trivial-variable,
|
||||
@@ -106,7 +106,6 @@ Checks: "-*,
|
||||
modernize-use-emplace,
|
||||
modernize-use-equals-default,
|
||||
modernize-use-equals-delete,
|
||||
modernize-use-nodiscard,
|
||||
modernize-use-override,
|
||||
modernize-use-ranges,
|
||||
modernize-use-starts-ends-with,
|
||||
|
||||
@@ -93,7 +93,6 @@ test.core > xrpl.basics
|
||||
test.core > xrpl.core
|
||||
test.core > xrpld.core
|
||||
test.core > xrpl.json
|
||||
test.core > xrpl.protocol
|
||||
test.core > xrpl.rdb
|
||||
test.core > xrpl.server
|
||||
test.csf > xrpl.basics
|
||||
|
||||
16
.github/workflows/reusable-build-test-config.yml
vendored
16
.github/workflows/reusable-build-test-config.yml
vendored
@@ -210,22 +210,6 @@ jobs:
|
||||
retention-days: 3
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Export server definitions
|
||||
if: ${{ runner.os != 'Windows' && !inputs.build_only && env.VOIDSTAR_ENABLED != 'true' }}
|
||||
working-directory: ${{ env.BUILD_DIR }}
|
||||
run: |
|
||||
set -o pipefail
|
||||
./xrpld --definitions | python3 -m json.tool > server_definitions.json
|
||||
|
||||
- name: Upload server definitions
|
||||
if: ${{ github.event.repository.visibility == 'public' && inputs.config_name == 'debian-bookworm-gcc-13-amd64-release' }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: server-definitions
|
||||
path: ${{ env.BUILD_DIR }}/server_definitions.json
|
||||
retention-days: 3
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Check linking (Linux)
|
||||
if: ${{ runner.os == 'Linux' && env.SANITIZERS_ENABLED == 'false' }}
|
||||
working-directory: ${{ env.BUILD_DIR }}
|
||||
|
||||
@@ -20,22 +20,6 @@ repos:
|
||||
- id: check-merge-conflict
|
||||
args: [--assume-in-merge]
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: clang-tidy
|
||||
name: "clang-tidy (enable with: TIDY=1)"
|
||||
entry: ./bin/pre-commit/clang_tidy_check.py
|
||||
language: python
|
||||
types_or: [c++, c]
|
||||
exclude: ^include/xrpl/protocol_autogen
|
||||
pass_filenames: false # script determines the staged files itself
|
||||
- id: fix-include-style
|
||||
name: fix include style
|
||||
entry: ./bin/pre-commit/fix_include_style.py
|
||||
language: python
|
||||
types_or: [c++, c]
|
||||
exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_entries)/
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: cd481d7b0bfb5c7b3090c21846317f9a8262e891 # frozen: v22.1.0
|
||||
hooks:
|
||||
@@ -83,6 +67,14 @@ repos:
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: clang-tidy
|
||||
name: "clang-tidy (enable with: TIDY=1)"
|
||||
entry: ./bin/pre-commit/clang_tidy_check.py
|
||||
language: python
|
||||
types_or: [c++, c]
|
||||
exclude: ^include/xrpl/protocol_autogen
|
||||
pass_filenames: false # script determines the staged files itself
|
||||
|
||||
- id: nix-fmt
|
||||
name: Format Nix files
|
||||
entry: |
|
||||
|
||||
113
SECURITY.md
113
SECURITY.md
@@ -22,10 +22,117 @@ Responsible investigation includes, but isn't limited to, the following:
|
||||
- Not targeting physical security measures, or attempting to use social engineering, spam, distributed denial of service (DDOS) attacks, etc.
|
||||
- Investigating bugs in a way that makes a reasonable, good faith effort not to be disruptive or harmful to the XRP Ledger and the broader ecosystem.
|
||||
|
||||
### Responsible Disclosure
|
||||
|
||||
If you discover a vulnerability or potential threat, or if you _think_
|
||||
you have, please reach out by dropping an email using the contact
|
||||
information below.
|
||||
|
||||
Your report should include the following:
|
||||
|
||||
- Your contact information (typically, an email address);
|
||||
- The description of the vulnerability;
|
||||
- The attack scenario (if any);
|
||||
- The steps to reproduce the vulnerability;
|
||||
- Any other relevant details or artifacts, including code, scripts or patches.
|
||||
|
||||
In your email, please describe the issue or potential threat. If possible, include a "repro" (code that can reproduce the issue) or describe the best way to reproduce and replicate the issue. Please make your report as detailed and comprehensive as possible.
|
||||
|
||||
For more information on responsible disclosure, please read this [Wikipedia article](https://en.wikipedia.org/wiki/Responsible_disclosure).
|
||||
|
||||
## Report Handling Process
|
||||
|
||||
Please report the bug directly to us and limit further disclosure. If you want to prove that you knew the bug as of a given time, consider using a cryptographic pre-commitment: hash the content of your report and publish the hash on a medium of your choice (e.g. on Twitter or as a memo in a transaction) as "proof" that you had written the text at a given point in time.
|
||||
|
||||
Once we receive a report, we:
|
||||
|
||||
1. Assign two people to independently evaluate the report;
|
||||
2. Consider their recommendations;
|
||||
3. If action is necessary, formulate a plan to address the issue;
|
||||
4. Communicate privately with the reporter to explain our plan.
|
||||
5. Prepare, test and release a version which fixes the issue; and
|
||||
6. Announce the vulnerability publicly.
|
||||
|
||||
We will triage and respond to your disclosure within 24 hours. Beyond that, we will work to analyze the issue in more detail, formulate, develop and test a fix.
|
||||
|
||||
While we commit to responding with 24 hours of your initial report with our triage assessment, we cannot guarantee a response time for the remaining steps. We will communicate with you throughout this process, letting you know where we are and keeping you updated on the timeframe.
|
||||
|
||||
## Bug Bounty Program
|
||||
|
||||
[Ripple](https://ripple.com) is generously sponsoring a bug bounty program for vulnerabilities in [`xrpld`](https://github.com/XRPLF/rippled) (and other related projects, like [`Clio`](https://github.com/XRPLF/clio), [`xrpl.js`](https://github.com/XRPLF/xrpl.js), [`xrpl-py`](https://github.com/XRPLF/xrpl-py), [`xrpl4j`](https://github.com/XRPLF/xrpl4j)).
|
||||
[Ripple](https://ripple.com) is generously sponsoring a bug bounty program for vulnerabilities in [`xrpld`](https://github.com/XRPLF/rippled) (and other related projects, like [`xrpl.js`](https://github.com/XRPLF/xrpl.js), [`xrpl-py`](https://github.com/XRPLF/xrpl-py), [`xrpl4j`](https://github.com/XRPLF/xrpl4j)).
|
||||
|
||||
This program allows us to recognize and reward individuals or groups that identify and report bugs.
|
||||
This program allows us to recognize and reward individuals or groups that identify and report bugs. In summary, in order to qualify for a bounty, the bug must be:
|
||||
|
||||
We have partnered with Bugcrowd to manage this program. It is a private program, and security researchers can participate based on invitation. If you need access to the program, please email bugs@ripple.com with your Bugcrowd handle or Bugcrowd registered email, and we will get you added to the program. Once you have been added, please submit vulnerability reports through Bugcrowd, not by email. The detailed bug bounty policy is available on the Bugcrowd website.
|
||||
1. **In scope**. Only bugs in software under the scope of the program qualify. Currently, that means `xrpld`, `xrpl.js`, `xrpl-py`, `xrpl4j`.
|
||||
2. **Relevant**. A security issue, posing a danger to user funds, privacy, or the operation of the XRP Ledger.
|
||||
3. **Original and previously unknown**. Bugs that are already known and discussed in public do not qualify. Previously reported bugs, even if publicly unknown, are not eligible.
|
||||
4. **Specific**. We welcome general security advice or recommendations, but we cannot pay bounties for that.
|
||||
5. **Fixable**. There has to be something we can do to permanently fix the problem. Note that bugs in other people’s software may still qualify in some cases. For example, if you find a bug in a library that we use which can compromise the security of software that is in scope and we can get it fixed, you may qualify for a bounty.
|
||||
6. **Unused**. If you use the exploit to attack the XRP Ledger, you do not qualify for a bounty. If you report a vulnerability used in an ongoing or past attack and there is specific, concrete evidence that suggests you are the attacker we reserve the right not to pay a bounty.
|
||||
|
||||
The amount paid varies dramatically. Vulnerabilities that are harmless on their own, but could form part of a critical exploit will usually receive a bounty. Full-blown exploits can receive much higher bounties. Please don’t hold back partial vulnerabilities while trying to construct a full-blown exploit. We will pay a bounty to anyone who reports a complete chain of vulnerabilities even if they have reported each component of the exploit separately and those vulnerabilities have been fixed in the meantime. However, to qualify for a the full bounty, you must to have been the first to report each of the partial exploits.
|
||||
|
||||
### Contacting Us
|
||||
|
||||
To report a qualifying bug, please send a detailed report to:
|
||||
|
||||
| Email Address | bugs@ripple.com |
|
||||
| :-----------: | :-------------------------------------------------- |
|
||||
| Short Key ID | `0xA9F514E0` |
|
||||
| Long Key ID | `0xD900855AA9F514E0` |
|
||||
| Fingerprint | `B72C 0654 2F2A E250 2763 A268 D900 855A A9F5 14E0` |
|
||||
|
||||
The full PGP key for this address, which is also available on several key servers (e.g. on [keyserver.ubuntu.com](https://keyserver.ubuntu.com)), is:
|
||||
|
||||
```
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
mQINBGkSZAQBEACprU199OhgdsOsygNjiQV4msuN3vDOUooehL+NwfsGfW79Tbqq
|
||||
Q2u7uQ3NZjW+M2T4nsDwuhkr7pe7xSReR5W8ssaczvtUyxkvbMClilcgZ2OSCAuC
|
||||
N9tzJsqOqkwBvXoNXkn//T2jnPz0ZU2wSF+NrEibq5FeuyGdoX3yXXBxq9pW9HzK
|
||||
HkQll63QSl6BzVSGRQq+B6lGgaZGLwf3mzmIND9Z5VGLNK2jKynyz9z091whNG/M
|
||||
kV+E7/r/bujHk7WIVId07G5/COTXmSr7kFnNEkd2Umw42dkgfiNKvlmJ9M7c1wLK
|
||||
KbL9Eb4ADuW6rRc5k4s1e6GT8R4/VPliWbCl9SE32hXH8uTkqVIFZP2eyM5WRRHs
|
||||
aKzitkQG9UK9gcb0kdgUkxOvvgPHAe5IuZlcHFzU4y0dBbU1VEFWVpiLU0q+IuNw
|
||||
5BRemeHc59YNsngkmAZ+/9zouoShRusZmC8Wzotv75C2qVBcjijPvmjWAUz0Zunm
|
||||
Lsr+O71vqHE73pERjD07wuD/ISjiYRYYE/bVrXtXLZijC7qAH4RE3nID+2ojcZyO
|
||||
/2jMQvt7un56RsGH4UBHi3aBHi9bUoDGCXKiQY981cEuNaOxpou7Mh3x/ONzzSvk
|
||||
sTV6nl1LOZHykN1JyKwaNbTSAiuyoN+7lOBqbV04DNYAHL88PrT21P83aQARAQAB
|
||||
tB1SaXBwbGUgTGFicyA8YnVnc0ByaXBwbGUuY29tPokCTgQTAQgAOBYhBLcsBlQv
|
||||
KuJQJ2OiaNkAhVqp9RTgBQJpEmQEAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA
|
||||
AAoJENkAhVqp9RTgBzgP/i7y+aDWl1maig1XMdyb+o0UGusumFSW4Hmj278wlKVv
|
||||
usgLPihYgHE0PKrv6WRyKOMC1tQEcYYN93M+OeQ1vFhS2YyURq6RCMmh4zq/awXG
|
||||
uZbG36OURB5NH8lGBOHiN/7O+nY0CgenBT2JWm+GW3nEOAVOVm4+r5GlpPlv+Dp1
|
||||
NPBThcKXFMnH73++NpSQoDzTfRYHPxhDAX3jkLi/moXfSanOLlR6l94XNNN0jBHW
|
||||
Quao0rzf4WSXq9g6AS224xhAA5JyIcFl8TX7hzj5HaFn3VWo3COoDu4U7H+BM0fl
|
||||
85yqiMQypp7EhN2gxpMMWaHY5TFM85U/bFXFYfEgihZ4/gt4uoIzsNI9jlX7mYvG
|
||||
KFdDij+oTlRsuOxdIy60B3dKcwOH9nZZCz0SPsN/zlRWgKzK4gDKdGhFkU9OlvPu
|
||||
94ZqscanoiWKDoZkF96+sjgfjkuHsDK7Lwc1Xi+T4drHG/3aVpkYabXox+lrKB/S
|
||||
yxZjeqOIQzWPhnLgCaLyvsKo5hxKzL0w3eURu8F3IS7RgOOlljv4M+Me9sEVcdNV
|
||||
aN3/tQwbaomSX1X5D5YXqhBwC3rU3wXwamsscRTGEpkV+JCX6KUqGP7nWmxCpAly
|
||||
FL05XuOd5SVHJjXLeuje0JqLUpN514uL+bThWwDbDTdAdwW3oK/2WbXz7IfJRLBj
|
||||
uQINBGkSZAQBEADdI3SL2F72qkrgFqXWE6HSRBu9bsAvTE5QrRPWk7ux6at537r4
|
||||
S4sIw2dOwLvbyIrDgKNq3LQ5wCK88NO/NeCOFm4AiCJSl3pJHXYnTDoUxTrrxx+o
|
||||
vSRI4I3fHEql/MqzgiAb0YUezjgFdh3vYheMPp/309PFbOLhiFqEcx80Mx5h06UH
|
||||
gDzu1qNj3Ec+31NLic5zwkrAkvFvD54d6bqYR3SEgMau6aYEewpGHbWBi2pLqSi2
|
||||
lQcAeOFixqGpTwDmAnYR8YtjBYepy0MojEAdTHcQQlOYSDk4q4elG+io2N8vECfU
|
||||
rD6ORecN48GXdZINYWTAdslrUeanmBdgQrYkSpce8TSghgT9P01SNaXxmyaehVUO
|
||||
lqI4pcg5G2oojAE8ncNS3TwDtt7daTaTC3bAdr4PXDVAzNAiewjMNZPB7xidkDGQ
|
||||
Y4W1LxTMXyJVWxehYOH7tsbBRKninlfRnLgYzmtIbNRAAvNcsxU6ihv3AV0WFknN
|
||||
YbSzotEv1Xq/5wk309x8zCDe+sP0cQicvbXafXmUzPAZzeqFg+VLFn7F9MP1WGlW
|
||||
B1u7VIvBF1Mp9Nd3EAGBAoLRdRu+0dVWIjPTQuPIuD9cCatJA0wVaKUrjYbBMl88
|
||||
a12LixNVGeSFS9N7ADHx0/o7GNT6l88YbaLP6zggUHpUD/bR+cDN7vllIQARAQAB
|
||||
iQI2BBgBCAAgFiEEtywGVC8q4lAnY6Jo2QCFWqn1FOAFAmkSZAQCGwwACgkQ2QCF
|
||||
Wqn1FOAfAA/8CYq4p0p4bobY20CKEMsZrkBTFJyPDqzFwMeTjgpzqbD7Y3Qq5QCK
|
||||
OBbvY02GWdiIsNOzKdBxiuam2xYP9WHZj4y7/uWEvT0qlPVmDFu+HXjoJ43oxwFd
|
||||
CUp2gMuQ4cSL3X94VRJ3BkVL+tgBm8CNY0vnTLLOO3kum/R69VsGJS1JSGUWjNM+
|
||||
4qwS3mz+73xJu1HmERyN2RZF/DGIZI2PyONQQ6aH85G1Dd2ohu2/DBAkQAMBrPbj
|
||||
FrbDaBLyFhODxU3kTWqnfLlaElSm2EGdIU2yx7n4BggEa//NZRMm5kyeo4vzhtlQ
|
||||
YIVUMLAOLZvnEqDnsLKp+22FzNR/O+htBQC4lPywl53oYSALdhz1IQlcAC1ru5KR
|
||||
XPzhIXV6IIzkcx9xNkEclZxmsuy5ERXyKEmLbIHAlzFmnrldlt2ZgXDtzaorLmxj
|
||||
klKibxd5tF50qOpOivz+oPtFo7n+HmFa1nlVAMxlDCUdM0pEVeYDKI5zfVwalyhZ
|
||||
NnjpakdZSXMwgc7NP/hH9buF35hKDp7EckT2y3JNYwHsDdy1icXN2q40XZw5tSIn
|
||||
zkPWdu3OUY8PISohN6Pw4h0RH4ZmoX97E8sEfmdKaT58U4Hf2aAv5r9IWCSrAVqY
|
||||
u5jvac29CzQR9Kal0A+8phHAXHNFD83SwzIC0syaT9ficAguwGH8X6Q=
|
||||
=nGuD
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
```
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Converts quoted includes (#include "...") to angle-bracket includes
|
||||
(#include <...>), which is the required style in this project.
|
||||
|
||||
Usage: ./bin/pre-commit/fix_include_style.py <file1> <file2> ...
|
||||
"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
PATTERN = re.compile(r'^(\s*#include\s*)"([^"]+)"', re.MULTILINE)
|
||||
|
||||
|
||||
def fix_includes(path: Path) -> bool:
|
||||
original = path.read_text(encoding="utf-8")
|
||||
fixed = PATTERN.sub(r"\1<\2>", original)
|
||||
if fixed != original:
|
||||
path.write_text(fixed, encoding="utf-8")
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def main() -> int:
|
||||
files = [Path(f) for f in sys.argv[1:]]
|
||||
success = True
|
||||
|
||||
for path in files:
|
||||
success &= fix_includes(path)
|
||||
|
||||
return 0 if success else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -118,7 +118,7 @@ if(MSVC)
|
||||
NOMINMAX
|
||||
# TODO: Resolve these warnings, don't just silence them
|
||||
_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
|
||||
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:Debug>>:_CRTDBG_MAP_ALLOC>
|
||||
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:Debug>,$<NOT:$<BOOL:${is_ci}>>>:_CRTDBG_MAP_ALLOC>
|
||||
)
|
||||
target_link_libraries(common INTERFACE -errorreport:none -machine:X64)
|
||||
else()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
@@ -12,6 +12,6 @@ namespace xrpl {
|
||||
@throws runtime_error
|
||||
*/
|
||||
void
|
||||
extractTarLz4(std::filesystem::path const& src, std::filesystem::path const& dst);
|
||||
extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const& dst);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
explicit Section(std::string name = "");
|
||||
|
||||
/** Returns the name of this section. */
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
name() const
|
||||
{
|
||||
return name_;
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
/** Returns all the lines in the section.
|
||||
This includes everything.
|
||||
*/
|
||||
[[nodiscard]] std::vector<std::string> const&
|
||||
std::vector<std::string> const&
|
||||
lines() const
|
||||
{
|
||||
return lines_;
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
/** Returns all the values in the section.
|
||||
Values are non-empty lines which are not key/value pairs.
|
||||
*/
|
||||
[[nodiscard]] std::vector<std::string> const&
|
||||
std::vector<std::string> const&
|
||||
values() const
|
||||
{
|
||||
return values_;
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
* @return The retrieved value. A section with an empty legacy value returns
|
||||
an empty string.
|
||||
*/
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
legacy() const
|
||||
{
|
||||
if (lines_.empty())
|
||||
@@ -117,11 +117,11 @@ public:
|
||||
}
|
||||
|
||||
/** Returns `true` if a key with the given name exists. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
exists(std::string const& name) const;
|
||||
|
||||
template <class T = std::string>
|
||||
[[nodiscard]] std::optional<T>
|
||||
std::optional<T>
|
||||
get(std::string const& name) const
|
||||
{
|
||||
auto const iter = lookup_.find(name);
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
|
||||
/// Returns a value if present, else another value.
|
||||
template <class T>
|
||||
[[nodiscard]] T
|
||||
T
|
||||
value_or(std::string const& name, T const& other) const
|
||||
{
|
||||
auto const v = get<T>(name);
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
|
||||
// indicates if trailing comments were seen
|
||||
// during the appending of any lines/values
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
had_trailing_comments() const
|
||||
{
|
||||
return had_trailing_comments_;
|
||||
@@ -151,42 +151,42 @@ public:
|
||||
operator<<(std::ostream&, Section const& section);
|
||||
|
||||
// Returns `true` if there are no key/value pairs.
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
empty() const
|
||||
{
|
||||
return lookup_.empty();
|
||||
}
|
||||
|
||||
// Returns the number of key/value pairs.
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
size() const
|
||||
{
|
||||
return lookup_.size();
|
||||
}
|
||||
|
||||
// For iteration of key/value pairs.
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const
|
||||
{
|
||||
return lookup_.cbegin();
|
||||
}
|
||||
|
||||
// For iteration of key/value pairs.
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cbegin() const
|
||||
{
|
||||
return lookup_.cbegin();
|
||||
}
|
||||
|
||||
// For iteration of key/value pairs.
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const
|
||||
{
|
||||
return lookup_.cend();
|
||||
}
|
||||
|
||||
// For iteration of key/value pairs.
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cend() const
|
||||
{
|
||||
return lookup_.cend();
|
||||
@@ -206,7 +206,7 @@ private:
|
||||
|
||||
public:
|
||||
/** Returns `true` if a section with the given name exists. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
exists(std::string const& name) const;
|
||||
|
||||
/** Returns the section with the given name.
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
Section&
|
||||
section(std::string const& name);
|
||||
|
||||
[[nodiscard]] Section const&
|
||||
Section const&
|
||||
section(std::string const& name) const;
|
||||
|
||||
Section const&
|
||||
@@ -264,7 +264,7 @@ public:
|
||||
* legacy value.
|
||||
* @return Contents of the legacy value.
|
||||
*/
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
legacy(std::string const& sectionName) const;
|
||||
|
||||
friend std::ostream&
|
||||
@@ -272,7 +272,7 @@ public:
|
||||
|
||||
// indicates if trailing comments were seen
|
||||
// in any loaded Sections
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
had_trailing_comments() const
|
||||
{
|
||||
return std::ranges::any_of(map_, [](auto s) { return s.second.had_trailing_comments(); });
|
||||
|
||||
@@ -101,13 +101,13 @@ public:
|
||||
}
|
||||
|
||||
/** Returns the number of bytes in the buffer. */
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
size() const noexcept
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
empty() const noexcept
|
||||
{
|
||||
return 0 == size_;
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
to a single byte, to facilitate pointer arithmetic.
|
||||
*/
|
||||
/** @{ */
|
||||
[[nodiscard]] std::uint8_t const*
|
||||
std::uint8_t const*
|
||||
data() const noexcept
|
||||
{
|
||||
return p_.get();
|
||||
@@ -169,25 +169,25 @@ public:
|
||||
return alloc(n);
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const noexcept
|
||||
{
|
||||
return p_.get();
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cbegin() const noexcept
|
||||
{
|
||||
return p_.get();
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const noexcept
|
||||
{
|
||||
return p_.get() + size_;
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cend() const noexcept
|
||||
{
|
||||
return p_.get() + size_;
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
using Entry = std::pair<std::string, int>;
|
||||
using List = std::vector<Entry>;
|
||||
|
||||
[[nodiscard]] List
|
||||
List
|
||||
getCounts(int minimumThreshold) const;
|
||||
|
||||
public:
|
||||
@@ -59,19 +59,19 @@ public:
|
||||
return --count_;
|
||||
}
|
||||
|
||||
[[nodiscard]] int
|
||||
int
|
||||
getCount() const noexcept
|
||||
{
|
||||
return count_.load();
|
||||
}
|
||||
|
||||
[[nodiscard]] Counter*
|
||||
Counter*
|
||||
getNext() const noexcept
|
||||
{
|
||||
return next_;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
getName() const noexcept
|
||||
{
|
||||
return name_;
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E const&
|
||||
constexpr E const&
|
||||
value() const&
|
||||
{
|
||||
return val_;
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
return std::move(val_);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E const&&
|
||||
constexpr E const&&
|
||||
value() const&&
|
||||
{
|
||||
return std::move(val_);
|
||||
@@ -125,13 +125,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool
|
||||
constexpr bool
|
||||
has_value() const
|
||||
{
|
||||
return Base::has_value();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr T const&
|
||||
constexpr T const&
|
||||
value() const
|
||||
{
|
||||
return Base::value();
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
return Base::value();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E const&
|
||||
constexpr E const&
|
||||
error() const
|
||||
{
|
||||
return Base::error();
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E const&
|
||||
constexpr E const&
|
||||
error() const
|
||||
{
|
||||
return Base::error();
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
std::string
|
||||
getFileContents(
|
||||
std::error_code& ec,
|
||||
std::filesystem::path const& sourcePath,
|
||||
boost::system::error_code& ec,
|
||||
boost::filesystem::path const& sourcePath,
|
||||
std::optional<std::size_t> maxSize = std::nullopt);
|
||||
|
||||
void
|
||||
writeFileContents(
|
||||
std::error_code& ec,
|
||||
std::filesystem::path const& destPath,
|
||||
boost::system::error_code& ec,
|
||||
boost::filesystem::path const& destPath,
|
||||
std::string const& contents);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -159,11 +159,11 @@ public:
|
||||
reset();
|
||||
|
||||
/** Get the raw pointer */
|
||||
[[nodiscard]] T*
|
||||
T*
|
||||
get() const;
|
||||
|
||||
/** Return the strong count */
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
use_count() const;
|
||||
|
||||
template <class TT, class... Args>
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
|
||||
private:
|
||||
/** Return the raw pointer held by this object. */
|
||||
[[nodiscard]] T*
|
||||
T*
|
||||
unsafeGetRawPtr() const;
|
||||
|
||||
/** Exchange the current raw pointer held by this object with the given
|
||||
@@ -260,7 +260,7 @@ public:
|
||||
lock() const;
|
||||
|
||||
/** Return true if the strong count is zero. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
expired() const;
|
||||
|
||||
/** Set the pointer to null and decrement the weak count.
|
||||
@@ -339,7 +339,7 @@ public:
|
||||
don't lock the weak pointer. Use the `lock` method if that's what's
|
||||
needed)
|
||||
*/
|
||||
[[nodiscard]] SharedIntrusive<T>
|
||||
SharedIntrusive<T>
|
||||
getStrong() const;
|
||||
|
||||
/** Return true if this is a strong pointer and the strong pointer is
|
||||
@@ -357,31 +357,31 @@ public:
|
||||
/** If this is a strong pointer, return the raw pointer. Otherwise
|
||||
return null.
|
||||
*/
|
||||
[[nodiscard]] T*
|
||||
T*
|
||||
get() const;
|
||||
|
||||
/** If this is a strong pointer, return the strong count. Otherwise
|
||||
* return 0
|
||||
*/
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
use_count() const;
|
||||
|
||||
/** Return true if there is a non-zero strong count. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
expired() const;
|
||||
|
||||
/** If this is a strong pointer, return the strong pointer. Otherwise
|
||||
attempt to lock the weak pointer.
|
||||
*/
|
||||
[[nodiscard]] SharedIntrusive<T>
|
||||
SharedIntrusive<T>
|
||||
lock() const;
|
||||
|
||||
/** Return true is this represents a strong pointer. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isStrong() const;
|
||||
|
||||
/** Return true is this represents a weak pointer. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isWeak() const;
|
||||
|
||||
/** If this is a weak pointer, attempt to convert it to a strong
|
||||
@@ -412,7 +412,7 @@ private:
|
||||
private:
|
||||
/** Return the raw pointer held by this object.
|
||||
*/
|
||||
[[nodiscard]] T*
|
||||
T*
|
||||
unsafeGetRawPtr() const;
|
||||
|
||||
enum class RefStrength { strong, weak };
|
||||
|
||||
@@ -207,7 +207,7 @@ private:
|
||||
RefCountPair(CountType s, CountType w) noexcept;
|
||||
|
||||
/** Convert back to the packed integer form. */
|
||||
[[nodiscard]] FieldType
|
||||
FieldType
|
||||
combinedValue() const noexcept;
|
||||
|
||||
static constexpr CountType maxStrongValue =
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
@return `true` if a system file is associated and opened for
|
||||
writing.
|
||||
*/
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isOpen() const noexcept;
|
||||
|
||||
/** Associate a system file with the log.
|
||||
@@ -88,7 +88,7 @@ private:
|
||||
@return `true` if the file was opened.
|
||||
*/
|
||||
bool
|
||||
open(std::filesystem::path const& path);
|
||||
open(boost::filesystem::path const& path);
|
||||
|
||||
/** Close and re-open the system file associated with the log
|
||||
This assists in interoperating with external log management tools.
|
||||
@@ -130,7 +130,7 @@ private:
|
||||
|
||||
private:
|
||||
std::unique_ptr<std::ofstream> m_stream;
|
||||
std::filesystem::path m_path;
|
||||
boost::filesystem::path m_path;
|
||||
};
|
||||
|
||||
std::mutex mutable mutex_;
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
virtual ~Logs() = default;
|
||||
|
||||
bool
|
||||
open(std::filesystem::path const& pathToLogFile);
|
||||
open(boost::filesystem::path const& pathToLogFile);
|
||||
|
||||
beast::Journal::Sink&
|
||||
get(std::string const& name);
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
return data_;
|
||||
}
|
||||
|
||||
[[nodiscard]] ProtectedDataType const&
|
||||
ProtectedDataType const&
|
||||
get() const
|
||||
{
|
||||
return data_;
|
||||
|
||||
@@ -252,9 +252,9 @@ public:
|
||||
// Assume unsigned values are... unsigned. i.e. positive
|
||||
explicit Number(internalrep mantissa, int exponent, normalized);
|
||||
|
||||
[[nodiscard]] constexpr rep
|
||||
constexpr rep
|
||||
mantissa() const noexcept;
|
||||
[[nodiscard]] constexpr int
|
||||
constexpr int
|
||||
exponent() const noexcept;
|
||||
|
||||
constexpr Number
|
||||
@@ -339,7 +339,7 @@ public:
|
||||
}
|
||||
|
||||
/** Return the sign of the amount */
|
||||
[[nodiscard]] constexpr int
|
||||
constexpr int
|
||||
signum() const noexcept
|
||||
{
|
||||
if (negative_)
|
||||
@@ -347,7 +347,7 @@ public:
|
||||
return (mantissa_ != 0u) ? 1 : 0;
|
||||
}
|
||||
|
||||
[[nodiscard]] Number
|
||||
Number
|
||||
truncate() const noexcept;
|
||||
|
||||
friend constexpr bool
|
||||
@@ -490,13 +490,13 @@ private:
|
||||
MantissaRange::rep const& minMantissa,
|
||||
MantissaRange::rep const& maxMantissa);
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isnormal() const noexcept;
|
||||
|
||||
// Copy the number, but modify the exponent by "exponentDelta". Because the
|
||||
// mantissa doesn't change, the result will be "mostly" normalized, but the
|
||||
// exponent could go out of range, so it will be checked.
|
||||
[[nodiscard]] Number
|
||||
Number
|
||||
shiftExponent(int exponentDelta) const;
|
||||
|
||||
// Safely convert rep (int64) mantissa to internalrep (uint64). If the rep
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] uint256 const&
|
||||
uint256 const&
|
||||
as_uint256() const
|
||||
{
|
||||
return hash_;
|
||||
@@ -30,17 +30,17 @@ public:
|
||||
{
|
||||
return hash_;
|
||||
}
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isZero() const
|
||||
{
|
||||
return hash_.isZero();
|
||||
}
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isNonZero() const
|
||||
{
|
||||
return hash_.isNonZero();
|
||||
}
|
||||
[[nodiscard]] int
|
||||
int
|
||||
signum() const
|
||||
{
|
||||
return hash_.signum();
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
/** Return a strong pointer if this is already a strong pointer (i.e. don't
|
||||
lock the weak pointer. Use the `lock` method if that's what's needed)
|
||||
*/
|
||||
[[nodiscard]] std::shared_ptr<T> const&
|
||||
std::shared_ptr<T> const&
|
||||
getStrong() const;
|
||||
|
||||
/** Return true if this is a strong pointer and the strong pointer is
|
||||
@@ -67,30 +67,30 @@ public:
|
||||
/** If this is a strong pointer, return the raw pointer. Otherwise return
|
||||
null.
|
||||
*/
|
||||
[[nodiscard]] T*
|
||||
T*
|
||||
get() const;
|
||||
|
||||
/** If this is a strong pointer, return the strong count. Otherwise return 0
|
||||
*/
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
use_count() const;
|
||||
|
||||
/** Return true if there is a non-zero strong count. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
expired() const;
|
||||
|
||||
/** If this is a strong pointer, return the strong pointer. Otherwise
|
||||
attempt to lock the weak pointer.
|
||||
*/
|
||||
[[nodiscard]] std::shared_ptr<T>
|
||||
std::shared_ptr<T>
|
||||
lock() const;
|
||||
|
||||
/** Return true is this represents a strong pointer. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isStrong() const;
|
||||
|
||||
/** Return true is this represents a weak pointer. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isWeak() const;
|
||||
|
||||
/** If this is a weak pointer, attempt to convert it to a strong pointer.
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
~SlabAllocator() = default;
|
||||
|
||||
/** Returns the size of the memory block this allocator returns. */
|
||||
[[nodiscard]] constexpr std::size_t
|
||||
constexpr std::size_t
|
||||
size() const noexcept
|
||||
{
|
||||
return itemSize_;
|
||||
@@ -284,7 +284,7 @@ class SlabAllocatorSet
|
||||
{
|
||||
private:
|
||||
// The list of allocators that belong to this set
|
||||
boost::container::static_vector<SlabAllocator<Type>, 64> allocators_{};
|
||||
boost::container::static_vector<SlabAllocator<Type>, 64> allocators_;
|
||||
|
||||
std::size_t maxSize_ = 0;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
@note The return type is guaranteed to be a pointer
|
||||
to a single byte, to facilitate pointer arithmetic.
|
||||
*/
|
||||
[[nodiscard]] std::uint8_t const*
|
||||
std::uint8_t const*
|
||||
data() const noexcept
|
||||
{
|
||||
return data_;
|
||||
@@ -123,25 +123,25 @@ public:
|
||||
size_ -= n;
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const noexcept
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cbegin() const noexcept
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const noexcept
|
||||
{
|
||||
return data_ + size_;
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cend() const noexcept
|
||||
{
|
||||
return data_ + size_;
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
@returns The requested subslice, if the request is valid.
|
||||
@throws std::out_of_range if pos > size()
|
||||
*/
|
||||
[[nodiscard]] Slice
|
||||
Slice
|
||||
substr(std::size_t pos, std::size_t count = std::numeric_limits<std::size_t>::max()) const
|
||||
{
|
||||
if (pos > size())
|
||||
|
||||
@@ -222,19 +222,19 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isWeak() const
|
||||
{
|
||||
if (!ptr)
|
||||
return true;
|
||||
return ptr.isWeak();
|
||||
}
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isCached() const
|
||||
{
|
||||
return ptr && ptr.isStrong();
|
||||
}
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isExpired() const
|
||||
{
|
||||
return ptr.expired();
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
{
|
||||
return reinterpret_cast<pointer>(data_.data());
|
||||
}
|
||||
[[nodiscard]] const_pointer
|
||||
const_pointer
|
||||
data() const
|
||||
{
|
||||
return reinterpret_cast<const_pointer>(data_.data());
|
||||
@@ -118,22 +118,22 @@ public:
|
||||
{
|
||||
return data() + bytes;
|
||||
}
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const
|
||||
{
|
||||
return data();
|
||||
}
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const
|
||||
{
|
||||
return data() + bytes;
|
||||
}
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cbegin() const
|
||||
{
|
||||
return data();
|
||||
}
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cend() const
|
||||
{
|
||||
return data() + bytes;
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
return fromVoid(from.data());
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr int
|
||||
constexpr int
|
||||
signum() const
|
||||
{
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
@@ -433,14 +433,14 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
[[nodiscard]] base_uint
|
||||
base_uint
|
||||
next() const
|
||||
{
|
||||
auto ret = *this;
|
||||
return ++ret;
|
||||
}
|
||||
|
||||
[[nodiscard]] base_uint
|
||||
base_uint
|
||||
prev() const
|
||||
{
|
||||
auto ret = *this;
|
||||
@@ -517,12 +517,12 @@ public:
|
||||
}
|
||||
|
||||
// Deprecated.
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isZero() const
|
||||
{
|
||||
return *this == beast::zero;
|
||||
}
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isNonZero() const
|
||||
{
|
||||
return *this != beast::zero;
|
||||
|
||||
@@ -72,12 +72,14 @@ template <class HashAlgorithm = beast::xxhasher>
|
||||
class hardened_hash
|
||||
{
|
||||
private:
|
||||
detail::seed_pair m_seeds{detail::make_seed_pair<>()};
|
||||
detail::seed_pair m_seeds;
|
||||
|
||||
public:
|
||||
using result_type = typename HashAlgorithm::result_type;
|
||||
|
||||
hardened_hash() = default;
|
||||
hardened_hash() : m_seeds(detail::make_seed_pair<>())
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
result_type
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
{
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
partition_map_type* map_{nullptr};
|
||||
typename partition_map_type::iterator ait_{};
|
||||
typename partition_map_type::iterator ait_;
|
||||
typename map_type::iterator mit_;
|
||||
|
||||
iterator() = default;
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
|
||||
partition_map_type* map_{nullptr};
|
||||
typename partition_map_type::iterator ait_{};
|
||||
typename partition_map_type::iterator ait_;
|
||||
typename map_type::iterator mit_;
|
||||
|
||||
const_iterator() = default;
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
return m_ios;
|
||||
}
|
||||
|
||||
[[nodiscard]] boost::asio::io_context const&
|
||||
boost::asio::io_context const&
|
||||
get_io_context() const
|
||||
{
|
||||
return m_ios;
|
||||
|
||||
@@ -63,7 +63,7 @@ struct abstract_clock_wrapper : public abstract_clock<Facade>
|
||||
using typename abstract_clock<Facade>::duration;
|
||||
using typename abstract_clock<Facade>::time_point;
|
||||
|
||||
[[nodiscard]] time_point
|
||||
time_point
|
||||
now() const override
|
||||
{
|
||||
return Clock::now();
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] time_point
|
||||
time_point
|
||||
now() const override
|
||||
{
|
||||
return now_;
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
return &m_iter->value;
|
||||
}
|
||||
|
||||
[[nodiscard]] time_point const&
|
||||
time_point const&
|
||||
when() const
|
||||
{
|
||||
return m_iter->when;
|
||||
@@ -136,7 +136,7 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] Iterator const&
|
||||
Iterator const&
|
||||
iterator() const
|
||||
{
|
||||
return m_iter;
|
||||
|
||||
@@ -186,7 +186,7 @@ private:
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] Compare const&
|
||||
Compare const&
|
||||
compare() const
|
||||
{
|
||||
return *this;
|
||||
@@ -295,7 +295,7 @@ private:
|
||||
return KeyValueCompare::compare();
|
||||
}
|
||||
|
||||
[[nodiscard]] Compare const&
|
||||
Compare const&
|
||||
compare() const
|
||||
{
|
||||
return KeyValueCompare::compare();
|
||||
@@ -307,7 +307,7 @@ private:
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] KeyValueCompare const&
|
||||
KeyValueCompare const&
|
||||
key_compare() const
|
||||
{
|
||||
return *this;
|
||||
@@ -319,7 +319,7 @@ private:
|
||||
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
||||
}
|
||||
|
||||
[[nodiscard]] ElementAllocator const&
|
||||
ElementAllocator const&
|
||||
alloc() const
|
||||
{
|
||||
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
||||
|
||||
@@ -149,7 +149,7 @@ private:
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] Hash const&
|
||||
Hash const&
|
||||
hash_function() const
|
||||
{
|
||||
return *this;
|
||||
@@ -195,7 +195,7 @@ private:
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] KeyEqual const&
|
||||
KeyEqual const&
|
||||
key_eq() const
|
||||
{
|
||||
return *this;
|
||||
@@ -348,7 +348,7 @@ private:
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] ValueHash const&
|
||||
ValueHash const&
|
||||
value_hash() const
|
||||
{
|
||||
return *this;
|
||||
@@ -360,7 +360,7 @@ private:
|
||||
return ValueHash::hash_function();
|
||||
}
|
||||
|
||||
[[nodiscard]] Hash const&
|
||||
Hash const&
|
||||
hash_function() const
|
||||
{
|
||||
return ValueHash::hash_function();
|
||||
@@ -372,7 +372,7 @@ private:
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] KeyValueEqual const&
|
||||
KeyValueEqual const&
|
||||
key_value_equal() const
|
||||
{
|
||||
return *this;
|
||||
@@ -384,7 +384,7 @@ private:
|
||||
return key_value_equal().key_eq();
|
||||
}
|
||||
|
||||
[[nodiscard]] KeyEqual const&
|
||||
KeyEqual const&
|
||||
key_eq() const
|
||||
{
|
||||
return key_value_equal().key_eq();
|
||||
@@ -396,7 +396,7 @@ private:
|
||||
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
||||
}
|
||||
|
||||
[[nodiscard]] ElementAllocator const&
|
||||
ElementAllocator const&
|
||||
alloc() const
|
||||
{
|
||||
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
||||
@@ -433,7 +433,7 @@ private:
|
||||
m_vec.clear();
|
||||
}
|
||||
|
||||
[[nodiscard]] size_type
|
||||
size_type
|
||||
max_bucket_count() const
|
||||
{
|
||||
return m_vec.max_size();
|
||||
@@ -445,7 +445,7 @@ private:
|
||||
return m_max_load_factor;
|
||||
}
|
||||
|
||||
[[nodiscard]] float const&
|
||||
float const&
|
||||
max_load_factor() const
|
||||
{
|
||||
return m_max_load_factor;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] T const&
|
||||
T const&
|
||||
member() const noexcept
|
||||
{
|
||||
return *this;
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
[[nodiscard]] reference
|
||||
reference
|
||||
dereference() const noexcept
|
||||
{
|
||||
return static_cast<reference>(*m_node);
|
||||
@@ -287,14 +287,14 @@ public:
|
||||
/** Determine if the list is empty.
|
||||
@return `true` if the list is empty.
|
||||
*/
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
empty() const noexcept
|
||||
{
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
/** Returns the number of elements in the list. */
|
||||
[[nodiscard]] size_type
|
||||
size_type
|
||||
size() const noexcept
|
||||
{
|
||||
return m_size;
|
||||
@@ -314,7 +314,7 @@ public:
|
||||
@invariant The list may not be empty.
|
||||
@return A const reference to the first element.
|
||||
*/
|
||||
[[nodiscard]] const_reference
|
||||
const_reference
|
||||
front() const noexcept
|
||||
{
|
||||
return element_from(m_head.m_next);
|
||||
@@ -334,7 +334,7 @@ public:
|
||||
@invariant The list may not be empty.
|
||||
@return A const reference to the last element.
|
||||
*/
|
||||
[[nodiscard]] const_reference
|
||||
const_reference
|
||||
back() const noexcept
|
||||
{
|
||||
return element_from(m_tail.m_prev);
|
||||
@@ -352,7 +352,7 @@ public:
|
||||
/** Obtain a const iterator to the beginning of the list.
|
||||
@return A const iterator pointing to the beginning of the list.
|
||||
*/
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const noexcept
|
||||
{
|
||||
return const_iterator(m_head.m_next);
|
||||
@@ -361,7 +361,7 @@ public:
|
||||
/** Obtain a const iterator to the beginning of the list.
|
||||
@return A const iterator pointing to the beginning of the list.
|
||||
*/
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cbegin() const noexcept
|
||||
{
|
||||
return const_iterator(m_head.m_next);
|
||||
@@ -379,7 +379,7 @@ public:
|
||||
/** Obtain a const iterator to the end of the list.
|
||||
@return A constiterator pointing to the end of the list.
|
||||
*/
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const noexcept
|
||||
{
|
||||
return const_iterator(&m_tail);
|
||||
@@ -388,7 +388,7 @@ public:
|
||||
/** Obtain a const iterator to the end of the list
|
||||
@return A constiterator pointing to the end of the list.
|
||||
*/
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cend() const noexcept
|
||||
{
|
||||
return const_iterator(&m_tail);
|
||||
@@ -549,7 +549,7 @@ public:
|
||||
@param element The element to obtain an iterator for.
|
||||
@return A const iterator to the element.
|
||||
*/
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
const_iterator_to(T const& element) const noexcept
|
||||
{
|
||||
return const_iterator(static_cast<Node const*>(&element));
|
||||
|
||||
@@ -24,7 +24,9 @@ public:
|
||||
using reference = std::
|
||||
conditional_t<IsConst, typename Container::const_reference, typename Container::reference>;
|
||||
|
||||
LockFreeStackIterator() = default;
|
||||
LockFreeStackIterator() : m_node()
|
||||
{
|
||||
}
|
||||
|
||||
LockFreeStackIterator(NodePtr node) : m_node(node)
|
||||
{
|
||||
@@ -77,7 +79,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
NodePtr m_node{};
|
||||
NodePtr m_node;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -162,7 +164,7 @@ public:
|
||||
operator=(LockFreeStack const&) = delete;
|
||||
|
||||
/** Returns true if the stack is empty. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
empty() const
|
||||
{
|
||||
return m_head.load() == &m_end;
|
||||
@@ -237,25 +239,25 @@ public:
|
||||
return iterator(&m_end);
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const
|
||||
{
|
||||
return const_iterator(m_head.load());
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const
|
||||
{
|
||||
return const_iterator(&m_end);
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cbegin() const
|
||||
{
|
||||
return const_iterator(m_head.load());
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cend() const
|
||||
{
|
||||
return const_iterator(&m_end);
|
||||
|
||||
@@ -37,15 +37,15 @@ public:
|
||||
parse(std::string_view input);
|
||||
|
||||
/** Produce a string from semantic version components. */
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
print() const;
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isRelease() const noexcept
|
||||
{
|
||||
return preReleaseIdentifiers.empty();
|
||||
}
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isPreRelease() const noexcept
|
||||
{
|
||||
return !isRelease();
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
m_impl->notify(ceil<value_type>(value));
|
||||
}
|
||||
|
||||
[[nodiscard]] std::shared_ptr<EventImpl> const&
|
||||
std::shared_ptr<EventImpl> const&
|
||||
impl() const
|
||||
{
|
||||
return m_impl;
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
}
|
||||
/** @} */
|
||||
|
||||
[[nodiscard]] std::shared_ptr<GaugeImpl> const&
|
||||
std::shared_ptr<GaugeImpl> const&
|
||||
impl() const
|
||||
{
|
||||
return m_impl;
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
using ptr = std::shared_ptr<Group>;
|
||||
|
||||
/** Returns the name of this group, for diagnostics. */
|
||||
[[nodiscard]] virtual std::string const&
|
||||
virtual std::string const&
|
||||
name() const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] std::shared_ptr<HookImpl> const&
|
||||
std::shared_ptr<HookImpl> const&
|
||||
impl() const
|
||||
{
|
||||
return m_impl;
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
}
|
||||
/** @} */
|
||||
|
||||
[[nodiscard]] std::shared_ptr<MeterImpl> const&
|
||||
std::shared_ptr<MeterImpl> const&
|
||||
impl() const
|
||||
{
|
||||
return m_impl;
|
||||
|
||||
@@ -32,25 +32,25 @@ public:
|
||||
from_string(std::string const& s);
|
||||
|
||||
/** Returns a string representing the endpoint. */
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
to_string() const;
|
||||
|
||||
/** Returns the port number on the endpoint. */
|
||||
[[nodiscard]] Port
|
||||
Port
|
||||
port() const
|
||||
{
|
||||
return m_port;
|
||||
}
|
||||
|
||||
/** Returns a new Endpoint with a different port. */
|
||||
[[nodiscard]] Endpoint
|
||||
Endpoint
|
||||
at_port(Port port) const
|
||||
{
|
||||
return Endpoint(m_addr, port);
|
||||
}
|
||||
|
||||
/** Returns the address portion of this endpoint. */
|
||||
[[nodiscard]] Address const&
|
||||
Address const&
|
||||
address() const
|
||||
{
|
||||
return m_addr;
|
||||
@@ -58,22 +58,22 @@ public:
|
||||
|
||||
/** Convenience accessors for the address part. */
|
||||
/** @{ */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
is_v4() const
|
||||
{
|
||||
return m_addr.is_v4();
|
||||
}
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
is_v6() const
|
||||
{
|
||||
return m_addr.is_v6();
|
||||
}
|
||||
[[nodiscard]] AddressV4
|
||||
AddressV4
|
||||
to_v4() const
|
||||
{
|
||||
return m_addr.to_v4();
|
||||
}
|
||||
[[nodiscard]] AddressV6
|
||||
AddressV6
|
||||
to_v6() const
|
||||
{
|
||||
return m_addr.to_v6();
|
||||
|
||||
@@ -25,7 +25,7 @@ protected:
|
||||
return m_cont;
|
||||
}
|
||||
|
||||
[[nodiscard]] cont_type const&
|
||||
cont_type const&
|
||||
cont() const
|
||||
{
|
||||
return m_cont;
|
||||
@@ -39,14 +39,14 @@ public:
|
||||
using const_iterator = typename cont_type::const_iterator;
|
||||
|
||||
/** Returns `true` if the container is empty. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
empty() const
|
||||
{
|
||||
return m_cont.empty();
|
||||
}
|
||||
|
||||
/** Returns the number of items in the container. */
|
||||
[[nodiscard]] size_type
|
||||
size_type
|
||||
size() const
|
||||
{
|
||||
return m_cont.size();
|
||||
@@ -54,25 +54,25 @@ public:
|
||||
|
||||
/** Returns forward iterators for traversal. */
|
||||
/** @{ */
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const
|
||||
{
|
||||
return m_cont.cbegin();
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cbegin() const
|
||||
{
|
||||
return m_cont.cbegin();
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const
|
||||
{
|
||||
return m_cont.cend();
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cend() const
|
||||
{
|
||||
return m_cont.cend();
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
recorder() = default;
|
||||
|
||||
/** Returns a report with the results of all completed suites. */
|
||||
[[nodiscard]] results const&
|
||||
results const&
|
||||
report() const
|
||||
{
|
||||
return m_results;
|
||||
|
||||
@@ -41,14 +41,14 @@ private:
|
||||
tests_t() = default;
|
||||
|
||||
/** Returns the total number of test conditions. */
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
total() const
|
||||
{
|
||||
return cont().size();
|
||||
}
|
||||
|
||||
/** Returns the number of failed test conditions. */
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
failed() const
|
||||
{
|
||||
return failed_;
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
}
|
||||
|
||||
/** Returns the name of this testcase. */
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
name() const
|
||||
{
|
||||
return name_;
|
||||
@@ -118,21 +118,21 @@ public:
|
||||
}
|
||||
|
||||
/** Returns the name of this suite. */
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
/** Returns the total number of test conditions. */
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
total() const
|
||||
{
|
||||
return total_;
|
||||
}
|
||||
|
||||
/** Returns the number of failures. */
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
failed() const
|
||||
{
|
||||
return failed_;
|
||||
@@ -173,21 +173,21 @@ public:
|
||||
results() = default;
|
||||
|
||||
/** Returns the total number of test cases. */
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
cases() const
|
||||
{
|
||||
return m_cases;
|
||||
}
|
||||
|
||||
/** Returns the total number of test conditions. */
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
total() const
|
||||
{
|
||||
return total_;
|
||||
}
|
||||
|
||||
/** Returns the number of failures. */
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
failed() const
|
||||
{
|
||||
return failed_;
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
}
|
||||
|
||||
/** Returns the argument string. */
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
arg() const
|
||||
{
|
||||
return arg_;
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
#include <xrpl/beast/unit_test/runner.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -25,7 +25,7 @@ make_reason(String const& reason, char const* file, int line)
|
||||
std::string s(reason);
|
||||
if (!s.empty())
|
||||
s.append(": ");
|
||||
namespace fs = std::filesystem;
|
||||
namespace fs = boost::filesystem;
|
||||
s.append(fs::path{file}.filename().string());
|
||||
s.append("(");
|
||||
s.append(boost::lexical_cast<std::string>(line));
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
// in the event of a failure, if the option to stop is set.
|
||||
struct abort_exception : public std::exception
|
||||
{
|
||||
[[nodiscard]] char const*
|
||||
char const*
|
||||
what() const noexcept override
|
||||
{
|
||||
return "test suite aborted";
|
||||
|
||||
@@ -42,33 +42,33 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
module() const
|
||||
{
|
||||
return module_;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
library() const
|
||||
{
|
||||
return library_;
|
||||
}
|
||||
|
||||
/// Returns `true` if this suite only runs manually.
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
manual() const
|
||||
{
|
||||
return manual_;
|
||||
}
|
||||
|
||||
/// Return the canonical suite name as a string.
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
full_name() const
|
||||
{
|
||||
return library_ + "." + module_ + "." + name_;
|
||||
|
||||
@@ -47,13 +47,13 @@ public:
|
||||
t_ = std::thread(&Thread::run, this, std::move(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
joinable() const
|
||||
{
|
||||
return t_.joinable();
|
||||
}
|
||||
|
||||
[[nodiscard]] std::thread::id
|
||||
std::thread::id
|
||||
get_id() const
|
||||
{
|
||||
return t_.get_id();
|
||||
|
||||
@@ -66,12 +66,12 @@ public:
|
||||
operator=(Sink const& lhs) = delete;
|
||||
|
||||
/** Returns `true` if text at the passed severity produces output. */
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
active(Severity level) const;
|
||||
|
||||
/** Returns `true` if a message is also written to the Output Window
|
||||
* (MSVC). */
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
console() const;
|
||||
|
||||
/** Set whether messages are also written to the Output Window (MSVC).
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
console(bool output);
|
||||
|
||||
/** Returns the minimum severity level this sink will report. */
|
||||
[[nodiscard]] virtual Severity
|
||||
virtual Severity
|
||||
threshold() const;
|
||||
|
||||
/** Set the minimum severity this sink will report. */
|
||||
@@ -204,14 +204,14 @@ public:
|
||||
operator=(Stream const& other) = delete;
|
||||
|
||||
/** Returns the Sink that this Stream writes to. */
|
||||
[[nodiscard]] Sink&
|
||||
Sink&
|
||||
sink() const
|
||||
{
|
||||
return m_sink;
|
||||
}
|
||||
|
||||
/** Returns the Severity level of messages this Stream reports. */
|
||||
[[nodiscard]] Severity
|
||||
Severity
|
||||
level() const
|
||||
{
|
||||
return m_level;
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
|
||||
/** Returns `true` if sink logs anything at this stream's level. */
|
||||
/** @{ */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
active() const
|
||||
{
|
||||
return m_sink.active(m_level);
|
||||
@@ -267,14 +267,14 @@ public:
|
||||
}
|
||||
|
||||
/** Returns the Sink associated with this Journal. */
|
||||
[[nodiscard]] Sink&
|
||||
Sink&
|
||||
sink() const
|
||||
{
|
||||
return *m_sink;
|
||||
}
|
||||
|
||||
/** Returns a stream for this sink, with the specified severity level. */
|
||||
[[nodiscard]] Stream
|
||||
Stream
|
||||
stream(Severity level) const
|
||||
{
|
||||
return Stream(*m_sink, level);
|
||||
@@ -284,7 +284,7 @@ public:
|
||||
For a message to be logged, the severity must be at or above the
|
||||
sink's severity threshold.
|
||||
*/
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
active(Severity level) const
|
||||
{
|
||||
return m_sink->active(level);
|
||||
@@ -292,37 +292,37 @@ public:
|
||||
|
||||
/** Severity stream access functions. */
|
||||
/** @{ */
|
||||
[[nodiscard]] Stream
|
||||
Stream
|
||||
trace() const
|
||||
{
|
||||
return {*m_sink, severities::kTrace};
|
||||
}
|
||||
|
||||
[[nodiscard]] Stream
|
||||
Stream
|
||||
debug() const
|
||||
{
|
||||
return {*m_sink, severities::kDebug};
|
||||
}
|
||||
|
||||
[[nodiscard]] Stream
|
||||
Stream
|
||||
info() const
|
||||
{
|
||||
return {*m_sink, severities::kInfo};
|
||||
}
|
||||
|
||||
[[nodiscard]] Stream
|
||||
Stream
|
||||
warn() const
|
||||
{
|
||||
return {*m_sink, severities::kWarning};
|
||||
}
|
||||
|
||||
[[nodiscard]] Stream
|
||||
Stream
|
||||
error() const
|
||||
{
|
||||
return {*m_sink, severities::kError};
|
||||
}
|
||||
|
||||
[[nodiscard]] Stream
|
||||
Stream
|
||||
fatal() const
|
||||
{
|
||||
return {*m_sink, severities::kFatal};
|
||||
|
||||
@@ -149,7 +149,7 @@ class PropertyStream::Item : public List<Item>::Node
|
||||
{
|
||||
public:
|
||||
explicit Item(Source* source);
|
||||
[[nodiscard]] Source&
|
||||
Source&
|
||||
source() const;
|
||||
Source*
|
||||
operator->() const;
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
|
||||
PropertyStream&
|
||||
stream();
|
||||
[[nodiscard]] PropertyStream const&
|
||||
PropertyStream const&
|
||||
stream() const;
|
||||
|
||||
template <typename Value>
|
||||
@@ -287,7 +287,7 @@ public:
|
||||
|
||||
PropertyStream&
|
||||
stream();
|
||||
[[nodiscard]] PropertyStream const&
|
||||
PropertyStream const&
|
||||
stream() const;
|
||||
|
||||
template <typename Value>
|
||||
@@ -323,7 +323,7 @@ public:
|
||||
operator=(Source const&) = delete;
|
||||
|
||||
/** Returns the name of this source. */
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
name() const;
|
||||
|
||||
/** Add a child source. */
|
||||
|
||||
@@ -35,13 +35,13 @@ public:
|
||||
prefix_ = s;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
active(beast::severities::Severity level) const override
|
||||
{
|
||||
return sink_.active(level);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
console() const override
|
||||
{
|
||||
return sink_.console();
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
sink_.console(output);
|
||||
}
|
||||
|
||||
[[nodiscard]] beast::severities::Severity
|
||||
beast::severities::Severity
|
||||
threshold() const override
|
||||
{
|
||||
return sink_.threshold();
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <iomanip>
|
||||
#include <random>
|
||||
#include <sstream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -16,7 +13,7 @@ namespace beast {
|
||||
*/
|
||||
class temp_dir
|
||||
{
|
||||
std::filesystem::path path_;
|
||||
boost::filesystem::path path_;
|
||||
|
||||
public:
|
||||
#if !GENERATING_DOCS
|
||||
@@ -28,35 +25,25 @@ public:
|
||||
/// Construct a temporary directory.
|
||||
temp_dir()
|
||||
{
|
||||
auto const dir = std::filesystem::temp_directory_path();
|
||||
std::random_device rd;
|
||||
constexpr std::size_t maxAttempts = 100;
|
||||
for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt)
|
||||
auto const dir = boost::filesystem::temp_directory_path();
|
||||
do
|
||||
{
|
||||
std::error_code ec;
|
||||
std::ostringstream oss;
|
||||
oss << std::hex << std::setfill('0') << std::setw(8) << rd() << std::setw(8) << rd();
|
||||
path_ = dir / oss.str();
|
||||
if (!std::filesystem::exists(path_, ec) && !ec)
|
||||
break;
|
||||
path_.clear();
|
||||
}
|
||||
if (path_.empty())
|
||||
throw std::runtime_error("Unable to generate a unique temporary directory path");
|
||||
std::filesystem::create_directory(path_);
|
||||
path_ = dir / boost::filesystem::unique_path();
|
||||
} while (boost::filesystem::exists(path_));
|
||||
boost::filesystem::create_directory(path_);
|
||||
}
|
||||
|
||||
/// Destroy a temporary directory.
|
||||
~temp_dir()
|
||||
{
|
||||
// use non-throwing calls in the destructor
|
||||
std::error_code ec;
|
||||
std::filesystem::remove_all(path_, ec);
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::remove_all(path_, ec);
|
||||
// TODO: warn/notify if ec set ?
|
||||
}
|
||||
|
||||
/// Get the native path for the temporary directory
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
path() const
|
||||
{
|
||||
return path_.string();
|
||||
@@ -66,7 +53,7 @@ public:
|
||||
|
||||
The file does not need to exist.
|
||||
*/
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
file(std::string const& name) const
|
||||
{
|
||||
return (path_ / name).string();
|
||||
|
||||
@@ -41,15 +41,15 @@ public:
|
||||
with respect to other conditions of the
|
||||
same type.
|
||||
*/
|
||||
[[nodiscard]] virtual Buffer
|
||||
virtual Buffer
|
||||
fingerprint() const = 0;
|
||||
|
||||
/** Returns the type of this condition. */
|
||||
[[nodiscard]] virtual Type
|
||||
virtual Type
|
||||
type() const = 0;
|
||||
|
||||
/** Validates a fulfillment. */
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
validate(Slice data) const = 0;
|
||||
|
||||
/** Calculates the cost associated with this fulfillment. *
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
type and properties of the condition and the fulfillment
|
||||
that the condition is generated from.
|
||||
*/
|
||||
[[nodiscard]] virtual std::uint32_t
|
||||
virtual std::uint32_t
|
||||
cost() const = 0;
|
||||
|
||||
/** Returns the condition associated with the given fulfillment.
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
will, if compliant, produce the identical condition for the
|
||||
same fulfillment.
|
||||
*/
|
||||
[[nodiscard]] virtual Condition
|
||||
virtual Condition
|
||||
condition() const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -90,13 +90,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] Type
|
||||
Type
|
||||
type() const override
|
||||
{
|
||||
return Type::preimageSha256;
|
||||
}
|
||||
|
||||
[[nodiscard]] Buffer
|
||||
Buffer
|
||||
fingerprint() const override
|
||||
{
|
||||
sha256_hasher h;
|
||||
@@ -105,19 +105,19 @@ public:
|
||||
return {d.data(), d.size()};
|
||||
}
|
||||
|
||||
[[nodiscard]] std::uint32_t
|
||||
std::uint32_t
|
||||
cost() const override
|
||||
{
|
||||
return static_cast<std::uint32_t>(payload_.size());
|
||||
}
|
||||
|
||||
[[nodiscard]] Condition
|
||||
Condition
|
||||
condition() const override
|
||||
{
|
||||
return {type(), cost(), fingerprint()};
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
validate(Slice) const override
|
||||
{
|
||||
// Perhaps counterintuitively, the message isn't
|
||||
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
{
|
||||
private:
|
||||
ClosureCounter& counter_;
|
||||
std::remove_reference_t<Closure> closure_{};
|
||||
std::remove_reference_t<Closure> closure_;
|
||||
|
||||
static_assert(
|
||||
std::is_same_v<decltype(closure_(std::declval<Args_t>()...)), Ret_t>,
|
||||
|
||||
@@ -118,7 +118,7 @@ private:
|
||||
peers_.insert(peer);
|
||||
}
|
||||
|
||||
[[nodiscard]] HashRouterFlags
|
||||
HashRouterFlags
|
||||
getFlags(void) const
|
||||
{
|
||||
return flags_;
|
||||
@@ -138,7 +138,7 @@ private:
|
||||
}
|
||||
|
||||
/** Return seated relay time point if the message has been relayed */
|
||||
[[nodiscard]] std::optional<Stopwatch::time_point>
|
||||
std::optional<Stopwatch::time_point>
|
||||
relayed() const
|
||||
{
|
||||
return relayed_;
|
||||
|
||||
@@ -98,11 +98,11 @@ public:
|
||||
LoadMonitor& lm,
|
||||
std::function<void()> const& job);
|
||||
|
||||
[[nodiscard]] JobType
|
||||
JobType
|
||||
getType() const;
|
||||
|
||||
/** Returns the time when the job was queued. */
|
||||
[[nodiscard]] clock_type::time_point const&
|
||||
clock_type::time_point const&
|
||||
queue_time() const;
|
||||
|
||||
void
|
||||
|
||||
@@ -7,13 +7,8 @@
|
||||
#include <xrpl/core/detail/Workers.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
|
||||
// Include only the specific Boost.Coroutine2 headers actually used here.
|
||||
// Avoid `boost/coroutine2/all.hpp` because it transitively pulls in
|
||||
// `boost/context/pooled_fixedsize_stack.hpp`, whose `.malloc()` / `.free()`
|
||||
// member calls on `boost::pool` collide with MSVC's `_CRTDBG_MAP_ALLOC` macros
|
||||
// in Debug builds (see cmake/XrplCompiler.cmake).
|
||||
#include <boost/context/protected_fixedsize_stack.hpp>
|
||||
#include <boost/coroutine2/coroutine.hpp>
|
||||
#include <boost/coroutine2/all.hpp>
|
||||
|
||||
#include <set>
|
||||
|
||||
|
||||
@@ -54,13 +54,13 @@ public:
|
||||
JobTypeData&
|
||||
operator=(JobTypeData const& other) = delete;
|
||||
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
name() const
|
||||
{
|
||||
return info.name();
|
||||
}
|
||||
|
||||
[[nodiscard]] JobType
|
||||
JobType
|
||||
type() const
|
||||
{
|
||||
return info.type();
|
||||
|
||||
@@ -40,37 +40,37 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] JobType
|
||||
JobType
|
||||
type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
[[nodiscard]] int
|
||||
int
|
||||
limit() const
|
||||
{
|
||||
return m_limit;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
special() const
|
||||
{
|
||||
return m_limit == 0;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::chrono::milliseconds
|
||||
std::chrono::milliseconds
|
||||
getAverageLatency() const
|
||||
{
|
||||
return m_avgLatency;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::chrono::milliseconds
|
||||
std::chrono::milliseconds
|
||||
getPeakLatency() const
|
||||
{
|
||||
return m_peakLatency;
|
||||
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
return instance().get(jt).name();
|
||||
}
|
||||
|
||||
[[nodiscard]] JobTypeInfo const&
|
||||
JobTypeInfo const&
|
||||
get(JobType jt) const
|
||||
{
|
||||
Map::const_iterator const iter(m_map.find(jt));
|
||||
@@ -125,37 +125,37 @@ public:
|
||||
return m_unknown;
|
||||
}
|
||||
|
||||
[[nodiscard]] JobTypeInfo const&
|
||||
JobTypeInfo const&
|
||||
getInvalid() const
|
||||
{
|
||||
return m_unknown;
|
||||
}
|
||||
|
||||
[[nodiscard]] Map::size_type
|
||||
Map::size_type
|
||||
size() const
|
||||
{
|
||||
return m_map.size();
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const
|
||||
{
|
||||
return m_map.cbegin();
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cbegin() const
|
||||
{
|
||||
return m_map.cbegin();
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const
|
||||
{
|
||||
return m_map.cend();
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
cend() const
|
||||
{
|
||||
return m_map.cend();
|
||||
|
||||
@@ -21,15 +21,15 @@ public:
|
||||
|
||||
~LoadEvent();
|
||||
|
||||
[[nodiscard]] std::string const&
|
||||
std::string const&
|
||||
name() const;
|
||||
|
||||
// The time spent waiting.
|
||||
[[nodiscard]] std::chrono::steady_clock::duration
|
||||
std::chrono::steady_clock::duration
|
||||
waitTime() const;
|
||||
|
||||
// The time spent running.
|
||||
[[nodiscard]] std::chrono::steady_clock::duration
|
||||
std::chrono::steady_clock::duration
|
||||
runTime() const;
|
||||
|
||||
void
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
*
|
||||
* @return The network ID this server is configured for
|
||||
*/
|
||||
[[nodiscard]] virtual std::uint32_t
|
||||
virtual std::uint32_t
|
||||
getNetworkID() const noexcept = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
PublicKey nodeId;
|
||||
std::string description = {}; // NOLINT(readability-redundant-member-init)
|
||||
|
||||
[[nodiscard]] auto
|
||||
auto
|
||||
toJson() const -> Json::Value;
|
||||
|
||||
template <typename Hasher>
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
#include <xrpl/core/JobTypes.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -42,7 +43,7 @@ public:
|
||||
*/
|
||||
struct Setup
|
||||
{
|
||||
std::filesystem::path perfLog;
|
||||
boost::filesystem::path perfLog;
|
||||
// log_interval is in milliseconds to support faster testing.
|
||||
milliseconds logInterval{seconds(1)};
|
||||
};
|
||||
@@ -120,7 +121,7 @@ public:
|
||||
*
|
||||
* @return Counters Json object
|
||||
*/
|
||||
[[nodiscard]] virtual Json::Value
|
||||
virtual Json::Value
|
||||
countersJson() const = 0;
|
||||
|
||||
/**
|
||||
@@ -128,7 +129,7 @@ public:
|
||||
*
|
||||
* @return Current executing jobs and RPC calls and durations
|
||||
*/
|
||||
[[nodiscard]] virtual Json::Value
|
||||
virtual Json::Value
|
||||
currentJson() const = 0;
|
||||
|
||||
/**
|
||||
@@ -147,7 +148,7 @@ public:
|
||||
};
|
||||
|
||||
PerfLog::Setup
|
||||
setup_PerfLog(Section const& section, std::filesystem::path const& configDir);
|
||||
setup_PerfLog(Section const& section, boost::filesystem::path const& configDir);
|
||||
|
||||
std::unique_ptr<PerfLog>
|
||||
make_PerfLog(
|
||||
|
||||
@@ -192,7 +192,7 @@ public:
|
||||
virtual OpenLedger&
|
||||
getOpenLedger() = 0;
|
||||
|
||||
[[nodiscard]] virtual OpenLedger const&
|
||||
virtual OpenLedger const&
|
||||
getOpenLedger() const = 0;
|
||||
|
||||
// Transaction and operation services
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
getPerfLog() = 0;
|
||||
|
||||
// Configuration and state
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
isStopping() const = 0;
|
||||
|
||||
virtual beast::Journal
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
virtual Logs&
|
||||
getLogs() = 0;
|
||||
|
||||
[[nodiscard]] virtual std::optional<uint256> const&
|
||||
virtual std::optional<uint256> const&
|
||||
getTrapTxID() const = 0;
|
||||
|
||||
/** Retrieve the "wallet database" */
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
|
||||
@note This function is not thread-safe.
|
||||
*/
|
||||
[[nodiscard]] int
|
||||
int
|
||||
getNumberOfThreads() const noexcept;
|
||||
|
||||
/** Set the desired number of threads.
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
While this function is thread-safe, the value may not stay
|
||||
accurate for very long. It's mainly for diagnostic purposes.
|
||||
*/
|
||||
[[nodiscard]] int
|
||||
int
|
||||
numberOfCurrentlyRunningTasks() const noexcept;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
|
||||
public:
|
||||
JsonPropertyStream();
|
||||
[[nodiscard]] Json::Value const&
|
||||
Json::Value const&
|
||||
top() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
* their location in the parsed document. An empty string is returned if no
|
||||
* error occurred during parsing.
|
||||
*/
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
getFormattedErrorMessages() const;
|
||||
|
||||
static constexpr unsigned nest_limit{25};
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
return str_;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr char const*
|
||||
constexpr char const*
|
||||
c_str() const
|
||||
{
|
||||
return str_;
|
||||
@@ -158,11 +158,11 @@ private:
|
||||
operator<(CZString const& other) const;
|
||||
bool
|
||||
operator==(CZString const& other) const;
|
||||
[[nodiscard]] int
|
||||
int
|
||||
index() const;
|
||||
[[nodiscard]] char const*
|
||||
char const*
|
||||
c_str() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isStaticString() const;
|
||||
|
||||
private:
|
||||
@@ -223,60 +223,60 @@ public:
|
||||
void
|
||||
swap(Value& other) noexcept;
|
||||
|
||||
[[nodiscard]] ValueType
|
||||
ValueType
|
||||
type() const;
|
||||
|
||||
[[nodiscard]] char const*
|
||||
char const*
|
||||
asCString() const;
|
||||
/** Returns the unquoted string value. */
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
asString() const;
|
||||
[[nodiscard]] Int
|
||||
Int
|
||||
asInt() const;
|
||||
[[nodiscard]] UInt
|
||||
UInt
|
||||
asUInt() const;
|
||||
[[nodiscard]] double
|
||||
double
|
||||
asDouble() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
asBool() const;
|
||||
|
||||
/** Correct absolute value from int or unsigned int */
|
||||
[[nodiscard]] UInt
|
||||
UInt
|
||||
asAbsUInt() const;
|
||||
|
||||
// TODO: What is the "empty()" method this docstring mentions?
|
||||
/** isNull() tests to see if this field is null. Don't use this method to
|
||||
test for emptiness: use empty(). */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isNull() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isBool() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isInt() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isUInt() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isIntegral() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isDouble() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isNumeric() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isString() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isArray() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isArrayOrNull() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isObject() const;
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isObjectOrNull() const;
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isConvertibleTo(ValueType other) const;
|
||||
|
||||
/// Number of values in array or object
|
||||
[[nodiscard]] UInt
|
||||
UInt
|
||||
size() const;
|
||||
|
||||
/** Returns false if this is an empty array, empty object, empty string,
|
||||
@@ -304,10 +304,10 @@ public:
|
||||
operator[](UInt index) const;
|
||||
/// If the array contains at least index+1 elements, returns the element
|
||||
/// value, otherwise returns defaultValue.
|
||||
[[nodiscard]] Value
|
||||
Value
|
||||
get(UInt index, Value const& defaultValue) const;
|
||||
/// Return true if index < size().
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isValidIndex(UInt index) const;
|
||||
/// \brief Append value to array at the end.
|
||||
///
|
||||
@@ -355,7 +355,7 @@ public:
|
||||
Value
|
||||
get(char const* key, Value const& defaultValue) const;
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
[[nodiscard]] Value
|
||||
Value
|
||||
get(std::string const& key, Value const& defaultValue) const;
|
||||
|
||||
/// \brief Remove and return the named member.
|
||||
@@ -374,10 +374,10 @@ public:
|
||||
bool
|
||||
isMember(char const* key) const;
|
||||
/// Return true if the object has a member named key.
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isMember(std::string const& key) const;
|
||||
/// Return true if the object has a member named key.
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isMember(StaticString const& key) const;
|
||||
|
||||
/// \brief Return a list of the member names.
|
||||
@@ -385,15 +385,15 @@ public:
|
||||
/// If null, return an empty list.
|
||||
/// \pre type() is objectValue or nullValue
|
||||
/// \post if type() was nullValue, it remains nullValue
|
||||
[[nodiscard]] Members
|
||||
Members
|
||||
getMemberNames() const;
|
||||
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
toStyledString() const;
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const;
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const;
|
||||
|
||||
iterator
|
||||
@@ -513,20 +513,20 @@ public:
|
||||
|
||||
/// Return either the index or the member name of the referenced value as a
|
||||
/// Value.
|
||||
[[nodiscard]] Value
|
||||
Value
|
||||
key() const;
|
||||
|
||||
/// Return the index of the referenced Value. -1 if it is not an arrayValue.
|
||||
[[nodiscard]] UInt
|
||||
UInt
|
||||
index() const;
|
||||
|
||||
/// Return the member name of the referenced Value. "" if it is not an
|
||||
/// objectValue.
|
||||
[[nodiscard]] char const*
|
||||
char const*
|
||||
memberName() const;
|
||||
|
||||
protected:
|
||||
[[nodiscard]] Value&
|
||||
Value&
|
||||
deref() const;
|
||||
|
||||
void
|
||||
@@ -535,10 +535,10 @@ protected:
|
||||
void
|
||||
decrement();
|
||||
|
||||
[[nodiscard]] difference_type
|
||||
difference_type
|
||||
computeDistance(SelfType const& other) const;
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isEqual(SelfType const& other) const;
|
||||
|
||||
void
|
||||
|
||||
@@ -30,47 +30,47 @@ public:
|
||||
std::shared_ptr<STTx const> const&,
|
||||
std::shared_ptr<STObject const> const&);
|
||||
|
||||
[[nodiscard]] std::shared_ptr<STTx const> const&
|
||||
std::shared_ptr<STTx const> const&
|
||||
getTxn() const
|
||||
{
|
||||
return mTxn;
|
||||
}
|
||||
[[nodiscard]] TxMeta const&
|
||||
TxMeta const&
|
||||
getMeta() const
|
||||
{
|
||||
return mMeta;
|
||||
}
|
||||
|
||||
[[nodiscard]] boost::container::flat_set<AccountID> const&
|
||||
boost::container::flat_set<AccountID> const&
|
||||
getAffected() const
|
||||
{
|
||||
return mAffected;
|
||||
}
|
||||
|
||||
[[nodiscard]] TxID
|
||||
TxID
|
||||
getTransactionID() const
|
||||
{
|
||||
return mTxn->getTransactionID();
|
||||
}
|
||||
[[nodiscard]] TxType
|
||||
TxType
|
||||
getTxnType() const
|
||||
{
|
||||
return mTxn->getTxnType();
|
||||
}
|
||||
[[nodiscard]] TER
|
||||
TER
|
||||
getResult() const
|
||||
{
|
||||
return mMeta.getResultTER();
|
||||
}
|
||||
[[nodiscard]] std::uint32_t
|
||||
std::uint32_t
|
||||
getTxnSeq() const
|
||||
{
|
||||
return mMeta.getIndex();
|
||||
}
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
getEscMeta() const;
|
||||
|
||||
[[nodiscard]] Json::Value const&
|
||||
Json::Value const&
|
||||
getJson() const
|
||||
{
|
||||
return mJson;
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
|
||||
virtual ~AmendmentTable() = default;
|
||||
|
||||
[[nodiscard]] virtual uint256
|
||||
virtual uint256
|
||||
find(std::string const& name) const = 0;
|
||||
|
||||
virtual bool
|
||||
@@ -47,9 +47,9 @@ public:
|
||||
virtual bool
|
||||
enable(uint256 const& amendment) = 0;
|
||||
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
isEnabled(uint256 const& amendment) const = 0;
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
isSupported(uint256 const& amendment) const = 0;
|
||||
|
||||
/**
|
||||
@@ -58,17 +58,17 @@ public:
|
||||
*
|
||||
* @return true if an unsupported feature is enabled on the network
|
||||
*/
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
hasUnsupportedEnabled() const = 0;
|
||||
|
||||
[[nodiscard]] virtual std::optional<NetClock::time_point>
|
||||
virtual std::optional<NetClock::time_point>
|
||||
firstUnsupportedExpected() const = 0;
|
||||
|
||||
[[nodiscard]] virtual Json::Value
|
||||
virtual Json::Value
|
||||
getJson(bool isAdmin) const = 0;
|
||||
|
||||
/** Returns a Json::objectValue. */
|
||||
[[nodiscard]] virtual Json::Value
|
||||
virtual Json::Value
|
||||
getJson(uint256 const& amendment, bool isAdmin) const = 0;
|
||||
|
||||
/** Called when a new fully-validated ledger is accepted. */
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
/** Called to determine whether the amendment logic needs to process
|
||||
a new validated ledger. (If it could have changed things.)
|
||||
*/
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
needValidatedLedger(LedgerIndex seq) const = 0;
|
||||
|
||||
virtual void
|
||||
@@ -112,14 +112,14 @@ public:
|
||||
|
||||
// Called by the consensus code when we need to
|
||||
// add feature entries to a validation
|
||||
[[nodiscard]] virtual std::vector<uint256>
|
||||
virtual std::vector<uint256>
|
||||
doValidation(std::set<uint256> const& enabled) const = 0;
|
||||
|
||||
// The set of amendments to enable in the genesis ledger
|
||||
// This will return all known, non-vetoed amendments.
|
||||
// If we ever have two amendments that should not both be
|
||||
// enabled at the same time, we should ensure one is vetoed.
|
||||
[[nodiscard]] virtual std::vector<uint256>
|
||||
virtual std::vector<uint256>
|
||||
getDesired() const = 0;
|
||||
|
||||
// The function below adapts the API callers expect to the
|
||||
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
while transactions applied to the consensus
|
||||
ledger produce hard failures (and claim a fee).
|
||||
*/
|
||||
[[nodiscard]] virtual ApplyFlags
|
||||
virtual ApplyFlags
|
||||
flags() const = 0;
|
||||
|
||||
/** Prepare to modify the SLE associated with key.
|
||||
|
||||
@@ -22,10 +22,10 @@ public:
|
||||
|
||||
BookDirs(ReadView const&, Book const&);
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const;
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -59,13 +59,13 @@ private:
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] uint256 const&
|
||||
uint256 const&
|
||||
getAccount() const
|
||||
{
|
||||
return account_;
|
||||
}
|
||||
|
||||
[[nodiscard]] uint256 const&
|
||||
uint256 const&
|
||||
getTXID() const
|
||||
{
|
||||
return txId_;
|
||||
@@ -118,30 +118,30 @@ public:
|
||||
return map_.erase(it);
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const
|
||||
{
|
||||
return map_.begin();
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const
|
||||
{
|
||||
return map_.end();
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t
|
||||
size_t
|
||||
size() const
|
||||
{
|
||||
return map_.size();
|
||||
}
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
empty() const
|
||||
{
|
||||
return map_.empty();
|
||||
}
|
||||
|
||||
[[nodiscard]] uint256 const&
|
||||
uint256 const&
|
||||
key() const
|
||||
{
|
||||
return salt_;
|
||||
|
||||
@@ -31,10 +31,10 @@ public:
|
||||
|
||||
Dir(ReadView const&, Keylet const&);
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
begin() const;
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
const_iterator
|
||||
end() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,8 +21,9 @@ private:
|
||||
struct ValueIOU
|
||||
{
|
||||
explicit ValueIOU() = default;
|
||||
STAmount lowAcctDebits;
|
||||
STAmount highAcctDebits;
|
||||
|
||||
STAmount lowAcctCredits;
|
||||
STAmount highAcctCredits;
|
||||
STAmount lowAcctOrigBalance;
|
||||
};
|
||||
|
||||
@@ -74,10 +75,10 @@ public:
|
||||
|
||||
// Get the adjustments for the balance between main and other.
|
||||
// Returns the debits, credits and the original balance
|
||||
[[nodiscard]] std::optional<AdjustmentIOU>
|
||||
std::optional<AdjustmentIOU>
|
||||
adjustmentsIOU(AccountID const& main, AccountID const& other, Currency const& currency) const;
|
||||
|
||||
[[nodiscard]] std::optional<AdjustmentMPT>
|
||||
std::optional<AdjustmentMPT>
|
||||
adjustmentsMPT(MPTID const& mptID) const;
|
||||
|
||||
void
|
||||
@@ -104,7 +105,7 @@ public:
|
||||
// Get the adjusted owner count. Since DeferredCredits is meant to be used
|
||||
// in payments, and payments only decrease owner counts, return the max
|
||||
// remembered owner count.
|
||||
[[nodiscard]] std::optional<std::uint32_t>
|
||||
std::optional<std::uint32_t>
|
||||
ownerCount(AccountID const& id) const;
|
||||
|
||||
void
|
||||
@@ -179,15 +180,15 @@ public:
|
||||
}
|
||||
/** @} */
|
||||
|
||||
[[nodiscard]] STAmount
|
||||
STAmount
|
||||
balanceHookIOU(AccountID const& account, AccountID const& issuer, STAmount const& amount)
|
||||
const override;
|
||||
|
||||
[[nodiscard]] STAmount
|
||||
STAmount
|
||||
balanceHookMPT(AccountID const& account, MPTIssue const& issue, std::int64_t amount)
|
||||
const override;
|
||||
|
||||
[[nodiscard]] STAmount
|
||||
STAmount
|
||||
balanceHookSelfIssueMPT(MPTIssue const& issue, std::int64_t amount) const override;
|
||||
|
||||
void
|
||||
@@ -212,7 +213,7 @@ public:
|
||||
void
|
||||
adjustOwnerCountHook(AccountID const& account, std::uint32_t cur, std::uint32_t next) override;
|
||||
|
||||
[[nodiscard]] std::uint32_t
|
||||
std::uint32_t
|
||||
ownerCountHook(AccountID const& account, std::uint32_t count) const override;
|
||||
|
||||
/** Apply changes to base view.
|
||||
@@ -229,7 +230,14 @@ public:
|
||||
apply(PaymentSandbox& to);
|
||||
/** @} */
|
||||
|
||||
[[nodiscard]] XRPAmount
|
||||
// Return a map of balance changes on trust lines. The low account is the
|
||||
// first account in the key. If the two accounts are equal, the map contains
|
||||
// the total changes in currency regardless of issuer. This is useful to get
|
||||
// the total change in XRP balances.
|
||||
std::map<std::tuple<AccountID, AccountID, Currency>, STAmount>
|
||||
balanceChanges(ReadView const& view) const;
|
||||
|
||||
XRPAmount
|
||||
xrpDestroyed() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -39,22 +39,22 @@ public:
|
||||
struct sles_type : detail::ReadViewFwdRange<std::shared_ptr<SLE const>>
|
||||
{
|
||||
explicit sles_type(ReadView const& view);
|
||||
[[nodiscard]] iterator
|
||||
iterator
|
||||
begin() const;
|
||||
[[nodiscard]] iterator
|
||||
iterator
|
||||
end() const;
|
||||
[[nodiscard]] iterator
|
||||
iterator
|
||||
upper_bound(key_type const& key) const;
|
||||
};
|
||||
|
||||
struct txs_type : detail::ReadViewFwdRange<tx_type>
|
||||
{
|
||||
explicit txs_type(ReadView const& view);
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
empty() const;
|
||||
[[nodiscard]] iterator
|
||||
iterator
|
||||
begin() const;
|
||||
[[nodiscard]] iterator
|
||||
iterator
|
||||
end() const;
|
||||
};
|
||||
|
||||
@@ -78,33 +78,33 @@ public:
|
||||
}
|
||||
|
||||
/** Returns information about the ledger. */
|
||||
[[nodiscard]] virtual LedgerHeader const&
|
||||
virtual LedgerHeader const&
|
||||
header() const = 0;
|
||||
|
||||
/** Returns true if this reflects an open ledger. */
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
open() const = 0;
|
||||
|
||||
/** Returns the close time of the previous ledger. */
|
||||
[[nodiscard]] NetClock::time_point
|
||||
NetClock::time_point
|
||||
parentCloseTime() const
|
||||
{
|
||||
return header().parentCloseTime;
|
||||
}
|
||||
|
||||
/** Returns the sequence number of the base ledger. */
|
||||
[[nodiscard]] LedgerIndex
|
||||
LedgerIndex
|
||||
seq() const
|
||||
{
|
||||
return header().seq;
|
||||
}
|
||||
|
||||
/** Returns the fees for the base ledger. */
|
||||
[[nodiscard]] virtual Fees const&
|
||||
virtual Fees const&
|
||||
fees() const = 0;
|
||||
|
||||
/** Returns the tx processing rules. */
|
||||
[[nodiscard]] virtual Rules const&
|
||||
virtual Rules const&
|
||||
rules() const = 0;
|
||||
|
||||
/** Determine if a state item exists.
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
@return `true` if a SLE is associated with the
|
||||
specified key.
|
||||
*/
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
exists(Keylet const& k) const = 0;
|
||||
|
||||
/** Return the key of the next state item.
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
the key returned would be outside the open
|
||||
interval (key, last).
|
||||
*/
|
||||
[[nodiscard]] virtual std::optional<key_type>
|
||||
virtual std::optional<key_type>
|
||||
succ(key_type const& key, std::optional<key_type> const& last = std::nullopt) const = 0;
|
||||
|
||||
/** Return the state item associated with a key.
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
@return `nullptr` if the key is not present or
|
||||
if the type does not match.
|
||||
*/
|
||||
[[nodiscard]] virtual std::shared_ptr<SLE const>
|
||||
virtual std::shared_ptr<SLE const>
|
||||
read(Keylet const& k) const = 0;
|
||||
|
||||
// Accounts in a payment are not allowed to use assets acquired during that
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
// changes that accounts make during a payment. `balanceHookIOU` adjusts
|
||||
// balances so newly acquired assets are not counted toward the balance.
|
||||
// This is required to support PaymentSandbox.
|
||||
[[nodiscard]] virtual STAmount
|
||||
virtual STAmount
|
||||
balanceHookIOU(AccountID const& account, AccountID const& issuer, STAmount const& amount) const
|
||||
{
|
||||
XRPL_ASSERT(amount.holds<Issue>(), "balanceHookIOU: amount is for Issue");
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
|
||||
// balanceHookMPT adjusts balances so newly acquired assets are not counted
|
||||
// toward the balance.
|
||||
[[nodiscard]] virtual STAmount
|
||||
virtual STAmount
|
||||
balanceHookMPT(AccountID const& account, MPTIssue const& issue, std::int64_t amount) const
|
||||
{
|
||||
return STAmount{issue, amount};
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
// funds available to issue, which are originally available funds less
|
||||
// already self sold MPT amounts (MPT sell offer). This hook is used
|
||||
// by issuerFundsToSelfIssue() function.
|
||||
[[nodiscard]] virtual STAmount
|
||||
virtual STAmount
|
||||
balanceHookSelfIssueMPT(MPTIssue const& issue, std::int64_t amount) const
|
||||
{
|
||||
return STAmount{issue, amount};
|
||||
@@ -182,30 +182,30 @@ public:
|
||||
// changes that accounts make during a payment. `ownerCountHook` adjusts the
|
||||
// ownerCount so it returns the max value of the ownerCount so far.
|
||||
// This is required to support PaymentSandbox.
|
||||
[[nodiscard]] virtual std::uint32_t
|
||||
virtual std::uint32_t
|
||||
ownerCountHook(AccountID const& account, std::uint32_t count) const
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
// used by the implementation
|
||||
[[nodiscard]] virtual std::unique_ptr<sles_type::iter_base>
|
||||
virtual std::unique_ptr<sles_type::iter_base>
|
||||
slesBegin() const = 0;
|
||||
|
||||
// used by the implementation
|
||||
[[nodiscard]] virtual std::unique_ptr<sles_type::iter_base>
|
||||
virtual std::unique_ptr<sles_type::iter_base>
|
||||
slesEnd() const = 0;
|
||||
|
||||
// used by the implementation
|
||||
[[nodiscard]] virtual std::unique_ptr<sles_type::iter_base>
|
||||
virtual std::unique_ptr<sles_type::iter_base>
|
||||
slesUpperBound(key_type const& key) const = 0;
|
||||
|
||||
// used by the implementation
|
||||
[[nodiscard]] virtual std::unique_ptr<txs_type::iter_base>
|
||||
virtual std::unique_ptr<txs_type::iter_base>
|
||||
txsBegin() const = 0;
|
||||
|
||||
// used by the implementation
|
||||
[[nodiscard]] virtual std::unique_ptr<txs_type::iter_base>
|
||||
virtual std::unique_ptr<txs_type::iter_base>
|
||||
txsEnd() const = 0;
|
||||
|
||||
/** Returns `true` if a tx exists in the tx map.
|
||||
@@ -213,7 +213,7 @@ public:
|
||||
A tx exists in the map if it is part of the
|
||||
base ledger, or if it is a newly inserted tx.
|
||||
*/
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
txExists(key_type const& key) const = 0;
|
||||
|
||||
/** Read a transaction from the tx map.
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
@return A pair of nullptr if the
|
||||
key is not found in the tx map.
|
||||
*/
|
||||
[[nodiscard]] virtual tx_type
|
||||
virtual tx_type
|
||||
txRead(key_type const& key) const = 0;
|
||||
|
||||
//
|
||||
@@ -257,7 +257,7 @@ public:
|
||||
|
||||
@return std::nullopt if the item does not exist.
|
||||
*/
|
||||
[[nodiscard]] virtual std::optional<digest_type>
|
||||
virtual std::optional<digest_type>
|
||||
digest(key_type const& key) const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
// Forward declarations for SLE wrappers
|
||||
template <typename ViewT>
|
||||
class AccountRoot;
|
||||
using RAccountRoot = AccountRoot<ReadView>;
|
||||
|
||||
enum class SkipEntry : bool { No = false, Yes };
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -157,7 +162,7 @@ canWithdraw(
|
||||
ReadView const& view,
|
||||
AccountID const& from,
|
||||
AccountID const& to,
|
||||
SLE::const_ref toSle,
|
||||
RAccountRoot const& toWrapped,
|
||||
STAmount const& amount,
|
||||
bool hasDestinationTag);
|
||||
|
||||
|
||||
@@ -54,19 +54,19 @@ public:
|
||||
bool isDryRun,
|
||||
beast::Journal j);
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
exists(ReadView const& base, Keylet const& k) const;
|
||||
|
||||
[[nodiscard]] std::optional<key_type>
|
||||
std::optional<key_type>
|
||||
succ(ReadView const& base, key_type const& key, std::optional<key_type> const& last) const;
|
||||
|
||||
[[nodiscard]] std::shared_ptr<SLE const>
|
||||
std::shared_ptr<SLE const>
|
||||
read(ReadView const& base, Keylet const& k) const;
|
||||
|
||||
std::shared_ptr<SLE>
|
||||
peek(ReadView const& base, Keylet const& k);
|
||||
|
||||
[[nodiscard]] std::size_t
|
||||
std::size_t
|
||||
size() const;
|
||||
|
||||
void
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
destroyXRP(XRPAmount const& fee);
|
||||
|
||||
// For debugging
|
||||
[[nodiscard]] XRPAmount const&
|
||||
XRPAmount const&
|
||||
dropsDestroyed() const
|
||||
{
|
||||
return dropsDestroyed_;
|
||||
|
||||
@@ -22,51 +22,51 @@ public:
|
||||
ApplyViewBase(ReadView const* base, ApplyFlags flags);
|
||||
|
||||
// ReadView
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
open() const override;
|
||||
|
||||
[[nodiscard]] LedgerHeader const&
|
||||
LedgerHeader const&
|
||||
header() const override;
|
||||
|
||||
[[nodiscard]] Fees const&
|
||||
Fees const&
|
||||
fees() const override;
|
||||
|
||||
[[nodiscard]] Rules const&
|
||||
Rules const&
|
||||
rules() const override;
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
exists(Keylet const& k) const override;
|
||||
|
||||
[[nodiscard]] std::optional<key_type>
|
||||
std::optional<key_type>
|
||||
succ(key_type const& key, std::optional<key_type> const& last = std::nullopt) const override;
|
||||
|
||||
[[nodiscard]] std::shared_ptr<SLE const>
|
||||
std::shared_ptr<SLE const>
|
||||
read(Keylet const& k) const override;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<sles_type::iter_base>
|
||||
std::unique_ptr<sles_type::iter_base>
|
||||
slesBegin() const override;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<sles_type::iter_base>
|
||||
std::unique_ptr<sles_type::iter_base>
|
||||
slesEnd() const override;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<sles_type::iter_base>
|
||||
std::unique_ptr<sles_type::iter_base>
|
||||
slesUpperBound(uint256 const& key) const override;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<txs_type::iter_base>
|
||||
std::unique_ptr<txs_type::iter_base>
|
||||
txsBegin() const override;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<txs_type::iter_base>
|
||||
std::unique_ptr<txs_type::iter_base>
|
||||
txsEnd() const override;
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
txExists(key_type const& key) const override;
|
||||
|
||||
[[nodiscard]] tx_type
|
||||
tx_type
|
||||
txRead(key_type const& key) const override;
|
||||
|
||||
// ApplyView
|
||||
|
||||
[[nodiscard]] ApplyFlags
|
||||
ApplyFlags
|
||||
flags() const override;
|
||||
|
||||
std::shared_ptr<SLE>
|
||||
|
||||
@@ -42,10 +42,10 @@ public:
|
||||
void
|
||||
apply(RawView& to) const;
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
exists(ReadView const& base, Keylet const& k) const;
|
||||
|
||||
[[nodiscard]] std::optional<key_type>
|
||||
std::optional<key_type>
|
||||
succ(ReadView const& base, key_type const& key, std::optional<key_type> const& last) const;
|
||||
|
||||
void
|
||||
@@ -57,19 +57,19 @@ public:
|
||||
void
|
||||
replace(std::shared_ptr<SLE> const& sle);
|
||||
|
||||
[[nodiscard]] std::shared_ptr<SLE const>
|
||||
std::shared_ptr<SLE const>
|
||||
read(ReadView const& base, Keylet const& k) const;
|
||||
|
||||
void
|
||||
destroyXRP(XRPAmount const& fee);
|
||||
|
||||
[[nodiscard]] std::unique_ptr<ReadView::sles_type::iter_base>
|
||||
std::unique_ptr<ReadView::sles_type::iter_base>
|
||||
slesBegin(ReadView const& base) const;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<ReadView::sles_type::iter_base>
|
||||
std::unique_ptr<ReadView::sles_type::iter_base>
|
||||
slesEnd(ReadView const& base) const;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<ReadView::sles_type::iter_base>
|
||||
std::unique_ptr<ReadView::sles_type::iter_base>
|
||||
slesUpperBound(ReadView const& base, uint256 const& key) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -27,16 +27,16 @@ public:
|
||||
|
||||
virtual ~ReadViewFwdIter() = default;
|
||||
|
||||
[[nodiscard]] virtual std::unique_ptr<ReadViewFwdIter>
|
||||
virtual std::unique_ptr<ReadViewFwdIter>
|
||||
copy() const = 0;
|
||||
|
||||
[[nodiscard]] virtual bool
|
||||
virtual bool
|
||||
equal(ReadViewFwdIter const& impl) const = 0;
|
||||
|
||||
virtual void
|
||||
increment() = 0;
|
||||
|
||||
[[nodiscard]] virtual value_type
|
||||
virtual value_type
|
||||
dereference() const = 0;
|
||||
};
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
|
||||
private:
|
||||
ReadView const* view_ = nullptr;
|
||||
std::unique_ptr<iter_base> impl_{};
|
||||
std::unique_ptr<iter_base> impl_;
|
||||
std::optional<value_type> mutable cache_;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/ledger/helpers/SLEBase.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Rate.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
@@ -15,46 +17,160 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
/** Check if the issuer has the global freeze flag set.
|
||||
@param issuer The account to check
|
||||
@return true if the account has global freeze set
|
||||
*/
|
||||
[[nodiscard]] bool
|
||||
isGlobalFrozen(ReadView const& view, AccountID const& issuer);
|
||||
|
||||
// Calculate liquid XRP balance for an account.
|
||||
// This function may be used to calculate the amount of XRP that
|
||||
// the holder is able to freely spend. It subtracts reserve requirements.
|
||||
//
|
||||
// ownerCountAdj adjusts the owner count in case the caller calculates
|
||||
// before ledger entries are added or removed. Positive to add, negative
|
||||
// to subtract.
|
||||
//
|
||||
// @param ownerCountAdj positive to add to count, negative to reduce count.
|
||||
[[nodiscard]] XRPAmount
|
||||
xrpLiquid(ReadView const& view, AccountID const& id, std::int32_t ownerCountAdj, beast::Journal j);
|
||||
|
||||
/** Adjust the owner count up or down. */
|
||||
void
|
||||
adjustOwnerCount(
|
||||
ApplyView& view,
|
||||
std::shared_ptr<SLE> const& sle,
|
||||
std::int32_t amount,
|
||||
beast::Journal j);
|
||||
|
||||
/** Returns IOU issuer transfer fee as Rate. Rate specifies
|
||||
* the fee as fractions of 1 billion. For example, 1% transfer rate
|
||||
* is represented as 1,010,000,000.
|
||||
* @param issuer The IOU issuer
|
||||
/**
|
||||
* View-parameterized wrapper for AccountRoot ledger entries.
|
||||
*
|
||||
* AccountRoot<ReadView> — read-only access to account data
|
||||
* AccountRoot<ApplyView> — read-write access, with insert/update/erase
|
||||
* and domain-specific write methods
|
||||
*/
|
||||
[[nodiscard]] Rate
|
||||
transferRate(ReadView const& view, AccountID const& issuer);
|
||||
template <typename ViewT>
|
||||
class AccountRoot : public SLEBase<ViewT>
|
||||
{
|
||||
static constexpr bool isWritable = SLEBase<ViewT>::isWritable;
|
||||
|
||||
AccountID const id_;
|
||||
|
||||
public:
|
||||
/** Constructor for read-only context */
|
||||
AccountRoot(
|
||||
AccountID const& id,
|
||||
ReadView const& view,
|
||||
beast::Journal j = beast::Journal{beast::Journal::getNullSink()})
|
||||
requires(!isWritable)
|
||||
: SLEBase<ViewT>(view.read(keylet::account(id)), view, j), id_(id)
|
||||
{
|
||||
}
|
||||
|
||||
/** Constructor for writable context */
|
||||
AccountRoot(
|
||||
AccountID const& id,
|
||||
ApplyView& view,
|
||||
beast::Journal j = beast::Journal{beast::Journal::getNullSink()})
|
||||
requires isWritable
|
||||
: SLEBase<ViewT>(keylet::account(id), view, j), id_(id)
|
||||
{
|
||||
}
|
||||
|
||||
/** Converting constructor: writable → read-only. */
|
||||
template <WritableView OtherViewT>
|
||||
AccountRoot(AccountRoot<OtherViewT> const& other)
|
||||
requires(!isWritable)
|
||||
: SLEBase<ViewT>(other), id_(other.id())
|
||||
{
|
||||
}
|
||||
|
||||
/** Create an AccountRoot backed by a brand-new SLE.
|
||||
*/
|
||||
[[nodiscard]] static AccountRoot
|
||||
makeNew(
|
||||
AccountID const& id,
|
||||
ApplyView& view,
|
||||
beast::Journal j = beast::Journal{beast::Journal::getNullSink()})
|
||||
requires isWritable
|
||||
{
|
||||
return AccountRoot(id, view, j, std::make_shared<SLE>(keylet::account(id)));
|
||||
}
|
||||
|
||||
AccountID const&
|
||||
id() const
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
// --- Read-only domain methods (available on both specializations) ---
|
||||
|
||||
/** Check if the issuer has the global freeze flag set.
|
||||
@return true if the account has global freeze set
|
||||
*/
|
||||
[[nodiscard]] bool
|
||||
isGlobalFrozen() const;
|
||||
|
||||
/** Returns IOU issuer transfer fee as Rate. Rate specifies
|
||||
* the fee as fractions of 1 billion. For example, 1% transfer rate
|
||||
* is represented as 1,010,000,000.
|
||||
*/
|
||||
[[nodiscard]] Rate
|
||||
transferRate() const;
|
||||
|
||||
// Calculate liquid XRP balance for an account.
|
||||
// This function may be used to calculate the amount of XRP that
|
||||
// the holder is able to freely spend. It subtracts reserve requirements.
|
||||
//
|
||||
// ownerCountAdj adjusts the owner count in case the caller calculates
|
||||
// before ledger entries are added or removed. Positive to add, negative
|
||||
// to subtract.
|
||||
//
|
||||
// @param ownerCountAdj positive to add to count, negative to reduce count.
|
||||
[[nodiscard]] XRPAmount
|
||||
xrpLiquid(std::int32_t ownerCountAdj) const;
|
||||
|
||||
/** Checks the destination and tag.
|
||||
|
||||
- Checks that the SLE is not null.
|
||||
- If the SLE requires a destination tag, checks that there is a tag.
|
||||
*/
|
||||
[[nodiscard]] TER
|
||||
checkDestinationAndTag(bool hasDestinationTag) const;
|
||||
|
||||
/** Returns true if and only if sleAcct is a pseudo-account or specific
|
||||
pseudo-accounts in pseudoFieldFilter.
|
||||
|
||||
Returns false if sleAcct is:
|
||||
- NOT a pseudo-account OR
|
||||
- NOT a ltACCOUNT_ROOT OR
|
||||
- null pointer
|
||||
*/
|
||||
[[nodiscard]] bool
|
||||
isPseudoAccount(std::set<SField const*> const& pseudoFieldFilter = {}) const;
|
||||
|
||||
[[nodiscard]] bool
|
||||
operator==(AccountRoot const& other) const
|
||||
{
|
||||
return id_ == other.id_;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
operator==(AccountID const& other) const
|
||||
{
|
||||
return id_ == other;
|
||||
}
|
||||
|
||||
// --- Write-only domain methods (compile-time gated) ---
|
||||
|
||||
/** Adjust the owner count up or down. */
|
||||
void
|
||||
adjustOwnerCount(std::int32_t amount)
|
||||
requires isWritable;
|
||||
|
||||
private:
|
||||
// Private constructor only used by `makeNew`
|
||||
AccountRoot(AccountID const& id, ApplyView& view, beast::Journal j, std::shared_ptr<SLE> sle)
|
||||
requires isWritable
|
||||
: SLEBase<ViewT>(std::move(sle), view, j), id_(id)
|
||||
{
|
||||
this->insert();
|
||||
}
|
||||
};
|
||||
|
||||
// CTAD deduction guide — bare AccountRoot(id, view) always deduces read-only.
|
||||
// For writable access, use WAccountRoot(id, applyView) explicitly.
|
||||
AccountRoot(AccountID const&, ReadView const&) -> AccountRoot<ReadView>;
|
||||
AccountRoot(AccountID const&, ReadView const&, beast::Journal) -> AccountRoot<ReadView>;
|
||||
|
||||
// Backward-compatible aliases
|
||||
using RAccountRoot = AccountRoot<ReadView>;
|
||||
using WAccountRoot = AccountRoot<ApplyView>;
|
||||
|
||||
// Explicit instantiation declarations (definitions in .cpp)
|
||||
extern template class AccountRoot<ReadView>;
|
||||
extern template class AccountRoot<ApplyView>;
|
||||
|
||||
/** Generate a pseudo-account address from a pseudo owner key.
|
||||
@param pseudoOwnerKey The key to generate the address from
|
||||
@return The generated account ID
|
||||
*/
|
||||
AccountID
|
||||
[[nodiscard]] AccountID
|
||||
pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey);
|
||||
|
||||
/** Returns the list of fields that define an ACCOUNT_ROOT as a pseudo-account
|
||||
@@ -67,29 +183,6 @@ pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey);
|
||||
[[nodiscard]] std::vector<SField const*> const&
|
||||
getPseudoAccountFields();
|
||||
|
||||
/** Returns true if and only if sleAcct is a pseudo-account or specific
|
||||
pseudo-accounts in pseudoFieldFilter.
|
||||
|
||||
Returns false if sleAcct is:
|
||||
- NOT a pseudo-account OR
|
||||
- NOT a ltACCOUNT_ROOT OR
|
||||
- null pointer
|
||||
*/
|
||||
[[nodiscard]] bool
|
||||
isPseudoAccount(
|
||||
std::shared_ptr<SLE const> sleAcct,
|
||||
std::set<SField const*> const& pseudoFieldFilter = {});
|
||||
|
||||
/** Convenience overload that reads the account from the view. */
|
||||
[[nodiscard]] inline bool
|
||||
isPseudoAccount(
|
||||
ReadView const& view,
|
||||
AccountID const& accountId,
|
||||
std::set<SField const*> const& pseudoFieldFilter = {})
|
||||
{
|
||||
return isPseudoAccount(view.read(keylet::account(accountId)), pseudoFieldFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create pseudo-account, storing pseudoOwnerKey into ownerField.
|
||||
*
|
||||
@@ -101,12 +194,4 @@ isPseudoAccount(
|
||||
[[nodiscard]] Expected<std::shared_ptr<SLE>, TER>
|
||||
createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const& ownerField);
|
||||
|
||||
/** Checks the destination and tag.
|
||||
|
||||
- Checks that the SLE is not null.
|
||||
- If the SLE requires a destination tag, checks that there is a tag.
|
||||
*/
|
||||
[[nodiscard]] TER
|
||||
checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/STArray.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
@@ -73,8 +74,7 @@ verifyDepositPreauth(
|
||||
STTx const& tx,
|
||||
ApplyView& view,
|
||||
AccountID const& src,
|
||||
AccountID const& dst,
|
||||
std::shared_ptr<SLE const> const& sleDst,
|
||||
RAccountRoot const& dst,
|
||||
beast::Journal j);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <xrpl/protocol/MPTAmount.h>
|
||||
#include <xrpl/protocol/Rate.h>
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
template <ValidIssueType T>
|
||||
@@ -18,7 +20,7 @@ TER
|
||||
escrowUnlockApplyHelper(
|
||||
ApplyView& view,
|
||||
Rate lockedRate,
|
||||
std::shared_ptr<SLE> const& sleDest,
|
||||
std::variant<std::shared_ptr<SLE>, WAccountRoot> dest,
|
||||
STAmount const& xrpBalance,
|
||||
STAmount const& amount,
|
||||
AccountID const& issuer,
|
||||
@@ -32,7 +34,7 @@ inline TER
|
||||
escrowUnlockApplyHelper<Issue>(
|
||||
ApplyView& view,
|
||||
Rate lockedRate,
|
||||
std::shared_ptr<SLE> const& sleDest,
|
||||
std::variant<std::shared_ptr<SLE>, WAccountRoot> dest,
|
||||
STAmount const& xrpBalance,
|
||||
STAmount const& amount,
|
||||
AccountID const& issuer,
|
||||
@@ -55,8 +57,14 @@ escrowUnlockApplyHelper<Issue>(
|
||||
|
||||
if (!view.exists(trustLineKey) && createAsset)
|
||||
{
|
||||
// For backwards compatibility: if dest is not WAccountRoot, return error
|
||||
if (!std::holds_alternative<WAccountRoot>(dest))
|
||||
return tefEXCEPTION;
|
||||
|
||||
auto& wrappedDest = std::get<WAccountRoot>(dest);
|
||||
|
||||
// Can the account cover the trust line's reserve?
|
||||
if (std::uint32_t const ownerCount = {sleDest->at(sfOwnerCount)};
|
||||
if (std::uint32_t const ownerCount = {wrappedDest->at(sfOwnerCount)};
|
||||
xrpBalance < view.fees().accountReserve(ownerCount + 1))
|
||||
{
|
||||
JLOG(journal.trace()) << "Trust line does not exist. "
|
||||
@@ -70,27 +78,27 @@ escrowUnlockApplyHelper<Issue>(
|
||||
initialBalance.get<Issue>().account = noAccount();
|
||||
|
||||
if (TER const ter = trustCreate(
|
||||
view, // payment sandbox
|
||||
recvLow, // is dest low?
|
||||
issuer, // source
|
||||
receiver, // destination
|
||||
trustLineKey.key, // ledger index
|
||||
sleDest, // Account to add to
|
||||
false, // authorize account
|
||||
(sleDest->getFlags() & lsfDefaultRipple) == 0, //
|
||||
false, // freeze trust line
|
||||
false, // deep freeze trust line
|
||||
initialBalance, // zero initial balance
|
||||
Issue(currency, receiver), // limit of zero
|
||||
0, // quality in
|
||||
0, // quality out
|
||||
journal); // journal
|
||||
view, // payment sandbox
|
||||
recvLow, // is dest low?
|
||||
issuer, // source
|
||||
receiver, // destination
|
||||
trustLineKey.key, // ledger index
|
||||
wrappedDest, // Account to add to
|
||||
false, // authorize account
|
||||
!wrappedDest->isFlag(lsfDefaultRipple),
|
||||
false, // freeze trust line
|
||||
false, // deep freeze trust line
|
||||
initialBalance, // zero initial balance
|
||||
Issue(currency, receiver), // limit of zero
|
||||
0, // quality in
|
||||
0, // quality out
|
||||
journal); // journal
|
||||
!isTesSuccess(ter))
|
||||
{
|
||||
return ter; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
view.update(sleDest);
|
||||
wrappedDest.update();
|
||||
}
|
||||
|
||||
if (!view.exists(trustLineKey) && !receiverIssuer)
|
||||
@@ -162,7 +170,7 @@ inline TER
|
||||
escrowUnlockApplyHelper<MPTIssue>(
|
||||
ApplyView& view,
|
||||
Rate lockedRate,
|
||||
std::shared_ptr<SLE> const& sleDest,
|
||||
std::variant<std::shared_ptr<SLE>, WAccountRoot> dest,
|
||||
STAmount const& xrpBalance,
|
||||
STAmount const& amount,
|
||||
AccountID const& issuer,
|
||||
@@ -178,7 +186,13 @@ escrowUnlockApplyHelper<MPTIssue>(
|
||||
auto const issuanceKey = keylet::mptIssuance(mptID);
|
||||
if (!view.exists(keylet::mptoken(issuanceKey.key, receiver)) && createAsset && !receiverIssuer)
|
||||
{
|
||||
if (std::uint32_t const ownerCount = {sleDest->at(sfOwnerCount)};
|
||||
// For backwards compatibility: if dest is not WAccountRoot, return error
|
||||
if (!std::holds_alternative<WAccountRoot>(dest))
|
||||
return tefEXCEPTION;
|
||||
|
||||
auto& wrappedDest = std::get<WAccountRoot>(dest);
|
||||
|
||||
if (std::uint32_t const ownerCount = {wrappedDest->at(sfOwnerCount)};
|
||||
xrpBalance < view.fees().accountReserve(ownerCount + 1))
|
||||
{
|
||||
return tecINSUFFICIENT_RESERVE;
|
||||
@@ -190,7 +204,7 @@ escrowUnlockApplyHelper<MPTIssue>(
|
||||
}
|
||||
|
||||
// update owner count.
|
||||
adjustOwnerCount(view, sleDest, 1, journal);
|
||||
wrappedDest.adjustOwnerCount(1);
|
||||
}
|
||||
|
||||
if (!view.exists(keylet::mptoken(issuanceKey.key, receiver)) && !receiverIssuer)
|
||||
|
||||
53
include/xrpl/ledger/helpers/README.md
Normal file
53
include/xrpl/ledger/helpers/README.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Ledger Entry Helpers (`helpers/`)
|
||||
|
||||
## Overview
|
||||
|
||||
This folder contains helper classes and free functions for working with **Serialized Ledger Entries (SLEs)**. Its centerpiece is `SLEBase.h`, which defines the template class `SLEBase<ViewT>` — a type-safe, context-aware wrapper around the raw `std::shared_ptr<SLE>` used throughout the rest of the codebase.
|
||||
|
||||
## The Problem: Untyped SLE Access
|
||||
|
||||
Historically, ledger entries are passed around as bare `std::shared_ptr<SLE>` (or `std::shared_ptr<SLE const>`). This has several drawbacks:
|
||||
|
||||
1. **No compile-time entry-type safety.** Any code holding an `std::shared_ptr<SLE>` can read or write _any_ field on _any_ ledger entry type. Nothing prevents you from calling `sle->getFieldU32(sfOwnerCount)` on an Offer SLE, even though Offers don't have that field.
|
||||
|
||||
2. **No read/write distinction.** A function that only needs to _read_ an entry still receives a mutable `std::shared_ptr<SLE>`, making it easy to accidentally mutate state. Conversely, a function that _must_ write has no way to express that requirement in its signature.
|
||||
|
||||
3. **No association with the view.** The SLE and the `ReadView` / `ApplyView` it came from travel as separate arguments, so callers must manually keep them in sync and remember to call `view.update(sle)` after mutations.
|
||||
|
||||
## The Solution: `SLEBase.h`
|
||||
|
||||
`SLEBase.h` introduces a single template class `SLEBase<ViewT>` that pairs an SLE with its view context and enforces read/write semantics at compile time via `requires` clauses.
|
||||
|
||||
**`SLEBase<ReadView>`** holds a `std::shared_ptr<SLE const>` and a `ReadView const&`. Write-only members are excluded at compile time.
|
||||
holds a mutable `std::shared_ptr<SLE>`, an `ApplyView&`, and a `Keylet`. It exposes `insert()`, `update()`, `erase()`, and `newSLE()` to keep the SLE and its view in sync automatically.
|
||||
|
||||
A converting constructor allows implicit conversion from `SLEBase<ApplyView>` to `SLEBase<ReadView>`, so functions taking a read-only wrapper can accept a writable one without a cast.
|
||||
|
||||
### Template Pattern
|
||||
|
||||
Each entry type is a single template class parameterized on the view type:
|
||||
|
||||
```
|
||||
AccountRoot<ReadView> — read-only: RAccountRoot
|
||||
AccountRoot<ApplyView> — writable: WAccountRoot
|
||||
```
|
||||
|
||||
Both specializations share all domain read methods. Write methods on `WAccountRoot` are gated with `requires is_writable` so they are unavailable on `RAccountRoot` at compile time. The `R`/`W` prefix aliases (`RAccountRoot`, `WAccountRoot`) are provided for convenience and backward compatibility.
|
||||
|
||||
## Files in This Directory
|
||||
|
||||
| File | Description |
|
||||
| ---------------------- | ---------------------------------------------------------------------------------------------------- |
|
||||
| `SLEBase.h` | Template base class `SLEBase<ViewT>` and `ReadOnlySLE`/`WritableSLE` aliases |
|
||||
| `AccountRootHelpers.h` | `AccountRoot<ViewT>` wrapper (`RAccountRoot`, `WAccountRoot`) and free functions for pseudo-accounts |
|
||||
| `CredentialHelpers.h` | Free functions for Credential ledger entries |
|
||||
| `DirectoryHelpers.h` | Free functions for directory traversal (`dirFirst`, `dirNext`, `forEachItem`, etc.) |
|
||||
| `MPTokenHelpers.h` | Free functions for MPToken and MPTokenIssuance ledger entries |
|
||||
| `OfferHelpers.h` | Free function `offerDelete` for removing Offer entries |
|
||||
| `RippleStateHelpers.h` | Free functions for RippleState (trust line) entries: credit, freeze, issuance, authorization |
|
||||
| `TokenHelpers.h` | Shared token helpers (freeze/auth checks used by both IOU and MPT paths) |
|
||||
| `VaultHelpers.h` | Free functions for Vault ledger entries |
|
||||
|
||||
## Migration Status
|
||||
|
||||
This migration is still in progress. New code should prefer the wrapper style where possible; existing free functions will be migrated incrementally.
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
|
||||
#include <xrpl/ledger/helpers/TokenHelpers.h>
|
||||
#include <xrpl/protocol/IOUAmount.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
@@ -137,15 +138,15 @@ trustCreate(
|
||||
bool const bSrcHigh,
|
||||
AccountID const& uSrcAccountID,
|
||||
AccountID const& uDstAccountID,
|
||||
uint256 const& uIndex, // --> ripple state entry
|
||||
SLE::ref sleAccount, // --> the account being set.
|
||||
bool const bAuth, // --> authorize account.
|
||||
bool const bNoRipple, // --> others cannot ripple through
|
||||
bool const bFreeze, // --> funds cannot leave
|
||||
bool bDeepFreeze, // --> can neither receive nor send funds
|
||||
STAmount const& saBalance, // --> balance of account being set.
|
||||
uint256 const& uIndex, // ripple state entry
|
||||
WAccountRoot& wrappedAcct, // the account being set.
|
||||
bool const bAuth, // authorize account.
|
||||
bool const bNoRipple, // others cannot ripple through
|
||||
bool const bFreeze, // funds cannot leave
|
||||
bool bDeepFreeze, // can neither receive nor send funds
|
||||
STAmount const& saBalance, // balance of account being set.
|
||||
// Issuer should be noAccount()
|
||||
STAmount const& saLimit, // --> limit for account being set.
|
||||
STAmount const& saLimit, // limit for account being set.
|
||||
// Issuer should be the account being set.
|
||||
std::uint32_t uQualityIn,
|
||||
std::uint32_t uQualityOut,
|
||||
|
||||
240
include/xrpl/ledger/helpers/SLEBase.h
Normal file
240
include/xrpl/ledger/helpers/SLEBase.h
Normal file
@@ -0,0 +1,240 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
|
||||
#include <concepts>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
// Concept to distinguish read-only vs writable view types
|
||||
template <typename V>
|
||||
concept WritableView = std::derived_from<V, ApplyView>;
|
||||
|
||||
/**
|
||||
* View-parameterized base class for all ledger entry wrappers.
|
||||
*
|
||||
* SLEBase<ReadView> — read-only: holds shared_ptr<SLE const> + ReadView const&
|
||||
* SLEBase<ApplyView> — writable: holds shared_ptr<SLE> + ApplyView& + Keylet,
|
||||
* plus insert/update/erase operations
|
||||
*
|
||||
* Write-only members are gated by `requires` clauses, providing compile-time
|
||||
* guarantees that read-only wrappers cannot mutate state.
|
||||
*
|
||||
* Derived classes should provide domain-specific accessors that hide
|
||||
* implementation details of the underlying ledger entry format.
|
||||
*/
|
||||
template <typename ViewT>
|
||||
class SLEBase
|
||||
{
|
||||
public:
|
||||
static constexpr bool isWritable = WritableView<ViewT>;
|
||||
|
||||
// SLE pointer type: mutable for writable views, const for read-only
|
||||
using sle_ptr_type = std::conditional_t<isWritable, std::shared_ptr<SLE>, SLE::const_pointer>;
|
||||
|
||||
// View reference type: ApplyView& for writable, ReadView const& for read-only
|
||||
using view_ref_type = std::conditional_t<isWritable, ApplyView&, ReadView const&>;
|
||||
|
||||
virtual ~SLEBase() = default;
|
||||
|
||||
SLEBase(SLEBase const&) = default;
|
||||
SLEBase(SLEBase&&) = default;
|
||||
SLEBase&
|
||||
operator=(SLEBase const&) = delete;
|
||||
SLEBase&
|
||||
operator=(SLEBase&&) = delete;
|
||||
|
||||
// --- Common interface (always available) ---
|
||||
|
||||
/** Returns true if the ledger entry exists */
|
||||
bool
|
||||
exists() const
|
||||
{
|
||||
return sle_ != nullptr;
|
||||
}
|
||||
|
||||
/** Explicit conversion to bool for convenient existence checking */
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return exists();
|
||||
}
|
||||
|
||||
/** Returns the underlying SLE for read access */
|
||||
SLE::const_pointer
|
||||
sle() const
|
||||
{
|
||||
return sle_;
|
||||
}
|
||||
|
||||
/** Returns the read view (always available; ApplyView inherits ReadView) */
|
||||
ReadView const&
|
||||
readView() const
|
||||
{
|
||||
return view_;
|
||||
}
|
||||
|
||||
/** Const dereference operators (always available) */
|
||||
STLedgerEntry const*
|
||||
operator->() const
|
||||
{
|
||||
XRPL_ASSERT(exists(), "xrpl::SLEBase::operator-> : exists");
|
||||
return sle_.get();
|
||||
}
|
||||
|
||||
STLedgerEntry const&
|
||||
operator*() const
|
||||
{
|
||||
XRPL_ASSERT(exists(), "xrpl::SLEBase::operator* : exists");
|
||||
return *sle_;
|
||||
}
|
||||
|
||||
// --- Writable interface (compile-time gated) ---
|
||||
|
||||
/** Returns a mutable SLE for write operations */
|
||||
sle_ptr_type const&
|
||||
mutableSle() const
|
||||
requires isWritable
|
||||
{
|
||||
return sle_;
|
||||
}
|
||||
|
||||
/** Returns true if this wrapper supports write operations */
|
||||
bool
|
||||
canModify() const
|
||||
requires isWritable
|
||||
{
|
||||
return sle_ != nullptr;
|
||||
}
|
||||
|
||||
/** Returns the apply view for write operations */
|
||||
ApplyView&
|
||||
applyView() const
|
||||
requires isWritable
|
||||
{
|
||||
return view_;
|
||||
}
|
||||
|
||||
/** Mutable dereference operators */
|
||||
STLedgerEntry*
|
||||
operator->()
|
||||
requires isWritable
|
||||
{
|
||||
XRPL_ASSERT(canModify(), "xrpl::SLEBase::operator-> : can modify");
|
||||
return sle_.get();
|
||||
}
|
||||
|
||||
STLedgerEntry&
|
||||
operator*()
|
||||
requires isWritable
|
||||
{
|
||||
XRPL_ASSERT(canModify(), "xrpl::SLEBase::operator* : can modify");
|
||||
return *sle_;
|
||||
}
|
||||
|
||||
void
|
||||
insert()
|
||||
requires isWritable
|
||||
{
|
||||
XRPL_ASSERT(canModify(), "xrpl::SLEBase::insert : can modify");
|
||||
view_.insert(sle_);
|
||||
}
|
||||
|
||||
void
|
||||
erase()
|
||||
requires isWritable
|
||||
{
|
||||
XRPL_ASSERT(canModify(), "xrpl::SLEBase::erase : can modify");
|
||||
view_.erase(sle_);
|
||||
}
|
||||
|
||||
void
|
||||
update()
|
||||
requires isWritable
|
||||
{
|
||||
XRPL_ASSERT(canModify(), "xrpl::SLEBase::update : can modify");
|
||||
view_.update(sle_);
|
||||
}
|
||||
|
||||
void
|
||||
newSLE()
|
||||
requires isWritable
|
||||
{
|
||||
XRPL_ASSERT(!canModify(), "xrpl::SLEBase::newSLE : no existing SLE");
|
||||
sle_ = std::make_shared<SLE>(key_);
|
||||
}
|
||||
|
||||
beast::Journal
|
||||
journal() const
|
||||
{
|
||||
return j_;
|
||||
}
|
||||
|
||||
protected:
|
||||
SLEBase() = delete;
|
||||
|
||||
/** Constructor for read-only context */
|
||||
explicit SLEBase(
|
||||
SLE::const_pointer sle,
|
||||
ReadView const& view,
|
||||
beast::Journal j = beast::Journal{beast::Journal::getNullSink()})
|
||||
requires(!isWritable)
|
||||
: view_(view), sle_(std::move(sle)), j_(j)
|
||||
{
|
||||
}
|
||||
|
||||
/** Converting constructor: writable → read-only.
|
||||
* Enables implicit conversion from SLEBase<ApplyView> to
|
||||
* SLEBase<ReadView>, so functions taking ReadOnlySLE const& can
|
||||
* accept WritableSLE.
|
||||
*/
|
||||
template <WritableView OtherViewT>
|
||||
SLEBase(SLEBase<OtherViewT> const& other)
|
||||
requires(!isWritable)
|
||||
: view_(other.readView()), sle_(other.sle()), j_(other.journal())
|
||||
{
|
||||
}
|
||||
|
||||
/** Constructor for writable context (from existing SLE) */
|
||||
explicit SLEBase(
|
||||
std::shared_ptr<SLE> sle,
|
||||
ApplyView& view,
|
||||
beast::Journal j = beast::Journal{beast::Journal::getNullSink()})
|
||||
requires isWritable
|
||||
: view_(view)
|
||||
, key_(sle ? Keylet(sle->getType(), sle->key()) : Keylet(ltANY, uint256{}))
|
||||
, sle_(std::move(sle))
|
||||
, j_(j)
|
||||
{
|
||||
}
|
||||
|
||||
/** Constructor for writable context (peek from view by keylet) */
|
||||
explicit SLEBase(
|
||||
Keylet const& key,
|
||||
ApplyView& view,
|
||||
beast::Journal j = beast::Journal{beast::Journal::getNullSink()})
|
||||
requires isWritable
|
||||
: view_(view), key_(key), sle_(view_.peek(key)), j_(j)
|
||||
{
|
||||
}
|
||||
|
||||
view_ref_type view_;
|
||||
|
||||
// Keylet is only meaningful for writable views, but we conditionally
|
||||
// include it to avoid wasting space in read-only wrappers.
|
||||
struct Empty
|
||||
{
|
||||
};
|
||||
[[no_unique_address]]
|
||||
std::conditional_t<isWritable, Keylet, Empty> key_{};
|
||||
|
||||
sle_ptr_type sle_;
|
||||
beast::Journal j_;
|
||||
};
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -245,7 +245,7 @@ canTransfer(ReadView const& view, Asset const& asset, AccountID const& from, Acc
|
||||
// Direct send w/o fees:
|
||||
// - Redeeming IOUs and/or sending sender's own IOUs.
|
||||
// - Create trust line of needed.
|
||||
// --> bCheckIssuer : normally require issuer to be involved.
|
||||
// bCheckIssuer : normally require issuer to be involved.
|
||||
// [[nodiscard]] // nodiscard commented out so DirectStep.cpp compiles.
|
||||
|
||||
/** Calls static directSendNoFeeIOU if saAmount represents Issue.
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
isSecure() const
|
||||
{
|
||||
return mSecure;
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
return ssl_context_;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
sslVerify() const
|
||||
{
|
||||
return verify_;
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
/** Get the block size for backends that support it
|
||||
*/
|
||||
[[nodiscard]] virtual std::optional<std::size_t>
|
||||
virtual std::optional<std::size_t>
|
||||
getBlockSize() const
|
||||
{
|
||||
return std::nullopt;
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
}
|
||||
|
||||
/** Returns the number of file descriptors the backend expects to need. */
|
||||
[[nodiscard]] virtual int
|
||||
virtual int
|
||||
fdRequired() const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
virtual ~Factory() = default;
|
||||
|
||||
/** Retrieve the name of this factory. */
|
||||
[[nodiscard]] virtual std::string
|
||||
virtual std::string
|
||||
getName() const = 0;
|
||||
|
||||
/** Create an instance of this factory's backend.
|
||||
|
||||
@@ -59,15 +59,15 @@ public:
|
||||
createObject(NodeObjectType type, Blob&& data, uint256 const& hash);
|
||||
|
||||
/** Returns the type of this object. */
|
||||
[[nodiscard]] NodeObjectType
|
||||
NodeObjectType
|
||||
getType() const;
|
||||
|
||||
/** Returns the hash of the data. */
|
||||
[[nodiscard]] uint256 const&
|
||||
uint256 const&
|
||||
getHash() const;
|
||||
|
||||
/** Returns the underlying data. */
|
||||
[[nodiscard]] Blob const&
|
||||
Blob const&
|
||||
getData() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
DecodedBlob(void const* key, void const* value, int valueBytes);
|
||||
|
||||
/** Determine if the decoding was successful. */
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
wasOk() const noexcept
|
||||
{
|
||||
return m_success;
|
||||
|
||||
@@ -234,11 +234,9 @@ message TMGetObjectByHash {
|
||||
otTRANSACTIONS = 7;
|
||||
}
|
||||
|
||||
// Previously used - don't reuse.
|
||||
reserved 3;
|
||||
|
||||
required ObjectType type = 1;
|
||||
required bool query = 2; // is this a query or a reply?
|
||||
optional uint32 seq = 3; // used to match replies to queries
|
||||
optional bytes ledgerHash = 4; // the hash of the ledger these queries are for
|
||||
optional bool fat = 5; // return related nodes
|
||||
repeated TMIndexedObject objects = 6; // the specific objects requested
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] AccountID const&
|
||||
AccountID const&
|
||||
getIssuer() const;
|
||||
|
||||
template <ValidIssueType TIss>
|
||||
@@ -80,16 +80,16 @@ public:
|
||||
get();
|
||||
|
||||
template <ValidIssueType TIss>
|
||||
[[nodiscard]] constexpr bool
|
||||
constexpr bool
|
||||
holds() const;
|
||||
|
||||
[[nodiscard]] std::string
|
||||
std::string
|
||||
getText() const;
|
||||
|
||||
[[nodiscard]] constexpr value_type const&
|
||||
constexpr value_type const&
|
||||
value() const;
|
||||
|
||||
[[nodiscard]] constexpr token_type
|
||||
constexpr token_type
|
||||
token() const;
|
||||
|
||||
void
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
STAmount
|
||||
operator()(Number const&) const;
|
||||
|
||||
[[nodiscard]] constexpr AmtType
|
||||
constexpr AmtType
|
||||
getAmountType() const;
|
||||
|
||||
// Custom, generic visit implementation
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
return detail::visit(issue_, std::forward<Visitors>(visitors)...);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool
|
||||
constexpr bool
|
||||
native() const
|
||||
{
|
||||
return visit(
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
[&](MPTIssue const&) { return false; });
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
bool
|
||||
integral() const
|
||||
{
|
||||
return visit(
|
||||
@@ -169,7 +169,7 @@ Asset::holds() const
|
||||
}
|
||||
|
||||
template <ValidIssueType TIss>
|
||||
[[nodiscard]] constexpr TIss const&
|
||||
constexpr TIss const&
|
||||
Asset::get() const
|
||||
{
|
||||
if (!std::holds_alternative<TIss>(issue_))
|
||||
|
||||
@@ -39,7 +39,7 @@ struct Fees
|
||||
The reserve is calculated as the reserve base plus
|
||||
the reserve increment times the number of increments.
|
||||
*/
|
||||
[[nodiscard]] XRPAmount
|
||||
XRPAmount
|
||||
accountReserve(std::size_t ownerCount) const
|
||||
{
|
||||
return reserve + ownerCount * increment;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user