Open mvadari opened 11 hours ago
Other than the ones I mentioned, i'd like to see
const
applied everywhere it can be. I'd also prefer to see some more spacing lines betweenif
statements and stuff like that. Bigif
conditions could be broken down to helper functions/lambdas and/or constants. Some of them are pretty hard to read as they are now but I understand that's old code, not new one.
Thanks for the review! I added more spacing and I think I added const
everywhere where applicable.
Definitely plan on adding more helper functions (every individual parser was written sort of individually, and had to reinvent a lot of wheels, and I think helper functions would do a lot to unify a lot of that). But wanted to save that for a separate PR to make this PR easier to review (since that code is already being moved around pretty significantly).
Attention: Patch coverage is 79.06977%
with 90 lines
in your changes missing coverage. Please review.
Project coverage is 77.9%. Comparing base (
0ec17b6
) to head (ee270ab
).
Files with missing lines | Patch % | Lines |
---|---|---|
src/xrpld/rpc/handlers/LedgerEntry.cpp | 78.9% | 89 Missing :warning: |
src/xrpld/net/detail/RPCCall.cpp | 87.5% | 1 Missing :warning: |
🚨 Try these New Features:
High Level Overview of Change
This PR heavily restructures
LedgerEntry.cpp
to make it easier to read and understand.Instead of having a nested series of if-elses, which is very difficult to parse, each object now has 3 elements in an array: the parameter name, a parsing function, and the expected ledger entry type.
This allows the parsing logic to be greatly simplified by returning early in each of the parsing functions, instead of needing to fall through with a lot of else statements - and this also avoids a lot of extra indenting (which in turn makes the code easier to read). It also makes it easier to audit what ledger entries are missing (e.g. NFT Offers are missing right now), and avoids bugs from forgetting to specify the expected ledger entry type.
It does not change any of the individual ledger entry parsing code, to make this PR easier to follow and review.
Context of Change
LedgerEntry.cpp
was a very messy file. I caught a bug in a PR that would have been avoided by this sort of structure.Type of Change
API Impact
No change in functionality.
Test Plan
Tests remained mostly unchanged. We may want some basic performance regression tests, but the performance effect should be pretty minimal.
Future Tasks