mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-27 23:38:08 +00:00
Review follow-up on the freshen lock-hold fix: - Drop host names, dates and one-site figures from the new comments, harness notes and docs; explain the mechanism in general terms. - RotationPhase stores its stage and cache labels as owned std::string, not std::string_view: the ctor still takes views so the label constants pass without a copy, but a member view would dangle if a caller ever passed a temporary. freshenCache/recordFreshen take the cache name by std::string_view (read-only, call-scoped). - The new DatabaseRotating test called fetchNodeObject through the derived type, whose private override hides the public base method; call it through Database& instead. This was the dev-box build break. - freshenCache reports the exact fetched count when a health abort cuts it short, and stops labelling the per-partition hold 'getKeys'. - Remove a [[maybe_unused]] that silenced no warning (the build sets -Wno-unused-parameter and disables misc-unused-parameters).
Basics
Utility functions and classes.
The module xrpl/basics should contain no dependencies on other modules.
Choosing an xrpld container.
-
std::vector- For ordered containers with most insertions or erases at the end.
-
std::deque- For ordered containers with most insertions or erases at the start or end.
-
std::list- For ordered containers with inserts and erases to the middle.
- For containers with iterators stable over insert and erase.
- Generally slower and bigger than
std::vectororstd::dequeexcept for those cases.
-
std::set- For sorted containers.
-
xrpl::hash_set- Where inserts and contains need to be O(1).
- For "small" sets,
std::setmight be faster and smaller.
-
xrpl::hardened_hash_set- For data sets where the key could be manipulated by an attacker in an attempt to mount an algorithmic complexity attack: see http://en.wikipedia.org/wiki/Algorithmic_complexity_attack
The following container is deprecated
std::unordered_set- Use
xrpl::hash_setinstead, which uses a better hashing algorithm. - Or use
xrpl::hardened_hash_setto prevent algorithmic complexity attacks.