Cleanup LedgerEntryType & TxType:

This commit removes the `ltINVALID` pseudo-type identifier from
`LedgerEntryType` and the `ttINVALID` pseudo-type identifier from
`TxType` and includes several small additional improvements that
help to simplify the code base.

It also improves the documentation `LedgerEntryType` and `TxType`,
which was all over the place, and highlights some important caveats
associated with making changes to the ledger and transaction type
identifiers.

The commit also adds a safety check to the `KnownFormats<>` class,
that will catch the the accidental reuse of format identifiers.
Ideally, this should be done at compile time but C++ does not (yet?)
allow for the sort of introspection that would enable this.
This commit is contained in:
Nik Bougalis
2021-08-25 01:14:53 -07:00
parent 234b754038
commit af5f28cbf8
15 changed files with 295 additions and 120 deletions

View File

@@ -23,17 +23,16 @@
namespace ripple {
bool
Keylet::check(SLE const& sle) const
Keylet::check(STLedgerEntry const& sle) const
{
assert(sle.getType() != ltANY || sle.getType() != ltCHILD);
if (type == ltANY)
return true;
if (type == ltINVALID)
return false;
if (type == ltCHILD)
{
assert(sle.getType() != ltDIR_NODE);
return sle.getType() != ltDIR_NODE;
}
return sle.getType() == type;
}