mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
blockchain_prune_known_spent_data: blackball file is now optional
If not present, the tool will scan the blockchain, since scanning for this is fairly fast.
This commit is contained in:
parent
17b45725af
commit
a48f2dab00
@ -175,11 +175,6 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::string input = command_line::get_arg(vm, arg_input);
|
const std::string input = command_line::get_arg(vm, arg_input);
|
||||||
if (input.empty())
|
|
||||||
{
|
|
||||||
LOG_PRINT_L0("No input given");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)");
|
LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)");
|
||||||
std::unique_ptr<Blockchain> core_storage;
|
std::unique_ptr<Blockchain> core_storage;
|
||||||
@ -210,8 +205,50 @@ int main(int argc, char* argv[])
|
|||||||
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize source blockchain storage");
|
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize source blockchain storage");
|
||||||
LOG_PRINT_L0("Source blockchain storage initialized OK");
|
LOG_PRINT_L0("Source blockchain storage initialized OK");
|
||||||
|
|
||||||
LOG_PRINT_L0("Loading known spent data...");
|
std::map<uint64_t, uint64_t> known_spent_outputs;
|
||||||
const std::map<uint64_t, uint64_t> known_spent_outputs = load_outputs(input);
|
if (input.empty())
|
||||||
|
{
|
||||||
|
std::map<uint64_t, std::pair<uint64_t, uint64_t>> outputs;
|
||||||
|
|
||||||
|
LOG_PRINT_L0("Scanning for known spent data...");
|
||||||
|
db->for_all_transactions([&](const crypto::hash &txid, const cryptonote::transaction &tx){
|
||||||
|
const bool miner_tx = tx.vin.size() == 1 && tx.vin[0].type() == typeid(txin_gen);
|
||||||
|
for (const auto &in: tx.vin)
|
||||||
|
{
|
||||||
|
if (in.type() != typeid(txin_to_key))
|
||||||
|
continue;
|
||||||
|
const auto &txin = boost::get<txin_to_key>(in);
|
||||||
|
if (txin.amount == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
outputs[txin.amount].second++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &out: tx.vout)
|
||||||
|
{
|
||||||
|
uint64_t amount = out.amount;
|
||||||
|
if (miner_tx && tx.version >= 2)
|
||||||
|
amount = 0;
|
||||||
|
if (amount == 0)
|
||||||
|
continue;
|
||||||
|
if (out.target.type() != typeid(txout_to_key))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
outputs[amount].first++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
for (const auto &i: outputs)
|
||||||
|
{
|
||||||
|
known_spent_outputs[i.first] = i.second.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_PRINT_L0("Loading known spent data...");
|
||||||
|
known_spent_outputs = load_outputs(input);
|
||||||
|
}
|
||||||
|
|
||||||
LOG_PRINT_L0("Pruning known spent data...");
|
LOG_PRINT_L0("Pruning known spent data...");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user