Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --clear_send_ids CLI option #1163

Merged
merged 1 commit into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions rai/node/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void rai::add_node_options (boost::program_options::options_description & descri
("unchecked_clear", "Clear unchecked blocks")
("data_path", boost::program_options::value<std::string> (), "Use the supplied path as the data directory")
("delete_node_id", "Delete the node ID in the database")
("clear_send_ids", "Remove all send IDs from the database (dangerous: not intended for production use)")
("diagnostics", "Run internal diagnostics")
("key_create", "Generates a adhoc random keypair and prints it to stdout")
("key_expand", "Derive public key and account number from <key>")
Expand Down Expand Up @@ -159,6 +160,11 @@ std::error_code rai::handle_node_options (boost::program_options::variables_map
auto transaction (node.node->store.tx_begin_write ());
node.node->store.delete_node_id (transaction);
}
if (vm.count ("clear_send_ids"))
{
auto transaction (node.node->store.tx_begin_write ());
node.node->wallets.clear_send_ids (transaction);
}
success = node.node->copy_with_compaction (vacuum_path);
}

Expand Down Expand Up @@ -206,6 +212,11 @@ std::error_code rai::handle_node_options (boost::program_options::variables_map
auto transaction (node.node->store.tx_begin_write ());
node.node->store.delete_node_id (transaction);
}
if (vm.count ("clear_send_ids"))
{
auto transaction (node.node->store.tx_begin_write ());
node.node->wallets.clear_send_ids (transaction);
}
success = node.node->copy_with_compaction (snapshot_path);
}
if (success)
Expand Down Expand Up @@ -238,6 +249,14 @@ std::error_code rai::handle_node_options (boost::program_options::variables_map
node.node->store.delete_node_id (transaction);
std::cerr << "Deleted Node ID" << std::endl;
}
else if (vm.count ("clear_send_ids"))
{
boost::filesystem::path data_path = vm.count ("data_path") ? boost::filesystem::path (vm["data_path"].as<std::string> ()) : rai::working_path ();
inactive_node node (data_path);
auto transaction (node.node->store.tx_begin_write ());
node.node->wallets.clear_send_ids (transaction);
std::cerr << "Send IDs deleted" << std::endl;
}
else if (vm.count ("diagnostics"))
{
inactive_node node (data_path);
Expand Down
6 changes: 6 additions & 0 deletions rai/node/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,12 @@ rai::transaction rai::wallets::tx_begin (bool write_a)
return env.tx_begin (write_a);
}

void rai::wallets::clear_send_ids (rai::transaction const & transaction_a)
{
auto status (mdb_drop (env.tx (transaction_a), send_action_ids, 0));
assert (status == 0);
}

rai::uint128_t const rai::wallets::generate_priority = std::numeric_limits<rai::uint128_t>::max ();
rai::uint128_t const rai::wallets::high_priority = std::numeric_limits<rai::uint128_t>::max () - 1;

Expand Down
1 change: 1 addition & 0 deletions rai/node/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class wallets
void foreach_representative (rai::transaction const &, std::function<void(rai::public_key const &, rai::raw_key const &)> const &);
bool exists (rai::transaction const &, rai::public_key const &);
void stop ();
void clear_send_ids (rai::transaction const &);
std::function<void(bool)> observer;
std::unordered_map<rai::uint256_union, std::shared_ptr<rai::wallet>> items;
std::multimap<rai::uint128_t, std::function<void()>, std::greater<rai::uint128_t>> actions;
Expand Down