xrpld
Loading...
Searching...
No Matches
InvariantCheckPrivilege.h
1#pragma once
2
3#include <xrpl/protocol/STTx.h>
4#include <xrpl/protocol/TxSettings.h> // IWYU pragma: export
5
6namespace xrpl {
7
8/*
9assert(enforce)
10
11There are several asserts (or XRPL_ASSERTs) in invariant check files that check
12a variable named `enforce` when an invariant fails. At first glance, those
13asserts may look incorrect, but they are not.
14
15Those asserts take advantage of two facts:
161. `asserts` are not (normally) executed in release builds.
172. Invariants should *never* fail, except in tests that specifically modify
18 the open ledger to break them.
19
20This makes `assert(enforce)` sort of a second-layer of invariant enforcement
21aimed at _developers_. It's designed to fire if a developer writes code that
22violates an invariant, and runs it in unit tests or a develop build that _does
23not have the relevant amendments enabled_. It's intentionally a pain in the neck
24so that bad code gets caught and fixed as early as possible.
25*/
26
27// `enum Privilege` and its `operator|` live in <xrpl/protocol/TxSettings.h>,
28// alongside the TxSettings struct that carries them out of transactions.macro.
29
30bool
31hasPrivilege(STTx const& tx, Privilege priv);
32
33} // namespace xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
Privilege
Operations a transaction is permitted to perform, as a bitfield.
Definition TxSettings.h:19
bool hasPrivilege(STTx const &tx, Privilege priv)