diff --git a/rai/core_test/network.cpp b/rai/core_test/network.cpp index 4da0c652..d0f29400 100644 --- a/rai/core_test/network.cpp +++ b/rai/core_test/network.cpp @@ -614,6 +614,9 @@ TEST (bootstrap_processor, push_diamond) rai::node_init init1; auto node1 (std::make_shared (init1, system.service, 24002, rai::unique_path (), system.alarm, system.logging, system.work)); ASSERT_FALSE (init1.error ()); + auto wallet1 (node1->wallets.create (100)); + wallet1->insert_adhoc (rai::test_genesis_key.prv); + wallet1->insert_adhoc (key.prv); std::unique_ptr send1 (new rai::send_block (system.nodes [0]->latest (rai::test_genesis_key.pub), key.pub, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (system.nodes [0]->latest (rai::test_genesis_key.pub)))); ASSERT_EQ (rai::process_result::progress, node1->process (*send1).code); std::unique_ptr open (new rai::open_block (send1->hash (), 1, key.pub, key.prv, key.pub, system.work.generate (key.pub))); diff --git a/rai/node/bootstrap.cpp b/rai/node/bootstrap.cpp index 515328c8..db07f48a 100755 --- a/rai/node/bootstrap.cpp +++ b/rai/node/bootstrap.cpp @@ -302,9 +302,12 @@ void rai::frontier_req_client::received_frontier (boost::system::error_code cons { while (!current.is_zero () && current < account) { - rai::transaction transaction (connection->node->store.environment, nullptr, true); // We know about an account they don't. - unsynced (transaction, info.head, 0); + rai::transaction transaction (connection->node->store.environment, nullptr, true); + if (connection->node->wallets.exists (transaction, current)) + { + unsynced (transaction, info.head, 0); + } next (); } if (!current.is_zero ()) @@ -321,7 +324,10 @@ void rai::frontier_req_client::received_frontier (boost::system::error_code cons if (connection->node->store.block_exists (transaction, latest)) { // We know about a block they don't. - unsynced (transaction, info.head, latest); + if (connection->node->wallets.exists (transaction, current)) + { + unsynced (transaction, info.head, latest); + } } else { @@ -350,7 +356,10 @@ void rai::frontier_req_client::received_frontier (boost::system::error_code cons while (!current.is_zero ()) { // We know about an account they don't. - unsynced (transaction, info.head, 0); + if (connection->node->wallets.exists (transaction, current)) + { + unsynced (transaction, info.head, 0); + } next (); } } diff --git a/rai/node/wallet.cpp b/rai/node/wallet.cpp index 658a2e17..4801e158 100644 --- a/rai/node/wallet.cpp +++ b/rai/node/wallet.cpp @@ -1499,6 +1499,16 @@ void rai::wallets::foreach_representative (MDB_txn * transaction_a, std::functio } } +bool rai::wallets::exists (MDB_txn * transaction_a, rai::public_key const & account_a) +{ + auto result (false); + for (auto i (items.begin ()), n (items.end ()); !result && i != n; ++i) + { + result = i->second->store.exists (transaction_a, account_a); + } + return result; +} + rai::uint128_t const rai::wallets::generate_priority = std::numeric_limits ::max (); rai::uint128_t const rai::wallets::high_priority = std::numeric_limits ::max () - 1; diff --git a/rai/node/wallet.hpp b/rai/node/wallet.hpp index 51ff0456..09814602 100644 --- a/rai/node/wallet.hpp +++ b/rai/node/wallet.hpp @@ -190,6 +190,7 @@ public: void do_wallet_actions (rai::account const &); void queue_wallet_action (rai::account const &, rai::uint128_t const &, std::function const &); void foreach_representative (MDB_txn *, std::function const &); + bool exists (MDB_txn *, rai::public_key const &); std::function observer; std::unordered_map > items; std::unordered_map , std::greater >> pending_actions;