-
Notifications
You must be signed in to change notification settings - Fork 75
feat: Read and write LedgerCache to file #2761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kuznetsss
merged 36 commits into
XRPLF:develop
from
kuznetsss:2413_Read_write_cache_from_disk
Nov 13, 2025
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
04482d4
Experimenting with binary cache
kuznetsss e33c428
Add cache.local_file options
kuznetsss 8d4427e
WIP: Rewriting cache reading writing
kuznetsss be922ef
Add streaming shasum class
kuznetsss 2e39083
Fix bugs, add sha256 hashsum
kuznetsss f2d4f89
Add tests for InputFile
kuznetsss 56cf901
Add tests for OutputFile
kuznetsss 58a9365
Move implementation to cpp files
kuznetsss 4cce68d
Add tests for LedgerCacheFile
kuznetsss efa12e0
Add save/load code to LedgerCache
kuznetsss 525e0b5
Move LedgerCacheFile implementation into cpp file
kuznetsss fca246f
Remove buffer and compression options
kuznetsss 58ba86a
Added hash() method to input and output files
kuznetsss 3f7b22d
Change cache file to use one hash for the whole file
kuznetsss cf2fa1c
WIP: save/load chache on clio start/stop
kuznetsss 35bcb86
Save and load ledger cache in clio
kuznetsss f6dbe4e
Add more tests
kuznetsss 5dce1f5
Merge remote-tracking branch 'upstream/develop' into 2413_Read_write_…
kuznetsss 8ecf622
Fix after merge
kuznetsss 47a2daa
Merge branch 'develop' into 2413_Read_write_cache_from_disk
kuznetsss b1b4d27
Run pre-commit
kuznetsss b631b72
Add missing docs
kuznetsss 6155d2c
Fix build
kuznetsss f12a0c2
Merge branch 'develop' into 2413_Read_write_cache_from_disk
kuznetsss 03d974f
Remove timestamp and add sequence verification
kuznetsss 17ce255
Save cache file with prefix new
kuznetsss c22fa4a
Revert precommit changes
kuznetsss a4749a3
Merge branch 'develop' into 2413_Read_write_cache_from_disk
kuznetsss 5cad274
Fix docs
kuznetsss 63ea5c3
Fix config key
kuznetsss 81edb2a
Fix review comments
kuznetsss ae5b54f
Update config description
kuznetsss 60e0a6d
Fix review comments
kuznetsss 2651b9c
Merge branch 'develop' into 2413_Read_write_cache_from_disk
kuznetsss cec4b44
Fix typo
kuznetsss b5567bc
Merge branch 'develop' into 2413_Read_write_cache_from_disk
kuznetsss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| //------------------------------------------------------------------------------ | ||
| /* | ||
| This file is part of clio: https://github.com/XRPLF/clio | ||
| Copyright (c) 2025, the clio developers. | ||
|
|
||
| Permission to use, copy, modify, and distribute this software for any | ||
| purpose with or without fee is hereby granted, provided that the above | ||
| copyright notice and this permission notice appear in all copies. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| */ | ||
| //============================================================================== | ||
|
|
||
| #include "data/impl/InputFile.hpp" | ||
|
|
||
| #include <xrpl/basics/base_uint.h> | ||
|
|
||
| #include <cstddef> | ||
| #include <cstring> | ||
| #include <ios> | ||
| #include <iosfwd> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| namespace data::impl { | ||
|
|
||
| InputFile::InputFile(std::string const& path) : file_(path, std::ios::binary | std::ios::in) | ||
| { | ||
| } | ||
|
|
||
| bool | ||
| InputFile::isOpen() const | ||
| { | ||
| return file_.is_open(); | ||
| } | ||
|
|
||
| bool | ||
| InputFile::readRaw(char* data, size_t size) | ||
| { | ||
| file_.read(data, size); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. null check before reading?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will crash anyway if |
||
| shasum_.update(data, size); | ||
| return not file_.fail(); | ||
kuznetsss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| ripple::uint256 | ||
| InputFile::hash() const | ||
| { | ||
| auto sum = shasum_; | ||
| return std::move(sum).finalize(); | ||
| } | ||
|
|
||
| } // namespace data::impl | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.