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