mirror of
https://codeberg.org/wownero/wownero-lws
synced 2026-01-09 23:25:16 -08:00
Fix rescan to invalid blockchain height bug (#48)
This commit is contained in:
committed by
Lee *!* Clagett
parent
aff7603519
commit
64f5d4a9ab
@@ -1352,6 +1352,24 @@ namespace db
|
||||
MONERO_PRECOND(db != nullptr);
|
||||
return db->try_write([this, height, addresses] (MDB_txn& txn) -> expect<std::vector<account_address>>
|
||||
{
|
||||
{
|
||||
cursor::blocks blocks_cur;
|
||||
MONERO_CHECK(check_cursor(txn, this->db->tables.blocks, blocks_cur));
|
||||
|
||||
MDB_val key = lmdb::to_val(blocks_version);
|
||||
MDB_val value{};
|
||||
|
||||
MONERO_LMDB_CHECK(mdb_cursor_get(blocks_cur.get(), &key, &value, MDB_SET));
|
||||
MONERO_LMDB_CHECK(mdb_cursor_get(blocks_cur.get(), &key, &value, MDB_LAST_DUP));
|
||||
|
||||
const expect<block_id> current_height =
|
||||
blocks.get_value<MONERO_FIELD(block_info, id)>(value);
|
||||
if (!current_height)
|
||||
return current_height.error();
|
||||
if (*current_height < height)
|
||||
return {error::bad_height};
|
||||
}
|
||||
|
||||
std::vector<account_address> updated{};
|
||||
updated.reserve(addresses.size());
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ namespace lws
|
||||
return "Received invalid transaction from REST client";
|
||||
case error::bad_daemon_response:
|
||||
return "Response from monerod daemon was bad/unexpected";
|
||||
case error::bad_height:
|
||||
return "Invalid blockchain height";
|
||||
case error::blockchain_reorg:
|
||||
return "A blockchain reorg has been detected";
|
||||
case error::configuration:
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace lws
|
||||
bad_blockchain, //!< Blockchain is invalid or wrong network type
|
||||
bad_client_tx, //!< REST client submitted invalid transaction
|
||||
bad_daemon_response, //!< RPC Response from daemon was invalid
|
||||
bad_height, //!< Invalid blockchain height
|
||||
blockchain_reorg, //!< Blockchain reorg after fetching/scanning block(s)
|
||||
configuration, //!< Process configuration invalid
|
||||
crypto_failure, //!< Cryptographic function failed
|
||||
|
||||
Reference in New Issue
Block a user