mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-05 01:37:00 +00:00
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.
54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <xrpl/beast/utility/Journal.h>
|
|
#include <xrpl/ledger/ReadView.h>
|
|
#include <xrpl/protocol/STAmount.h>
|
|
#include <xrpl/protocol/STTx.h>
|
|
#include <xrpl/protocol/TER.h>
|
|
|
|
#include <optional>
|
|
|
|
namespace xrpl {
|
|
|
|
class ValidAMM
|
|
{
|
|
std::optional<AccountID> ammAccount_;
|
|
std::optional<STAmount> lptAMMBalanceAfter_;
|
|
std::optional<STAmount> lptAMMBalanceBefore_;
|
|
bool ammPoolChanged_;
|
|
|
|
public:
|
|
enum class ZeroAllowed : bool { No = false, Yes = true };
|
|
|
|
ValidAMM() : ammPoolChanged_{false}
|
|
{
|
|
}
|
|
void
|
|
visitEntry(bool, std::shared_ptr<SLE const> const&, std::shared_ptr<SLE const> const&);
|
|
|
|
bool
|
|
finalize(STTx const&, TER const, XRPAmount const, ReadView const&, beast::Journal const&);
|
|
|
|
private:
|
|
bool
|
|
finalizeBid(bool enforce, beast::Journal const&) const;
|
|
bool
|
|
finalizeVote(bool enforce, beast::Journal const&) const;
|
|
bool
|
|
finalizeCreate(STTx const&, ReadView const&, bool enforce, beast::Journal const&) const;
|
|
bool
|
|
finalizeDelete(bool enforce, TER res, beast::Journal const&) const;
|
|
bool
|
|
finalizeDeposit(STTx const&, ReadView const&, bool enforce, beast::Journal const&) const;
|
|
// Includes clawback
|
|
bool
|
|
finalizeWithdraw(STTx const&, ReadView const&, bool enforce, beast::Journal const&) const;
|
|
bool
|
|
finalizeDEX(bool enforce, beast::Journal const&) const;
|
|
bool
|
|
generalInvariant(STTx const&, ReadView const&, ZeroAllowed zeroAllowed, beast::Journal const&)
|
|
const;
|
|
};
|
|
|
|
} // namespace xrpl
|