refactor: Clean up NetworkOPs - #6575
Conversation
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6575 +/- ##
=========================================
- Coverage 82.5% 82.5% -0.0%
=========================================
Files 1010 1010
Lines 79246 79232 -14
Branches 7529 7531 +2
=========================================
- Hits 65389 65366 -23
- Misses 13857 13866 +9
🚀 New features to boost your workflow:
|
…eanup-for-network-ops Signed-off-by: JCW <a1q123456@users.noreply.github.com> # Conflicts: # src/xrpld/app/misc/NetworkOPs.cpp
| auto const& txns = dbResult->first; | ||
| marker = dbResult->second; | ||
| size_t num_txns = txns.size(); | ||
| for (size_t i = 0; i < num_txns; ++i) |
There was a problem hiding this comment.
[nit] while we're touching this code, could we move away from the index-based loop and use a range-based or iterator-style loop instead? Not a blocker though — I’m also fine leaving this kind of mechanical cleanup to clang-tidy.
There was a problem hiding this comment.
Because what we're doing at the line 3741, we can't convert this for loop until we upgrade to c++ 23, which will give us std::views::chunk_by
vlntb
left a comment
There was a problem hiding this comment.
This change looks good to me. I like the simplification here: it removes handling for an impossible case and avoids downcasting by relying on the shared interface instead. Approving.
There was a problem hiding this comment.
Pull request overview
This PR refactors NetworkOPsImp::addAccountHistoryJob to avoid depending on a specific relational DB implementation (SQLite) and removes a previously-unreachable database-type check/downcast, aligning the code with the simplified RelationalDatabase hierarchy.
Changes:
- Removes
SQLiteDatabaseinclude and eliminates database-type probing viadynamic_cast. - Updates account history paging to call
RelationalDatabase::newestAccountTxPage()directly. - Restructures the job lambda to remove the SQLite-specific switch/case and related unreachable paths.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
…eanup-for-network-ops
6862d87 to
3174777
Compare
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
…eanup-for-network-ops
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
…eanup-for-network-ops
godexsoft
left a comment
There was a problem hiding this comment.
Looks fine overall. You can likely add const in many places in the changed code. But since it's not new code and clang-tidy can do that later too, it's ok to leave it out.
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
…eanup-for-network-ops
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
High Level Overview of Change
This PR cleans up a code path that checks the database type because never going to hit, and a dynamic cast that casts the database type from
RelationalDatabasetoSqlLiteDatabaseinNetworkOPsImp::addAccountHistoryJob.Detailed change list
Removed the lines from 3486 to 3510. Removed the
databaseTypecapture from the lambda at the line 3513, and extractedcase Sqlitefrom the switch-case block.Context of Change
We simplified the inheritance hierarchy for
RelationalDatabasein a previous PR and most of the services don't need to downcast the database instance toSqlLiteDatabaseanymore, also, a good design should never care about what the actual implementation is.API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)