diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-08-12 21:45:10 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-09-09 12:02:32 +0000 |
commit | 2b2a681b017683153ed747f693b21f67049a2b27 (patch) | |
tree | f1fe2b90ba70883e5126d7f0202ae86d39c68fe8 /src/blockchain_utilities/blockchain_blackball.cpp | |
parent | blockchain_blackball: set transaction looping txn to read only (diff) | |
download | monero-2b2a681b017683153ed747f693b21f67049a2b27.tar.xz |
blockchain_blackball: avoid false positives for different amounts
Identical offset based rings may not actually be identical rings
since they represent different outputs
Diffstat (limited to 'src/blockchain_utilities/blockchain_blackball.cpp')
-rw-r--r-- | src/blockchain_utilities/blockchain_blackball.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/blockchain_utilities/blockchain_blackball.cpp b/src/blockchain_utilities/blockchain_blackball.cpp index 833a19a0b..42e04f195 100644 --- a/src/blockchain_utilities/blockchain_blackball.cpp +++ b/src/blockchain_utilities/blockchain_blackball.cpp @@ -298,14 +298,18 @@ static void close() } } -static std::string compress_ring(const std::vector<uint64_t> &ring) +static std::string compress_ring(const std::vector<uint64_t> &ring, std::string s = "") { - std::string s; for (uint64_t out: ring) s += tools::get_varint_data(out); return s; } +static std::string compress_ring(uint64_t amount, const std::vector<uint64_t> &ring) +{ + return compress_ring(ring, tools::get_varint_data(amount)); +} + static std::vector<uint64_t> decompress_ring(const std::string &s) { std::vector<uint64_t> ring; @@ -583,9 +587,9 @@ static std::string keep_under_511(const std::string &s) return std::string((const char*)&hash, 32); } -static uint64_t get_ring_instances(MDB_txn *txn, const std::vector<uint64_t> &ring) +static uint64_t get_ring_instances(MDB_txn *txn, uint64_t amount, const std::vector<uint64_t> &ring) { - const std::string sring = keep_under_511(compress_ring(ring)); + const std::string sring = keep_under_511(compress_ring(amount, ring)); MDB_val k, v; k.mv_data = (void*)sring.data(); k.mv_size = sring.size(); @@ -596,9 +600,9 @@ static uint64_t get_ring_instances(MDB_txn *txn, const std::vector<uint64_t> &ri return *(const uint64_t*)v.mv_data; } -static void set_ring_instances(MDB_txn *txn, const std::vector<uint64_t> &ring, uint64_t count) +static void set_ring_instances(MDB_txn *txn, uint64_t amount, const std::vector<uint64_t> &ring, uint64_t count) { - const std::string sring = keep_under_511(compress_ring(ring)); + const std::string sring = keep_under_511(compress_ring(amount, ring)); MDB_val k, v; k.mv_data = (void*)sring.data(); k.mv_size = sring.size(); @@ -945,9 +949,9 @@ int main(int argc, char* argv[]) std::vector<uint64_t> relative_ring; std::vector<uint64_t> new_ring = canonicalize(txin.key_offsets); const uint32_t ring_size = txin.key_offsets.size(); - uint64_t instances = get_ring_instances(txn, new_ring); + uint64_t instances = get_ring_instances(txn, txin.amount, new_ring); ++instances; - set_ring_instances(txn, new_ring, instances); + set_ring_instances(txn, txin.amount, new_ring, instances); if (n == 0 && ring_size == 1) { const crypto::public_key pkey = get_output_key(cur0, txin.amount, absolute[0]); |