3#include <eosio/eosio.hpp>
4#include <eosio/../../capi/eosio/db.h>
29 static constexpr uint32_t
BUDGET = 100;
40 inline bool row_exists(eosio::name code, uint64_t scope, eosio::name table, uint64_t primary_key) {
41 return db_find_i64(code.value, scope, table.value, primary_key) >= 0;
51 template <
typename Index>
52 inline bool next_index_value(eosio::name code, uint64_t scope, uint64_t from, uint64_t &value) {
53 uint64_t secondary = from;
55 const int32_t itr = db_idx64_lowerbound(code.value, scope, Index::name(), &secondary, &primary);
56 if (itr < 0)
return false;
79 template <
typename Index,
typename Pred>
81 for (
auto it = index.begin(); it != index.end() && !b.
exhausted();) {
92 template <
typename Table>
94 erase_where(table, b, [](
const auto &) {
return true; });
100 b.
exhausted() ?
", бюджет исчерпан — продолжит следующий вызов" :
"");
contract
Definition: eosio.msig_tests.cpp:977
Очистка отработавших записей — общее для действия cleanup всех контрактов.
Definition: cleanup.hpp:27
void erase_where(Index &index, budget &b, Pred pred)
Удаляет строки индекса или таблицы, для которых выполнено условие.
Definition: cleanup.hpp:80
void erase_all(Table &table, budget &b)
Удаляет все строки таблицы, которую код больше не читает и не пишет.
Definition: cleanup.hpp:93
static constexpr uint32_t BUDGET
Строк на один вызов cleanup
Definition: cleanup.hpp:29
void report(eosio::name contract, const budget &b)
Итог вызова в консоль транзакции — его видит лог плейбука.
Definition: cleanup.hpp:98
bool row_exists(eosio::name code, uint64_t scope, eosio::name table, uint64_t primary_key)
Есть ли в таблице строка с таким первичным ключом — без разбора строки.
Definition: cleanup.hpp:40
bool next_index_value(eosio::name code, uint64_t scope, uint64_t from, uint64_t &value)
Следующее значение вторичного индекса uint64 не меньше from — без разбора строк.
Definition: cleanup.hpp:52
Остаток строк, которые текущий вызов ещё может удалить.
Definition: cleanup.hpp:62
bool exhausted() const
Definition: cleanup.hpp:66
void take()
Definition: cleanup.hpp:67
uint32_t erased
Definition: cleanup.hpp:64
uint32_t left
Definition: cleanup.hpp:63