mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Compare commits
8 Commits
ximinez/fi
...
bthomee/cc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a07399d2f1 | ||
|
|
73ef462422 | ||
|
|
ac71a5fcc8 | ||
|
|
efd2a33ecb | ||
|
|
5ca0577739 | ||
|
|
89ea91af5d | ||
|
|
30d2f70744 | ||
|
|
aec131bcbb |
56
.github/scripts/strategy-matrix/linux.json
vendored
56
.github/scripts/strategy-matrix/linux.json
vendored
@@ -15,196 +15,196 @@
|
|||||||
"distro_version": "bookworm",
|
"distro_version": "bookworm",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "12",
|
"compiler_version": "12",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "bookworm",
|
"distro_version": "bookworm",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "13",
|
"compiler_version": "13",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "bookworm",
|
"distro_version": "bookworm",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "14",
|
"compiler_version": "14",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "bookworm",
|
"distro_version": "bookworm",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "15",
|
"compiler_version": "15",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "bookworm",
|
"distro_version": "bookworm",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "16",
|
"compiler_version": "16",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "bookworm",
|
"distro_version": "bookworm",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "17",
|
"compiler_version": "17",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "bookworm",
|
"distro_version": "bookworm",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "18",
|
"compiler_version": "18",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "bookworm",
|
"distro_version": "bookworm",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "19",
|
"compiler_version": "19",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "bookworm",
|
"distro_version": "bookworm",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "20",
|
"compiler_version": "20",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "trixie",
|
"distro_version": "trixie",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "14",
|
"compiler_version": "14",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "trixie",
|
"distro_version": "trixie",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "15",
|
"compiler_version": "15",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "trixie",
|
"distro_version": "trixie",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "20",
|
"compiler_version": "20",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "debian",
|
"distro_name": "debian",
|
||||||
"distro_version": "trixie",
|
"distro_version": "trixie",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "21",
|
"compiler_version": "21",
|
||||||
"image_sha": "0525eae"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "rhel",
|
"distro_name": "rhel",
|
||||||
"distro_version": "8",
|
"distro_version": "8",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "14",
|
"compiler_version": "14",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "rhel",
|
"distro_name": "rhel",
|
||||||
"distro_version": "8",
|
"distro_version": "8",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "any",
|
"compiler_version": "any",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "rhel",
|
"distro_name": "rhel",
|
||||||
"distro_version": "9",
|
"distro_version": "9",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "12",
|
"compiler_version": "12",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "rhel",
|
"distro_name": "rhel",
|
||||||
"distro_version": "9",
|
"distro_version": "9",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "13",
|
"compiler_version": "13",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "rhel",
|
"distro_name": "rhel",
|
||||||
"distro_version": "9",
|
"distro_version": "9",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "14",
|
"compiler_version": "14",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "rhel",
|
"distro_name": "rhel",
|
||||||
"distro_version": "9",
|
"distro_version": "9",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "any",
|
"compiler_version": "any",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "rhel",
|
"distro_name": "rhel",
|
||||||
"distro_version": "10",
|
"distro_version": "10",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "14",
|
"compiler_version": "14",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "rhel",
|
"distro_name": "rhel",
|
||||||
"distro_version": "10",
|
"distro_version": "10",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "any",
|
"compiler_version": "any",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "ubuntu",
|
"distro_name": "ubuntu",
|
||||||
"distro_version": "jammy",
|
"distro_version": "jammy",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "12",
|
"compiler_version": "12",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "ubuntu",
|
"distro_name": "ubuntu",
|
||||||
"distro_version": "noble",
|
"distro_version": "noble",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "13",
|
"compiler_version": "13",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "ubuntu",
|
"distro_name": "ubuntu",
|
||||||
"distro_version": "noble",
|
"distro_version": "noble",
|
||||||
"compiler_name": "gcc",
|
"compiler_name": "gcc",
|
||||||
"compiler_version": "14",
|
"compiler_version": "14",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "ubuntu",
|
"distro_name": "ubuntu",
|
||||||
"distro_version": "noble",
|
"distro_version": "noble",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "16",
|
"compiler_version": "16",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "ubuntu",
|
"distro_name": "ubuntu",
|
||||||
"distro_version": "noble",
|
"distro_version": "noble",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "17",
|
"compiler_version": "17",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "ubuntu",
|
"distro_name": "ubuntu",
|
||||||
"distro_version": "noble",
|
"distro_version": "noble",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "18",
|
"compiler_version": "18",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"distro_name": "ubuntu",
|
"distro_name": "ubuntu",
|
||||||
"distro_version": "noble",
|
"distro_version": "noble",
|
||||||
"compiler_name": "clang",
|
"compiler_name": "clang",
|
||||||
"compiler_version": "19",
|
"compiler_version": "19",
|
||||||
"image_sha": "e1782cd"
|
"image_sha": "ca4517d"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"build_type": ["Debug", "Release"],
|
"build_type": ["Debug", "Release"],
|
||||||
|
|||||||
24
.github/workflows/reusable-build-test-config.yml
vendored
24
.github/workflows/reusable-build-test-config.yml
vendored
@@ -116,6 +116,16 @@ jobs:
|
|||||||
${CMAKE_ARGS} \
|
${CMAKE_ARGS} \
|
||||||
..
|
..
|
||||||
|
|
||||||
|
- name: Restore build objects (Linux)
|
||||||
|
if: ${{ runner.os == 'Linux' }}
|
||||||
|
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
|
with:
|
||||||
|
path: ${{ env.CCACHE_DIR }}
|
||||||
|
key: ${{ inputs.config_name }}
|
||||||
|
|
||||||
|
- name: Print out ccache statistics before building
|
||||||
|
run: ccache -s
|
||||||
|
|
||||||
- name: Build the binary
|
- name: Build the binary
|
||||||
working-directory: ${{ inputs.build_dir }}
|
working-directory: ${{ inputs.build_dir }}
|
||||||
env:
|
env:
|
||||||
@@ -129,14 +139,22 @@ jobs:
|
|||||||
--parallel "${BUILD_NPROC}" \
|
--parallel "${BUILD_NPROC}" \
|
||||||
--target "${CMAKE_TARGET}"
|
--target "${CMAKE_TARGET}"
|
||||||
|
|
||||||
|
- name: Print out ccache statistics after building
|
||||||
|
run: ccache -s
|
||||||
|
|
||||||
|
- name: Save build objects (Linux)
|
||||||
|
if: ${{ runner.os == 'Linux' }}
|
||||||
|
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
|
with:
|
||||||
|
path: ${{ env.CCACHE_DIR }}
|
||||||
|
key: ${{ inputs.config_name }}
|
||||||
|
|
||||||
- name: Upload rippled artifact (Linux)
|
- name: Upload rippled artifact (Linux)
|
||||||
if: ${{ github.repository_owner == 'XRPLF' && runner.os == 'Linux' }}
|
if: ${{ github.repository_owner == 'XRPLF' && runner.os == 'Linux' }}
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
env:
|
|
||||||
BUILD_DIR: ${{ inputs.build_dir }}
|
|
||||||
with:
|
with:
|
||||||
name: rippled-${{ inputs.config_name }}
|
name: rippled-${{ inputs.config_name }}
|
||||||
path: ${{ env.BUILD_DIR }}/rippled
|
path: ${{ inputs.build_dir }}/rippled
|
||||||
retention-days: 3
|
retention-days: 3
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -111,6 +111,3 @@ bld.rippled/
|
|||||||
|
|
||||||
# Suggested in-tree build directory
|
# Suggested in-tree build directory
|
||||||
/.build*/
|
/.build*/
|
||||||
|
|
||||||
# Locally patched Conan recipes
|
|
||||||
external/conan-center-index/
|
|
||||||
|
|||||||
47
BUILD.md
47
BUILD.md
@@ -141,37 +141,21 @@ Alternatively, you can pull the patched recipes into the repository and use them
|
|||||||
locally:
|
locally:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Extract the version number from the lockfile.
|
|
||||||
function extract_version {
|
|
||||||
version=$(cat conan.lock | sed -nE "s@.+${1}/(.+)#.+@\1@p" | head -n1)
|
|
||||||
echo ${version}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Define which recipes to export.
|
|
||||||
recipes=(ed25519 grpc secp256k1 snappy soci)
|
|
||||||
|
|
||||||
# Selectively check out the recipes from our CCI fork.
|
|
||||||
cd external
|
cd external
|
||||||
mkdir -p conan-center-index
|
|
||||||
cd conan-center-index
|
|
||||||
git init
|
git init
|
||||||
git remote add origin git@github.com:XRPLF/conan-center-index.git
|
git remote add origin git@github.com:XRPLF/conan-center-index.git
|
||||||
git sparse-checkout init
|
git sparse-checkout init
|
||||||
for recipe in ${recipes[@]}; do
|
git sparse-checkout set recipes/ed25519
|
||||||
echo "Checking out ${recipe}..."
|
git sparse-checkout add recipes/secp256k1
|
||||||
git sparse-checkout add recipes/${recipe}/all
|
git sparse-checkout add recipes/snappy
|
||||||
done
|
git sparse-checkout add recipes/soci
|
||||||
git fetch origin master
|
git fetch origin master
|
||||||
git checkout master
|
git checkout master
|
||||||
cd ../..
|
conan export --version 2015.03 recipes/ed25519/all
|
||||||
|
conan export --version 0.7.0 recipes/secp256k1/all
|
||||||
# Export the recipes into the local cache.
|
conan export --version 1.1.10 recipes/snappy/all
|
||||||
for recipe in ${recipes[@]}; do
|
conan export --version 4.0.3 recipes/soci/all
|
||||||
version=$(extract_version ${recipe})
|
rm -rf .git
|
||||||
echo "Exporting ${recipe}/${version}..."
|
|
||||||
conan export --version $(extract_version ${recipe}) \
|
|
||||||
external/conan-center-index/recipes/${recipe}/all
|
|
||||||
done
|
|
||||||
```
|
```
|
||||||
|
|
||||||
In the case we switch to a newer version of a dependency that still requires a
|
In the case we switch to a newer version of a dependency that still requires a
|
||||||
@@ -401,6 +385,19 @@ tools.build:cxxflags=['-DBOOST_ASIO_DISABLE_CONCEPTS']
|
|||||||
`--settings build_type=$BUILD_TYPE` or in the profile itself,
|
`--settings build_type=$BUILD_TYPE` or in the profile itself,
|
||||||
under the section `[settings]` with the key `build_type`.
|
under the section `[settings]` with the key `build_type`.
|
||||||
|
|
||||||
|
If you are using a Microsoft Visual C++ compiler,
|
||||||
|
then you will need to ensure consistency between the `build_type` setting
|
||||||
|
and the `compiler.runtime` setting.
|
||||||
|
|
||||||
|
When `build_type` is `Release`, `compiler.runtime` should be `MT`.
|
||||||
|
|
||||||
|
When `build_type` is `Debug`, `compiler.runtime` should be `MTd`.
|
||||||
|
|
||||||
|
```
|
||||||
|
conan install .. --output-folder . --build missing --settings build_type=Release --settings compiler.runtime=MT
|
||||||
|
conan install .. --output-folder . --build missing --settings build_type=Debug --settings compiler.runtime=MTd
|
||||||
|
```
|
||||||
|
|
||||||
3. Configure CMake and pass the toolchain file generated by Conan, located at
|
3. Configure CMake and pass the toolchain file generated by Conan, located at
|
||||||
`$OUTPUT_FOLDER/build/generators/conan_toolchain.cmake`.
|
`$OUTPUT_FOLDER/build/generators/conan_toolchain.cmake`.
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
setup project-wide compiler settings
|
setup project-wide compiler settings
|
||||||
#]===================================================================]
|
#]===================================================================]
|
||||||
|
|
||||||
|
find_program(CCACHE_PATH "ccache")
|
||||||
|
if (CCACHE_PATH)
|
||||||
|
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PATH}")
|
||||||
|
message(STATUS "Using ccache: ${CCACHE_PATH}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
#[=========================================================[
|
#[=========================================================[
|
||||||
TODO some/most of these common settings belong in a
|
TODO some/most of these common settings belong in a
|
||||||
toolchain file, especially the ABI-impacting ones
|
toolchain file, especially the ABI-impacting ones
|
||||||
|
|||||||
18
conan.lock
18
conan.lock
@@ -9,7 +9,7 @@
|
|||||||
"secp256k1/0.7.0#9210e4c655d0a665400378a663960d17%1764261276.764",
|
"secp256k1/0.7.0#9210e4c655d0a665400378a663960d17%1764261276.764",
|
||||||
"rocksdb/10.5.1#4a197eca381a3e5ae8adf8cffa5aacd0%1762797952.535",
|
"rocksdb/10.5.1#4a197eca381a3e5ae8adf8cffa5aacd0%1762797952.535",
|
||||||
"re2/20230301#ca3b241baec15bd31ea9187150e0b333%1764175362.029",
|
"re2/20230301#ca3b241baec15bd31ea9187150e0b333%1764175362.029",
|
||||||
"protobuf/6.32.1#f481fd276fc23a33b85a3ed1e898b693%1759134873.45",
|
"protobuf/3.21.12#44ee56c0a6eea0c19aeeaca680370b88%1764175361.456",
|
||||||
"openssl/3.5.4#a1d5835cc6ed5c5b8f3cd5b9b5d24205%1760106486.594",
|
"openssl/3.5.4#a1d5835cc6ed5c5b8f3cd5b9b5d24205%1760106486.594",
|
||||||
"nudb/2.0.9#fb8dfd1a5557f5e0528114c2da17721e%1763150366.909",
|
"nudb/2.0.9#fb8dfd1a5557f5e0528114c2da17721e%1763150366.909",
|
||||||
"lz4/1.10.0#59fc63cac7f10fbe8e05c7e62c2f3504%1756234228.999",
|
"lz4/1.10.0#59fc63cac7f10fbe8e05c7e62c2f3504%1756234228.999",
|
||||||
@@ -17,19 +17,19 @@
|
|||||||
"libbacktrace/cci.20210118#a7691bfccd8caaf66309df196790a5a1%1756230911.03",
|
"libbacktrace/cci.20210118#a7691bfccd8caaf66309df196790a5a1%1756230911.03",
|
||||||
"libarchive/3.8.1#ffee18995c706e02bf96e7a2f7042e0d%1764175360.142",
|
"libarchive/3.8.1#ffee18995c706e02bf96e7a2f7042e0d%1764175360.142",
|
||||||
"jemalloc/5.3.0#e951da9cf599e956cebc117880d2d9f8%1729241615.244",
|
"jemalloc/5.3.0#e951da9cf599e956cebc117880d2d9f8%1729241615.244",
|
||||||
"grpc/1.72.0#f244a57bff01e708c55a1100b12e1589%1763158050.628",
|
"grpc/1.50.1#02291451d1e17200293a409410d1c4e1%1756234248.958",
|
||||||
"ed25519/2015.03#ae761bdc52730a843f0809bdf6c1b1f6%1764270189.893",
|
"ed25519/2015.03#17c1f1910e769f368025267a53c23c13%1764259445.491",
|
||||||
"doctest/2.4.12#eb9fb352fb2fdfc8abb17ec270945165%1762797941.757",
|
"doctest/2.4.12#eb9fb352fb2fdfc8abb17ec270945165%1762797941.757",
|
||||||
"date/3.0.4#862e11e80030356b53c2c38599ceb32b%1763584497.32",
|
"date/3.0.4#862e11e80030356b53c2c38599ceb32b%1763584497.32",
|
||||||
"c-ares/1.34.5#5581c2b62a608b40bb85d965ab3ec7c8%1764175359.429",
|
"c-ares/1.34.5#5581c2b62a608b40bb85d965ab3ec7c8%1764175359.429",
|
||||||
"bzip2/1.0.8#c470882369c2d95c5c77e970c0c7e321%1764175359.429",
|
"bzip2/1.0.8#c470882369c2d95c5c77e970c0c7e321%1764175359.429",
|
||||||
"boost/1.88.0#8852c0b72ce8271fb8ff7c53456d4983%1756223752.326",
|
"boost/1.88.0#8852c0b72ce8271fb8ff7c53456d4983%1756223752.326",
|
||||||
"abseil/20250127.0#9e8e8cfc89a1324139fc0ee3bd4d8c8c%1753819045.301"
|
"abseil/20230802.1#90ba607d4ee8fb5fb157c3db540671fc%1764175359.429"
|
||||||
],
|
],
|
||||||
"build_requires": [
|
"build_requires": [
|
||||||
"zlib/1.3.1#b8bc2603263cf7eccbd6e17e66b0ed76%1756234269.497",
|
"zlib/1.3.1#b8bc2603263cf7eccbd6e17e66b0ed76%1756234269.497",
|
||||||
"strawberryperl/5.32.1.1#707032463aa0620fa17ec0d887f5fe41%1756234281.733",
|
"strawberryperl/5.32.1.1#707032463aa0620fa17ec0d887f5fe41%1756234281.733",
|
||||||
"protobuf/6.32.1#f481fd276fc23a33b85a3ed1e898b693%1759134873.45",
|
"protobuf/3.21.12#44ee56c0a6eea0c19aeeaca680370b88%1764175361.456",
|
||||||
"nasm/2.16.01#31e26f2ee3c4346ecd347911bd126904%1756234232.901",
|
"nasm/2.16.01#31e26f2ee3c4346ecd347911bd126904%1756234232.901",
|
||||||
"msys2/cci.latest#5b73b10144f73cc5bfe0572ed9be39e1%1751977009.857",
|
"msys2/cci.latest#5b73b10144f73cc5bfe0572ed9be39e1%1751977009.857",
|
||||||
"m4/1.4.19#70dc8bbb33e981d119d2acc0175cf381%1763158052.846",
|
"m4/1.4.19#70dc8bbb33e981d119d2acc0175cf381%1763158052.846",
|
||||||
@@ -37,13 +37,13 @@
|
|||||||
"cmake/3.31.10#313d16a1aa16bbdb2ca0792467214b76%1764175359.429",
|
"cmake/3.31.10#313d16a1aa16bbdb2ca0792467214b76%1764175359.429",
|
||||||
"b2/5.3.3#107c15377719889654eb9a162a673975%1756234226.28",
|
"b2/5.3.3#107c15377719889654eb9a162a673975%1756234226.28",
|
||||||
"automake/1.16.5#b91b7c384c3deaa9d535be02da14d04f%1755524470.56",
|
"automake/1.16.5#b91b7c384c3deaa9d535be02da14d04f%1755524470.56",
|
||||||
"autoconf/2.71#51077f068e61700d65bb05541ea1e4b0%1731054366.86",
|
"autoconf/2.71#51077f068e61700d65bb05541ea1e4b0%1731054366.86"
|
||||||
"abseil/20250127.0#9e8e8cfc89a1324139fc0ee3bd4d8c8c%1753819045.301"
|
|
||||||
],
|
],
|
||||||
"python_requires": [],
|
"python_requires": [],
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"protobuf/5.27.0": [
|
"protobuf/3.21.12": [
|
||||||
"protobuf/6.32.1"
|
null,
|
||||||
|
"protobuf/3.21.12"
|
||||||
],
|
],
|
||||||
"lz4/1.9.4": [
|
"lz4/1.9.4": [
|
||||||
"lz4/1.10.0"
|
"lz4/1.10.0"
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ compiler.libcxx={{detect_api.detect_libcxx(compiler, version, compiler_exe)}}
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
[conf]
|
[conf]
|
||||||
|
{% if compiler == "clang" and compiler_version >= 19 %}
|
||||||
|
grpc/1.50.1:tools.build:cxxflags+=['-Wno-missing-template-arg-list-after-template-kw']
|
||||||
|
{% endif %}
|
||||||
|
{% if compiler == "apple-clang" and compiler_version >= 17 %}
|
||||||
|
grpc/1.50.1:tools.build:cxxflags+=['-Wno-missing-template-arg-list-after-template-kw']
|
||||||
|
{% endif %}
|
||||||
{% if compiler == "gcc" and compiler_version < 13 %}
|
{% if compiler == "gcc" and compiler_version < 13 %}
|
||||||
tools.build:cxxflags+=['-Wno-restrict']
|
tools.build:cxxflags+=['-Wno-restrict']
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
16
conanfile.py
16
conanfile.py
@@ -29,7 +29,7 @@ class Xrpl(ConanFile):
|
|||||||
|
|
||||||
requires = [
|
requires = [
|
||||||
"ed25519/2015.03",
|
"ed25519/2015.03",
|
||||||
"grpc/1.72.0",
|
"grpc/1.50.1",
|
||||||
"libarchive/3.8.1",
|
"libarchive/3.8.1",
|
||||||
"nudb/2.0.9",
|
"nudb/2.0.9",
|
||||||
"openssl/3.5.4",
|
"openssl/3.5.4",
|
||||||
@@ -43,7 +43,7 @@ class Xrpl(ConanFile):
|
|||||||
]
|
]
|
||||||
|
|
||||||
tool_requires = [
|
tool_requires = [
|
||||||
"protobuf/6.32.1",
|
"protobuf/3.21.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
default_options = {
|
default_options = {
|
||||||
@@ -61,16 +61,6 @@ class Xrpl(ConanFile):
|
|||||||
"ed25519/*:shared": False,
|
"ed25519/*:shared": False,
|
||||||
"grpc/*:shared": False,
|
"grpc/*:shared": False,
|
||||||
"grpc/*:secure": True,
|
"grpc/*:secure": True,
|
||||||
"grpc/*:codegen": True,
|
|
||||||
"grpc/*:cpp_plugin": True,
|
|
||||||
"grpc/*:csharp_ext": False,
|
|
||||||
"grpc/*:csharp_plugin": False,
|
|
||||||
"grpc/*:node_plugin": False,
|
|
||||||
"grpc/*:objective_c_plugin": False,
|
|
||||||
"grpc/*:php_plugin": False,
|
|
||||||
"grpc/*:python_plugin": False,
|
|
||||||
"grpc/*:ruby_plugin": False,
|
|
||||||
"grpc/*:otel_plugin": False,
|
|
||||||
"libarchive/*:shared": False,
|
"libarchive/*:shared": False,
|
||||||
"libarchive/*:with_acl": False,
|
"libarchive/*:with_acl": False,
|
||||||
"libarchive/*:with_bzip2": False,
|
"libarchive/*:with_bzip2": False,
|
||||||
@@ -128,7 +118,7 @@ class Xrpl(ConanFile):
|
|||||||
self.requires("boost/1.88.0", force=True, **transitive_headers_opt)
|
self.requires("boost/1.88.0", force=True, **transitive_headers_opt)
|
||||||
self.requires("date/3.0.4", **transitive_headers_opt)
|
self.requires("date/3.0.4", **transitive_headers_opt)
|
||||||
self.requires("lz4/1.10.0", force=True)
|
self.requires("lz4/1.10.0", force=True)
|
||||||
self.requires("protobuf/6.32.1", force=True)
|
self.requires("protobuf/3.21.12", force=True)
|
||||||
self.requires("sqlite3/3.49.1", force=True)
|
self.requires("sqlite3/3.49.1", force=True)
|
||||||
if self.options.jemalloc:
|
if self.options.jemalloc:
|
||||||
self.requires("jemalloc/5.3.0")
|
self.requires("jemalloc/5.3.0")
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
#include <test/jtx/multisign.h>
|
#include <test/jtx/multisign.h>
|
||||||
#include <test/jtx/xchain_bridge.h>
|
#include <test/jtx/xchain_bridge.h>
|
||||||
|
|
||||||
#include <xrpld/app/tx/apply.h>
|
|
||||||
|
|
||||||
#include <xrpl/beast/unit_test.h>
|
#include <xrpl/beast/unit_test.h>
|
||||||
#include <xrpl/json/json_value.h>
|
#include <xrpl/json/json_value.h>
|
||||||
#include <xrpl/protocol/AccountID.h>
|
#include <xrpl/protocol/AccountID.h>
|
||||||
@@ -2010,370 +2008,6 @@ class LedgerEntry_test : public beast::unit_test::suite
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test the ledger entry types that don't take parameters
|
|
||||||
void
|
|
||||||
testLedgerEntryFixed()
|
|
||||||
{
|
|
||||||
using namespace test::jtx;
|
|
||||||
|
|
||||||
Account const alice{"alice"};
|
|
||||||
Account const bob{"bob"};
|
|
||||||
|
|
||||||
Env env{*this, envconfig([](auto cfg) {
|
|
||||||
cfg->START_UP = Config::FRESH;
|
|
||||||
return cfg;
|
|
||||||
})};
|
|
||||||
|
|
||||||
env.close();
|
|
||||||
|
|
||||||
/** Verifies that the RPC result has the expected data
|
|
||||||
*
|
|
||||||
* @param good: Indicates that the request should have succeeded
|
|
||||||
* and returned a ledger object of `expectedType` type.
|
|
||||||
* @param jv: The RPC result Json value
|
|
||||||
* @param expectedType: The type that the ledger object should
|
|
||||||
* have if "good".
|
|
||||||
* @param expectedError: Optional. The expected error if not
|
|
||||||
* good. Defaults to "entryNotFound".
|
|
||||||
*/
|
|
||||||
auto checkResult =
|
|
||||||
[&](bool good,
|
|
||||||
Json::Value const& jv,
|
|
||||||
Json::StaticString const& expectedType,
|
|
||||||
std::optional<std::string> const& expectedError = {}) {
|
|
||||||
if (good)
|
|
||||||
{
|
|
||||||
BEAST_EXPECTS(
|
|
||||||
jv.isObject() && jv.isMember(jss::result) &&
|
|
||||||
!jv[jss::result].isMember(jss::error) &&
|
|
||||||
jv[jss::result].isMember(jss::node) &&
|
|
||||||
jv[jss::result][jss::node].isMember(
|
|
||||||
sfLedgerEntryType.jsonName) &&
|
|
||||||
jv[jss::result][jss::node]
|
|
||||||
[sfLedgerEntryType.jsonName] == expectedType,
|
|
||||||
to_string(jv));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BEAST_EXPECTS(
|
|
||||||
jv.isObject() && jv.isMember(jss::result) &&
|
|
||||||
jv[jss::result].isMember(jss::error) &&
|
|
||||||
!jv[jss::result].isMember(jss::node) &&
|
|
||||||
jv[jss::result][jss::error] ==
|
|
||||||
expectedError.value_or("entryNotFound"),
|
|
||||||
to_string(jv));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Runs a series of tests for a given fixed-position ledger
|
|
||||||
* entry.
|
|
||||||
*
|
|
||||||
* @param field: The Json request field to use.
|
|
||||||
* @param expectedType: The type that the ledger object should
|
|
||||||
* have if "good".
|
|
||||||
* @param expectedKey: The keylet of the fixed object.
|
|
||||||
* @param good: Indicates whether the object is expected to
|
|
||||||
* exist.
|
|
||||||
*/
|
|
||||||
auto test = [&](Json::StaticString const& field,
|
|
||||||
Json::StaticString const& expectedType,
|
|
||||||
Keylet const& expectedKey,
|
|
||||||
bool good) {
|
|
||||||
testcase << "ledger_entry " << expectedType.c_str()
|
|
||||||
<< (good ? "" : " not") << " found";
|
|
||||||
|
|
||||||
auto const hexKey = strHex(expectedKey.key);
|
|
||||||
|
|
||||||
// Test bad values
|
|
||||||
// "field":null
|
|
||||||
Json::Value params;
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[field] = Json::nullValue;
|
|
||||||
auto jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, expectedType, "malformedRequest");
|
|
||||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
|
||||||
|
|
||||||
// "field":"string"
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[field] = "arbitrary string";
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, expectedType, "malformedRequest");
|
|
||||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
|
||||||
|
|
||||||
// "field":false
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[field] = false;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, expectedType, "invalidParams");
|
|
||||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
|
||||||
|
|
||||||
{
|
|
||||||
// "field":[incorrect index hash]
|
|
||||||
auto const badKey = strHex(expectedKey.key + uint256{1});
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[field] = badKey;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, expectedType, "entryNotFound");
|
|
||||||
BEAST_EXPECTS(
|
|
||||||
jv[jss::result][jss::index] == badKey, to_string(jv));
|
|
||||||
}
|
|
||||||
|
|
||||||
// "index":"field" using API 2
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::index] = field;
|
|
||||||
params[jss::api_version] = 2;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, expectedType, "malformedRequest");
|
|
||||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
|
||||||
|
|
||||||
// Test good values
|
|
||||||
// Use the "field":true notation
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[field] = true;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
// Index will always be returned for valid parameters.
|
|
||||||
std::string const pdIdx = jv[jss::result][jss::index].asString();
|
|
||||||
BEAST_EXPECTS(hexKey == pdIdx, to_string(jv));
|
|
||||||
checkResult(good, jv, expectedType);
|
|
||||||
|
|
||||||
// "field":"[index hash]"
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[field] = hexKey;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(good, jv, expectedType);
|
|
||||||
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
|
|
||||||
|
|
||||||
// Use the "index":"field" notation with API 3
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::index] = field;
|
|
||||||
params[jss::api_version] = 3;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
// Index is correct either way
|
|
||||||
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
|
|
||||||
checkResult(good, jv, expectedType);
|
|
||||||
|
|
||||||
// Use the "index":"[index hash]" notation
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::index] = pdIdx;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
// Index is correct either way
|
|
||||||
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
|
|
||||||
checkResult(good, jv, expectedType);
|
|
||||||
};
|
|
||||||
|
|
||||||
test(jss::amendments, jss::Amendments, keylet::amendments(), true);
|
|
||||||
test(jss::fee, jss::FeeSettings, keylet::fees(), true);
|
|
||||||
// There won't be an nunl
|
|
||||||
test(jss::nunl, jss::NegativeUNL, keylet::negativeUNL(), false);
|
|
||||||
// Can only get the short skip list this way
|
|
||||||
test(jss::hashes, jss::LedgerHashes, keylet::skip(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
testLedgerEntryHashes()
|
|
||||||
{
|
|
||||||
using namespace test::jtx;
|
|
||||||
|
|
||||||
Account const alice{"alice"};
|
|
||||||
Account const bob{"bob"};
|
|
||||||
|
|
||||||
Env env{*this, envconfig([](auto cfg) {
|
|
||||||
cfg->START_UP = Config::FRESH;
|
|
||||||
return cfg;
|
|
||||||
})};
|
|
||||||
|
|
||||||
env.close();
|
|
||||||
|
|
||||||
/** Verifies that the RPC result has the expected data
|
|
||||||
*
|
|
||||||
* @param good: Indicates that the request should have succeeded
|
|
||||||
* and returned a ledger object of `expectedType` type.
|
|
||||||
* @param jv: The RPC result Json value
|
|
||||||
* @param expectedCount: The number of Hashes expected in the
|
|
||||||
* object if "good".
|
|
||||||
* @param expectedError: Optional. The expected error if not
|
|
||||||
* good. Defaults to "entryNotFound".
|
|
||||||
*/
|
|
||||||
auto checkResult =
|
|
||||||
[&](bool good,
|
|
||||||
Json::Value const& jv,
|
|
||||||
int expectedCount,
|
|
||||||
std::optional<std::string> const& expectedError = {}) {
|
|
||||||
if (good)
|
|
||||||
{
|
|
||||||
BEAST_EXPECTS(
|
|
||||||
jv.isObject() && jv.isMember(jss::result) &&
|
|
||||||
!jv[jss::result].isMember(jss::error) &&
|
|
||||||
jv[jss::result].isMember(jss::node) &&
|
|
||||||
jv[jss::result][jss::node].isMember(
|
|
||||||
sfLedgerEntryType.jsonName) &&
|
|
||||||
jv[jss::result][jss::node]
|
|
||||||
[sfLedgerEntryType.jsonName] == jss::LedgerHashes,
|
|
||||||
to_string(jv));
|
|
||||||
BEAST_EXPECTS(
|
|
||||||
jv[jss::result].isMember(jss::node) &&
|
|
||||||
jv[jss::result][jss::node].isMember("Hashes") &&
|
|
||||||
jv[jss::result][jss::node]["Hashes"].size() ==
|
|
||||||
expectedCount,
|
|
||||||
to_string(jv[jss::result][jss::node]["Hashes"].size()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BEAST_EXPECTS(
|
|
||||||
jv.isObject() && jv.isMember(jss::result) &&
|
|
||||||
jv[jss::result].isMember(jss::error) &&
|
|
||||||
!jv[jss::result].isMember(jss::node) &&
|
|
||||||
jv[jss::result][jss::error] ==
|
|
||||||
expectedError.value_or("entryNotFound"),
|
|
||||||
to_string(jv));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Runs a series of tests for a given ledger index.
|
|
||||||
*
|
|
||||||
* @param ledger: The ledger index value of the "hashes" request
|
|
||||||
* parameter. May not necessarily be a number.
|
|
||||||
* @param expectedKey: The expected keylet of the object.
|
|
||||||
* @param good: Indicates whether the object is expected to
|
|
||||||
* exist.
|
|
||||||
* @param expectedCount: The number of Hashes expected in the
|
|
||||||
* object if "good".
|
|
||||||
*/
|
|
||||||
auto test = [&](Json::Value ledger,
|
|
||||||
Keylet const& expectedKey,
|
|
||||||
bool good,
|
|
||||||
int expectedCount = 0) {
|
|
||||||
testcase << "ledger_entry LedgerHashes: seq: "
|
|
||||||
<< env.current()->info().seq
|
|
||||||
<< " \"hashes\":" << to_string(ledger)
|
|
||||||
<< (good ? "" : " not") << " found";
|
|
||||||
|
|
||||||
auto const hexKey = strHex(expectedKey.key);
|
|
||||||
|
|
||||||
// Test bad values
|
|
||||||
// "hashes":null
|
|
||||||
Json::Value params;
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::hashes] = Json::nullValue;
|
|
||||||
auto jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, 0, "malformedRequest");
|
|
||||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
|
||||||
|
|
||||||
// "hashes":"non-uint string"
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::hashes] = "arbitrary string";
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, 0, "malformedRequest");
|
|
||||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
|
||||||
|
|
||||||
// "hashes":"uint string" is invalid, too
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::hashes] = "10";
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, 0, "malformedRequest");
|
|
||||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
|
||||||
|
|
||||||
// "hashes":false
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::hashes] = false;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, 0, "invalidParams");
|
|
||||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
|
||||||
|
|
||||||
// "hashes":-1
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::hashes] = -1;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, 0, "internal");
|
|
||||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
|
||||||
|
|
||||||
// "hashes":[incorrect index hash]
|
|
||||||
{
|
|
||||||
auto const badKey = strHex(expectedKey.key + uint256{1});
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::hashes] = badKey;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(false, jv, 0, "entryNotFound");
|
|
||||||
BEAST_EXPECT(jv[jss::result][jss::index] == badKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test good values
|
|
||||||
// Use the "hashes":ledger notation
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::hashes] = ledger;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(good, jv, expectedCount);
|
|
||||||
// Index will always be returned for valid parameters.
|
|
||||||
std::string const pdIdx = jv[jss::result][jss::index].asString();
|
|
||||||
BEAST_EXPECTS(hexKey == pdIdx, strHex(pdIdx));
|
|
||||||
|
|
||||||
// "hashes":"[index hash]"
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::hashes] = hexKey;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(good, jv, expectedCount);
|
|
||||||
// Index is correct either way
|
|
||||||
BEAST_EXPECTS(
|
|
||||||
hexKey == jv[jss::result][jss::index].asString(),
|
|
||||||
strHex(jv[jss::result][jss::index].asString()));
|
|
||||||
|
|
||||||
// Use the "index":"[index hash]" notation
|
|
||||||
params.clear();
|
|
||||||
params[jss::ledger_index] = jss::validated;
|
|
||||||
params[jss::index] = hexKey;
|
|
||||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
|
||||||
checkResult(good, jv, expectedCount);
|
|
||||||
// Index is correct either way
|
|
||||||
BEAST_EXPECTS(
|
|
||||||
hexKey == jv[jss::result][jss::index].asString(),
|
|
||||||
strHex(jv[jss::result][jss::index].asString()));
|
|
||||||
};
|
|
||||||
|
|
||||||
// short skip list
|
|
||||||
test(true, keylet::skip(), true, 2);
|
|
||||||
// long skip list at index 0
|
|
||||||
test(1, keylet::skip(1), false);
|
|
||||||
// long skip list at index 1
|
|
||||||
test(1 << 17, keylet::skip(1 << 17), false);
|
|
||||||
|
|
||||||
// Close more ledgers, but stop short of the flag ledger
|
|
||||||
for (auto i = env.current()->seq(); i <= 250; ++i)
|
|
||||||
env.close();
|
|
||||||
|
|
||||||
// short skip list
|
|
||||||
test(true, keylet::skip(), true, 249);
|
|
||||||
// long skip list at index 0
|
|
||||||
test(1, keylet::skip(1), false);
|
|
||||||
// long skip list at index 1
|
|
||||||
test(1 << 17, keylet::skip(1 << 17), false);
|
|
||||||
|
|
||||||
// Close a flag ledger so the first "long" skip list is created
|
|
||||||
for (auto i = env.current()->seq(); i <= 260; ++i)
|
|
||||||
env.close();
|
|
||||||
|
|
||||||
// short skip list
|
|
||||||
test(true, keylet::skip(), true, 256);
|
|
||||||
// long skip list at index 0
|
|
||||||
test(1, keylet::skip(1), true, 1);
|
|
||||||
// long skip list at index 1
|
|
||||||
test(1 << 17, keylet::skip(1 << 17), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
testLedgerEntryCLI()
|
testLedgerEntryCLI()
|
||||||
{
|
{
|
||||||
@@ -2423,8 +2057,6 @@ public:
|
|||||||
testOracleLedgerEntry();
|
testOracleLedgerEntry();
|
||||||
testLedgerEntryMPT();
|
testLedgerEntryMPT();
|
||||||
testLedgerEntryPermissionedDomain();
|
testLedgerEntryPermissionedDomain();
|
||||||
testLedgerEntryFixed();
|
|
||||||
testLedgerEntryHashes();
|
|
||||||
testLedgerEntryCLI();
|
testLedgerEntryCLI();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,32 +18,6 @@
|
|||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
using FunctionType = std::function<Expected<uint256, Json::Value>(
|
|
||||||
Json::Value const&,
|
|
||||||
Json::StaticString const,
|
|
||||||
unsigned apiVersion)>;
|
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
|
||||||
parseFixed(
|
|
||||||
Keylet const& keylet,
|
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const& fieldName,
|
|
||||||
unsigned apiVersion);
|
|
||||||
|
|
||||||
// Helper function to return FunctionType for objects that have a fixed
|
|
||||||
// location. That is, they don't take parameters to compute the index.
|
|
||||||
// e.g. amendments, fees, negative UNL, etc.
|
|
||||||
static FunctionType
|
|
||||||
fixed(Keylet const& keylet)
|
|
||||||
{
|
|
||||||
return [&keylet](
|
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion) -> Expected<uint256, Json::Value> {
|
|
||||||
return parseFixed(keylet, params, fieldName, apiVersion);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseObjectID(
|
parseObjectID(
|
||||||
Json::Value const& params,
|
Json::Value const& params,
|
||||||
@@ -59,33 +33,13 @@ parseObjectID(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseIndex(
|
parseIndex(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (apiVersion > 2u && params.isString())
|
|
||||||
{
|
|
||||||
std::string const index = params.asString();
|
|
||||||
if (index == jss::amendments.c_str())
|
|
||||||
return keylet::amendments().key;
|
|
||||||
if (index == jss::fee.c_str())
|
|
||||||
return keylet::fees().key;
|
|
||||||
if (index == jss::nunl)
|
|
||||||
return keylet::negativeUNL().key;
|
|
||||||
if (index == jss::hashes)
|
|
||||||
// Note this only finds the "short" skip list. Use "hashes":index to
|
|
||||||
// get the long list.
|
|
||||||
return keylet::skip().key;
|
|
||||||
}
|
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseAccountRoot(
|
parseAccountRoot(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (auto const account = LedgerEntryHelpers::parse<AccountID>(params))
|
if (auto const account = LedgerEntryHelpers::parse<AccountID>(params))
|
||||||
{
|
{
|
||||||
@@ -96,13 +50,14 @@ parseAccountRoot(
|
|||||||
"malformedAddress", fieldName, "AccountID");
|
"malformedAddress", fieldName, "AccountID");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const parseAmendments = fixed(keylet::amendments());
|
static Expected<uint256, Json::Value>
|
||||||
|
parseAmendments(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
|
{
|
||||||
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseAMM(
|
parseAMM(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -129,10 +84,7 @@ parseAMM(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseBridge(
|
parseBridge(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isMember(jss::bridge))
|
if (!params.isMember(jss::bridge))
|
||||||
{
|
{
|
||||||
@@ -163,19 +115,13 @@ parseBridge(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseCheck(
|
parseCheck(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseCredential(
|
parseCredential(Json::Value const& cred, Json::StaticString const fieldName)
|
||||||
Json::Value const& cred,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!cred.isObject())
|
if (!cred.isObject())
|
||||||
{
|
{
|
||||||
@@ -206,10 +152,7 @@ parseCredential(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseDelegate(
|
parseDelegate(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -300,10 +243,7 @@ parseAuthorizeCredentials(Json::Value const& jv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseDepositPreauth(
|
parseDepositPreauth(Json::Value const& dp, Json::StaticString const fieldName)
|
||||||
Json::Value const& dp,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!dp.isObject())
|
if (!dp.isObject())
|
||||||
{
|
{
|
||||||
@@ -356,10 +296,7 @@ parseDepositPreauth(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseDID(
|
parseDID(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
auto const account = LedgerEntryHelpers::parse<AccountID>(params);
|
auto const account = LedgerEntryHelpers::parse<AccountID>(params);
|
||||||
if (!account)
|
if (!account)
|
||||||
@@ -374,8 +311,7 @@ parseDID(
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseDirectoryNode(
|
parseDirectoryNode(
|
||||||
Json::Value const& params,
|
Json::Value const& params,
|
||||||
Json::StaticString const fieldName,
|
Json::StaticString const fieldName)
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -428,10 +364,7 @@ parseDirectoryNode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseEscrow(
|
parseEscrow(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -450,53 +383,20 @@ parseEscrow(
|
|||||||
return keylet::escrow(*id, *seq).key;
|
return keylet::escrow(*id, *seq).key;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const parseFeeSettings = fixed(keylet::fees());
|
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseFixed(
|
parseFeeSettings(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Keylet const& keylet,
|
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const& fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isBool())
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
{
|
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
|
||||||
}
|
|
||||||
if (!params.asBool())
|
|
||||||
{
|
|
||||||
return LedgerEntryHelpers::invalidFieldError(
|
|
||||||
"invalidParams", fieldName, "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
return keylet.key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseLedgerHashes(
|
parseLedgerHashes(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (params.isUInt() || params.isInt())
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
{
|
|
||||||
// If the index doesn't parse as a UInt, throw
|
|
||||||
auto const index = params.asUInt();
|
|
||||||
|
|
||||||
// Return the "long" skip list for the given ledger index.
|
|
||||||
auto const keylet = keylet::skip(index);
|
|
||||||
return keylet.key;
|
|
||||||
}
|
|
||||||
// Return the key in `params` or the "short" skip list, which contains
|
|
||||||
// hashes since the last flag ledger.
|
|
||||||
return parseFixed(keylet::skip(), params, fieldName, apiVersion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseLoanBroker(
|
parseLoanBroker(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -516,10 +416,7 @@ parseLoanBroker(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseLoan(
|
parseLoan(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -539,10 +436,7 @@ parseLoan(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseMPToken(
|
parseMPToken(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -565,8 +459,7 @@ parseMPToken(
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseMPTokenIssuance(
|
parseMPTokenIssuance(
|
||||||
Json::Value const& params,
|
Json::Value const& params,
|
||||||
Json::StaticString const fieldName,
|
Json::StaticString const fieldName)
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
auto const mptIssuanceID = LedgerEntryHelpers::parse<uint192>(params);
|
auto const mptIssuanceID = LedgerEntryHelpers::parse<uint192>(params);
|
||||||
if (!mptIssuanceID)
|
if (!mptIssuanceID)
|
||||||
@@ -577,30 +470,25 @@ parseMPTokenIssuance(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseNFTokenOffer(
|
parseNFTokenOffer(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseNFTokenPage(
|
parseNFTokenPage(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const parseNegativeUNL = fixed(keylet::negativeUNL());
|
static Expected<uint256, Json::Value>
|
||||||
|
parseNegativeUNL(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
|
{
|
||||||
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseOffer(
|
parseOffer(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -621,10 +509,7 @@ parseOffer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseOracle(
|
parseOracle(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -645,10 +530,7 @@ parseOracle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parsePayChannel(
|
parsePayChannel(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
@@ -656,8 +538,7 @@ parsePayChannel(
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parsePermissionedDomain(
|
parsePermissionedDomain(
|
||||||
Json::Value const& pd,
|
Json::Value const& pd,
|
||||||
Json::StaticString const fieldName,
|
Json::StaticString const fieldName)
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (pd.isString())
|
if (pd.isString())
|
||||||
{
|
{
|
||||||
@@ -686,8 +567,7 @@ parsePermissionedDomain(
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseRippleState(
|
parseRippleState(
|
||||||
Json::Value const& jvRippleState,
|
Json::Value const& jvRippleState,
|
||||||
Json::StaticString const fieldName,
|
Json::StaticString const fieldName)
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
Currency uCurrency;
|
Currency uCurrency;
|
||||||
|
|
||||||
@@ -737,19 +617,13 @@ parseRippleState(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseSignerList(
|
parseSignerList(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
return parseObjectID(params, fieldName, "hex string");
|
return parseObjectID(params, fieldName, "hex string");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseTicket(
|
parseTicket(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -770,10 +644,7 @@ parseTicket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseVault(
|
parseVault(Json::Value const& params, Json::StaticString const fieldName)
|
||||||
Json::Value const& params,
|
|
||||||
Json::StaticString const fieldName,
|
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!params.isObject())
|
if (!params.isObject())
|
||||||
{
|
{
|
||||||
@@ -796,8 +667,7 @@ parseVault(
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseXChainOwnedClaimID(
|
parseXChainOwnedClaimID(
|
||||||
Json::Value const& claim_id,
|
Json::Value const& claim_id,
|
||||||
Json::StaticString const fieldName,
|
Json::StaticString const fieldName)
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!claim_id.isObject())
|
if (!claim_id.isObject())
|
||||||
{
|
{
|
||||||
@@ -822,8 +692,7 @@ parseXChainOwnedClaimID(
|
|||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
parseXChainOwnedCreateAccountClaimID(
|
parseXChainOwnedCreateAccountClaimID(
|
||||||
Json::Value const& claim_id,
|
Json::Value const& claim_id,
|
||||||
Json::StaticString const fieldName,
|
Json::StaticString const fieldName)
|
||||||
unsigned apiVersion)
|
|
||||||
{
|
{
|
||||||
if (!claim_id.isObject())
|
if (!claim_id.isObject())
|
||||||
{
|
{
|
||||||
@@ -847,6 +716,10 @@ parseXChainOwnedCreateAccountClaimID(
|
|||||||
return keylet.key;
|
return keylet.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using FunctionType = Expected<uint256, Json::Value> (*)(
|
||||||
|
Json::Value const&,
|
||||||
|
Json::StaticString const);
|
||||||
|
|
||||||
struct LedgerEntry
|
struct LedgerEntry
|
||||||
{
|
{
|
||||||
Json::StaticString fieldName;
|
Json::StaticString fieldName;
|
||||||
@@ -879,7 +752,7 @@ doLedgerEntry(RPC::JsonContext& context)
|
|||||||
{jss::ripple_state, parseRippleState, ltRIPPLE_STATE},
|
{jss::ripple_state, parseRippleState, ltRIPPLE_STATE},
|
||||||
});
|
});
|
||||||
|
|
||||||
auto const hasMoreThanOneMember = [&]() {
|
auto hasMoreThanOneMember = [&]() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (auto const& ledgerEntry : ledgerEntryParsers)
|
for (auto const& ledgerEntry : ledgerEntryParsers)
|
||||||
@@ -923,8 +796,8 @@ doLedgerEntry(RPC::JsonContext& context)
|
|||||||
Json::Value const& params = ledgerEntry.fieldName == jss::bridge
|
Json::Value const& params = ledgerEntry.fieldName == jss::bridge
|
||||||
? context.params
|
? context.params
|
||||||
: context.params[ledgerEntry.fieldName];
|
: context.params[ledgerEntry.fieldName];
|
||||||
auto const result = ledgerEntry.parseFunction(
|
auto const result =
|
||||||
params, ledgerEntry.fieldName, context.apiVersion);
|
ledgerEntry.parseFunction(params, ledgerEntry.fieldName);
|
||||||
if (!result)
|
if (!result)
|
||||||
return result.error();
|
return result.error();
|
||||||
|
|
||||||
@@ -955,13 +828,9 @@ doLedgerEntry(RPC::JsonContext& context)
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the computed index regardless of whether the node exists.
|
|
||||||
jvResult[jss::index] = to_string(uNodeIndex);
|
|
||||||
|
|
||||||
if (uNodeIndex.isZero())
|
if (uNodeIndex.isZero())
|
||||||
{
|
{
|
||||||
RPC::inject_error(rpcENTRY_NOT_FOUND, jvResult);
|
return RPC::make_error(rpcENTRY_NOT_FOUND);
|
||||||
return jvResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const sleNode = lpLedger->read(keylet::unchecked(uNodeIndex));
|
auto const sleNode = lpLedger->read(keylet::unchecked(uNodeIndex));
|
||||||
@@ -973,14 +842,12 @@ doLedgerEntry(RPC::JsonContext& context)
|
|||||||
if (!sleNode)
|
if (!sleNode)
|
||||||
{
|
{
|
||||||
// Not found.
|
// Not found.
|
||||||
RPC::inject_error(rpcENTRY_NOT_FOUND, jvResult);
|
return RPC::make_error(rpcENTRY_NOT_FOUND);
|
||||||
return jvResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((expectedType != ltANY) && (expectedType != sleNode->getType()))
|
if ((expectedType != ltANY) && (expectedType != sleNode->getType()))
|
||||||
{
|
{
|
||||||
RPC::inject_error(rpcUNEXPECTED_LEDGER_TYPE, jvResult);
|
return RPC::make_error(rpcUNEXPECTED_LEDGER_TYPE);
|
||||||
return jvResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bNodeBinary)
|
if (bNodeBinary)
|
||||||
@@ -990,10 +857,12 @@ doLedgerEntry(RPC::JsonContext& context)
|
|||||||
sleNode->add(s);
|
sleNode->add(s);
|
||||||
|
|
||||||
jvResult[jss::node_binary] = strHex(s.peekData());
|
jvResult[jss::node_binary] = strHex(s.peekData());
|
||||||
|
jvResult[jss::index] = to_string(uNodeIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jvResult[jss::node] = sleNode->getJson(JsonOptions::none);
|
jvResult[jss::node] = sleNode->getJson(JsonOptions::none);
|
||||||
|
jvResult[jss::index] = to_string(uNodeIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return jvResult;
|
return jvResult;
|
||||||
|
|||||||
Reference in New Issue
Block a user