breaks down InvariantCheck to multiple classes - #6440
Conversation
godexsoft
left a comment
There was a problem hiding this comment.
I like this new structure. We should consider adding a namespace like 'invariants' for all of this (could be done in a separate pr if there is interest).
To fix pre-commit you may want to setup pre-commit hooks so that clang-format automatically fixes code when you commit/push.
Thanks @godexsoft ! I'm not sure why my local formatter keeps making these changes... I configured pre-commit |
The invariant check system had grown into a single monolithic file pair containing 24 invariant checker classes. The large `InvariantCheck.cpp` file was a frequent source of merge conflicts and difficult to navigate. This refactoring improves maintainability and readability with zero behavioral changes. In particular, this change: - Splits `InvariantCheck.h` and `InvariantCheck.cpp` into 10 focused header/source pairs organized by domain under a new `invariants/` subdirectory. - Extracts the shared `Privilege` enum and `hasPrivilege()` function into a dedicated `InvariantCheckPrivilege.h` header, so domain-specific files can reference them independently.
Summary
InvariantCheck.h(733 lines) andInvariantCheck.cpp(3,483 lines) into 10 focused header/source pairs organized by domain under a newinvariants/subdirectoryPrivilegeenum andhasPrivilege()function into a dedicatedInvariantCheckPrivilege.hheader so domain-specific files can reference them independentlyMotivation
The invariant check system had grown into a single monolithic file pair containing 24 invariant checker classes. At 3,483 lines,
InvariantCheck.cppwas a frequent source of merge conflicts and difficult to navigate. This refactoring improves maintainability and readability with zero behavioral changes.File layout
Design decisions
InvariantCheck.hremains the single entry point: It#includes all sub-headers and still defines theInvariantCheckstuple andgetInvariantChecks(). Consumers likeApplyContext.cpponly update the include path — no logic changes.InvariantCheckPrivilege.h: ThePrivilegeenum andhasPrivilege()are used by 6 different invariant classes across separate translation units. The enum andconstexpr operator|live in the header;hasPrivilege()is declared there but defined inInvariantCheck.cppbecause it uses thetransactions.macroX-macro which requires single-TU compilation.add_module(xrpl tx)usesGLOB_RECURSEwhich automatically discovers files in subdirectories.Next Steps
Vault...Invariant
High Level Overview of Change
Context of Change
Type of Change
.gitignore, formatting, dropping support for older tooling)API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)