Fix ringct+coinbase output tracking, and update rescan rollbacks (#178)

This commit is contained in:
Lee *!* Clagett
2025-09-04 23:14:03 -04:00
committed by Lee *!* Clagett
parent 44278d0d11
commit a11482c123
5 changed files with 57 additions and 28 deletions

View File

@@ -2100,7 +2100,7 @@ namespace db
{
//! \return Success, even if `address` was not found (designed for
expect<void>
change_height(MDB_cursor& accounts_cur, MDB_cursor& accounts_ba_cur, MDB_cursor& accounts_bh_cur, block_id height, account_address const& address)
change_height(MDB_cursor& accounts_cur, MDB_cursor& accounts_ba_cur, MDB_cursor& accounts_bh_cur, MDB_cursor& outputs_cur, MDB_cursor& spends_cur, MDB_cursor& images_cur, block_id height, account_address const& address)
{
MDB_val key = lmdb::to_val(by_address_version);
MDB_val value = lmdb::to_val(address);
@@ -2146,6 +2146,9 @@ namespace db
mdb_cursor_put(&accounts_bh_cur, &key, &value, MDB_NODUPDATA)
);
MONERO_CHECK(rollback_outputs(user->id, height, outputs_cur));
MONERO_CHECK(rollback_spends(user->id, height, spends_cur, images_cur));
return success();
}
}
@@ -2180,15 +2183,21 @@ namespace db
cursor::accounts accounts_cur;
cursor::accounts_by_address accounts_ba_cur;
cursor::accounts_by_height accounts_bh_cur;
cursor::outputs outputs_cur;
cursor::spends spends_cur;
cursor::images images_cur;
MONERO_CHECK(check_cursor(txn, this->db->tables.accounts, accounts_cur));
MONERO_CHECK(check_cursor(txn, this->db->tables.accounts_ba, accounts_ba_cur));
MONERO_CHECK(check_cursor(txn, this->db->tables.accounts_bh, accounts_bh_cur));
MONERO_CHECK(check_cursor(txn, this->db->tables.outputs, outputs_cur));
MONERO_CHECK(check_cursor(txn, this->db->tables.spends, spends_cur));
MONERO_CHECK(check_cursor(txn, this->db->tables.images, images_cur));
for (account_address const& address : addresses)
{
const expect<void> changed = change_height(
*accounts_cur, *accounts_ba_cur, *accounts_bh_cur, height, address
*accounts_cur, *accounts_ba_cur, *accounts_bh_cur, *outputs_cur, *spends_cur, *images_cur, height, address
);
if (changed)
updated.push_back(address);
@@ -2421,11 +2430,17 @@ namespace db
cursor::accounts accounts_ba_cur;
cursor::accounts accounts_bh_cur;
cursor::requests requests_cur;
cursor::outputs outputs_cur;
cursor::spends spends_cur;
cursor::images images_cur;
MONERO_CHECK(check_cursor(txn, tables.accounts, accounts_cur));
MONERO_CHECK(check_cursor(txn, tables.accounts_ba, accounts_ba_cur));
MONERO_CHECK(check_cursor(txn, tables.accounts_bh, accounts_bh_cur));
MONERO_CHECK(check_cursor(txn, tables.requests, requests_cur));
MONERO_CHECK(check_cursor(txn, tables.outputs, outputs_cur));
MONERO_CHECK(check_cursor(txn, tables.spends, spends_cur));
MONERO_CHECK(check_cursor(txn, tables.images, images_cur));
const request req = request::import_scan;
for (account_address const& address : addresses)
@@ -2445,7 +2460,7 @@ namespace db
return new_height.error();
const expect<void> changed = change_height(
*accounts_cur, *accounts_ba_cur, *accounts_bh_cur, *new_height, address
*accounts_cur, *accounts_ba_cur, *accounts_bh_cur, *outputs_cur, *spends_cur, *images_cur, *new_height, address
);
if (changed)
updated.push_back(address);