Fix spend tracking bug in db::storage (#89)

This commit is contained in:
Lee *!* Clagett 2023-12-03 15:47:04 -05:00 committed by Lee *!* Clagett
parent 9446758fdb
commit 9f98d2a8c9
2 changed files with 8 additions and 2 deletions

View file

@ -217,8 +217,8 @@ namespace db
{
transaction_link link; //!< Orders and links `spend` to `output`.
crypto::key_image image; //!< Unique ID for the spend
// `link` and `image` must in this order for LMDB optimizations
output_id source; //!< The output being spent
// `link`, `image`, and `source` must in this order for LMDB optimizations
std::uint64_t timestamp; //!< Timestamp of spend
std::uint64_t unlock_time;//!< Unlock time of spend
std::uint32_t mixin_count;//!< Ring-size of TX output

View file

@ -219,7 +219,13 @@ namespace db
right_bytes.remove_prefix(sizeof(crypto::hash));
static_assert(sizeof(crypto::key_image) == 32, "bad memcmp below");
return compare_32bytes(left_bytes, right_bytes);
diff = compare_32bytes(left_bytes, right_bytes);
if (diff)
return diff;
left_bytes.remove_prefix(sizeof(crypto::key_image));
right_bytes.remove_prefix(sizeof(crypto::key_image));
return less<output_id>(left_bytes, right_bytes);
}
constexpr const lmdb::basic_table<unsigned, block_info> blocks{