From 2425f27acd843b510136f780eb3600bd11e16f8b Mon Sep 17 00:00:00 2001 From: stoffu Date: Tue, 13 Aug 2019 15:25:53 +0900 Subject: [PATCH] blockchain_blackball: use is_output_spent instead of ringdb.blackballed for spentness test --- src/blockchain_utilities/blockchain_blackball.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/blockchain_utilities/blockchain_blackball.cpp b/src/blockchain_utilities/blockchain_blackball.cpp index 68fd9e14a..857e97afd 100644 --- a/src/blockchain_utilities/blockchain_blackball.cpp +++ b/src/blockchain_utilities/blockchain_blackball.cpp @@ -1317,6 +1317,13 @@ int main(int argc, char* argv[]) MINFO("Spent outputs database is empty. Either you haven't run the analysis mode yet, or there is really no output marked as spent."); goto skip_secondary_passes; } + MDB_txn *txn; + int dbr = mdb_txn_begin(env, NULL, 0, &txn); + CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr))); + MDB_cursor *cur; + dbr = mdb_cursor_open(txn, dbi_spent, &cur); + CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to open LMDB cursor: " + std::string(mdb_strerror(dbr))); + const uint64_t STAT_WINDOW = 10000; uint64_t outs_total = 0; uint64_t outs_spent = 0; @@ -1342,7 +1349,7 @@ int main(int argc, char* argv[]) ++outs_total; CHECK_AND_ASSERT_THROW_MES(out.target.type() == typeid(txout_to_key), "Out target type is not txout_to_key: height=" + std::to_string(height)); uint64_t out_global_index = outs_per_amount[out.amount]++; - if (ringdb.blackballed({out.amount, out_global_index})) + if (is_output_spent(cur, output_data(out.amount, out_global_index))) ++outs_spent; } if (last_tx) @@ -1358,6 +1365,9 @@ int main(int argc, char* argv[]) } return true; }); + mdb_cursor_close(cur); + dbr = mdb_txn_commit(txn); + CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to commit txn creating/opening database: " + std::string(mdb_strerror(dbr))); goto skip_secondary_passes; }