Removing private keys from lambda capture.
This commit is contained in:
parent
e2bfd293d7
commit
4bfa4d6fe4
3 changed files with 42 additions and 47 deletions
|
|
@ -1857,43 +1857,31 @@ public:
|
|||
auto wallet (i->second);
|
||||
if (wallet->exists (block_a.hashables.destination))
|
||||
{
|
||||
rai::private_key prv;
|
||||
rai::account representative;
|
||||
rai::receivable receivable;
|
||||
rai::transaction transaction (node.store.environment, nullptr, false);
|
||||
auto error (false);
|
||||
{
|
||||
error = wallet->store.fetch (transaction, block_a.hashables.destination, prv);
|
||||
representative = wallet->store.representative (transaction);
|
||||
}
|
||||
representative = wallet->store.representative (transaction);
|
||||
auto error (node.store.pending_get (transaction, block_a.hash (), receivable));
|
||||
if (!error)
|
||||
{
|
||||
error = error | node.store.pending_get (transaction, block_a.hash (), receivable);
|
||||
if (!error)
|
||||
auto block_l (std::shared_ptr <rai::send_block> (static_cast <rai::send_block *> (block_a.clone ().release ())));
|
||||
auto node_l (node.shared ());
|
||||
auto amount (receivable.amount.number ());
|
||||
node.service.add (std::chrono::system_clock::now (), [block_l, representative, wallet, node_l, amount] ()
|
||||
{
|
||||
auto block_l (std::shared_ptr <rai::send_block> (static_cast <rai::send_block *> (block_a.clone ().release ())));
|
||||
auto node_l (node.shared ());
|
||||
auto amount (receivable.amount.number ());
|
||||
node.service.add (std::chrono::system_clock::now (), [block_l, prv, representative, wallet, node_l, amount] ()
|
||||
node_l->wallets.queue_wallet_action (block_l->hashables.destination, amount, [block_l, representative, wallet, amount] ()
|
||||
{
|
||||
node_l->wallets.queue_wallet_action (block_l->hashables.destination, amount, [block_l, prv, representative, wallet, amount] ()
|
||||
{
|
||||
auto error (wallet->receive_action (*block_l, prv, representative, amount));
|
||||
(void)error; // Might be interesting to view during debug
|
||||
});
|
||||
auto error (wallet->receive_action (*block_l, representative, amount));
|
||||
(void)error; // Might be interesting to view during debug
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (node.config.logging.ledger_duplicate_logging ())
|
||||
{
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("Block confirmed before timeout %1%") % block_a.hash ().to_string ());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("While confirming %1%, unable to fetch wallet key") % block_a.hash ().to_string ());
|
||||
if (node.config.logging.ledger_duplicate_logging ())
|
||||
{
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("Block confirmed before timeout %1%") % block_a.hash ().to_string ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -649,7 +649,7 @@ bool check_ownership (rai::wallets & wallets_a, rai::account const & account_a)
|
|||
}
|
||||
}
|
||||
|
||||
bool rai::wallet::receive_action (rai::send_block const & send_a, rai::private_key const & prv_a, rai::account const & representative_a, rai::uint128_union const & amount_a)
|
||||
bool rai::wallet::receive_action (rai::send_block const & send_a, rai::account const & representative_a, rai::uint128_union const & amount_a)
|
||||
{
|
||||
assert (!check_ownership (node.wallets, send_a.hashables.destination));
|
||||
auto hash (send_a.hash ());
|
||||
|
|
@ -660,18 +660,28 @@ bool rai::wallet::receive_action (rai::send_block const & send_a, rai::private_k
|
|||
rai::transaction transaction (node.ledger.store.environment, nullptr, false);
|
||||
if (node.ledger.store.pending_exists (transaction, hash))
|
||||
{
|
||||
rai::account_info info;
|
||||
auto new_account (node.ledger.store.account_get (transaction, send_a.hashables.destination, info));
|
||||
if (!new_account)
|
||||
rai::private_key prv;
|
||||
if (!store.fetch (transaction, send_a.hashables.destination, prv))
|
||||
{
|
||||
auto receive (new rai::receive_block (info.head, hash, prv_a, send_a.hashables.destination, work_fetch (transaction, send_a.hashables.destination, info.head)));
|
||||
block.reset (receive);
|
||||
rai::account_info info;
|
||||
auto new_account (node.ledger.store.account_get (transaction, send_a.hashables.destination, info));
|
||||
if (!new_account)
|
||||
{
|
||||
auto receive (new rai::receive_block (info.head, hash, prv, send_a.hashables.destination, work_fetch (transaction, send_a.hashables.destination, info.head)));
|
||||
block.reset (receive);
|
||||
}
|
||||
else
|
||||
{
|
||||
block.reset (new rai::open_block (hash, representative_a, send_a.hashables.destination, prv, send_a.hashables.destination, work_fetch (transaction, send_a.hashables.destination, send_a.hashables.destination)));
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
block.reset (new rai::open_block (hash, representative_a, send_a.hashables.destination, prv_a, send_a.hashables.destination, work_fetch (transaction, send_a.hashables.destination, send_a.hashables.destination)));
|
||||
result = true;
|
||||
BOOST_LOG (node.log) << "Unable to receive, wallet locked";
|
||||
}
|
||||
result = false;
|
||||
prv.clear ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -806,14 +816,14 @@ bool rai::wallet::change_sync (rai::account const & source_a, rai::account const
|
|||
return result;
|
||||
}
|
||||
|
||||
bool rai::wallet::receive_sync (rai::send_block const & block_a, rai::private_key const & prv_a, rai::account const & account_a, rai::uint128_t const & amount_a)
|
||||
bool rai::wallet::receive_sync (rai::send_block const & block_a, rai::account const & account_a, rai::uint128_t const & amount_a)
|
||||
{
|
||||
std::mutex complete;
|
||||
complete.lock ();
|
||||
bool result;
|
||||
node.wallets.queue_wallet_action (block_a.hashables.destination, amount_a, [this, &block_a, &prv_a, account_a, &result, &complete, amount_a] ()
|
||||
node.wallets.queue_wallet_action (block_a.hashables.destination, amount_a, [this, &block_a, account_a, &result, &complete, amount_a] ()
|
||||
{
|
||||
result = receive_action (block_a, prv_a, account_a, amount_a);
|
||||
result = receive_action (block_a, account_a, amount_a);
|
||||
complete.unlock ();
|
||||
});
|
||||
complete.lock ();
|
||||
|
|
@ -923,23 +933,21 @@ public:
|
|||
rai::receivable receivable (i->second);
|
||||
if (receivable.source == account_a)
|
||||
{
|
||||
if (wallet->store.exists(transaction, receivable.destination))
|
||||
if (wallet->store.exists (transaction, receivable.destination))
|
||||
{
|
||||
rai::private_key prv;
|
||||
auto error (wallet->store.fetch (transaction, receivable.destination, prv));
|
||||
if (!error)
|
||||
if (wallet->store.valid_password (transaction))
|
||||
{
|
||||
auto block_l (wallet->node.store.block_get (transaction, i->first));
|
||||
assert (dynamic_cast <rai::send_block *> (block_l.get ()) != nullptr);
|
||||
std::shared_ptr <rai::send_block> block (static_cast <rai::send_block *> (block_l.release ()));
|
||||
auto wallet_l (wallet);
|
||||
auto amount (receivable.amount.number ());
|
||||
wallet->node.background ([wallet_l, block, representative, prv, amount]
|
||||
wallet->node.background ([wallet_l, block, representative, amount]
|
||||
{
|
||||
wallet_l->node.wallets.queue_wallet_action (block->hashables.destination, amount, [wallet_l, block, representative, prv, amount] ()
|
||||
wallet_l->node.wallets.queue_wallet_action (block->hashables.destination, amount, [wallet_l, block, representative, amount] ()
|
||||
{
|
||||
BOOST_LOG (wallet_l->node.log) << boost::str (boost::format ("Receiving block: %1%") % block->hash ().to_string ());
|
||||
auto error (wallet_l->receive_action (*block, prv, representative, amount));
|
||||
auto error (wallet_l->receive_action (*block, representative, amount));
|
||||
if (error)
|
||||
{
|
||||
BOOST_LOG (wallet_l->node.log) << boost::str (boost::format ("Error receiving block %1%") % block->hash ().to_string ());
|
||||
|
|
@ -951,7 +959,6 @@ public:
|
|||
{
|
||||
BOOST_LOG (wallet->node.log) << boost::str (boost::format ("Unable to fetch key for: %1%, stopping pending search") % receivable.destination.to_base58check ());
|
||||
}
|
||||
prv.clear ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,10 +126,10 @@ public:
|
|||
bool import (std::string const &, std::string const &);
|
||||
void serialize (std::string &);
|
||||
bool change_action (rai::account const &, rai::account const &);
|
||||
bool receive_action (rai::send_block const &, rai::private_key const &, rai::account const &, rai::uint128_union const &);
|
||||
bool receive_action (rai::send_block const &, rai::account const &, rai::uint128_union const &);
|
||||
rai::block_hash send_action (rai::account const &, rai::account const &, rai::uint128_t const &);
|
||||
bool change_sync (rai::account const &, rai::account const &);
|
||||
bool receive_sync (rai::send_block const &, rai::private_key const &, rai::account const &, rai::uint128_t const &);
|
||||
bool receive_sync (rai::send_block const &, rai::account const &, rai::uint128_t const &);
|
||||
rai::block_hash send_sync (rai::account const &, rai::account const &, rai::uint128_t const &);
|
||||
void work_generate (rai::account const &, rai::block_hash const &);
|
||||
void work_update (MDB_txn *, rai::account const &, rai::block_hash const &, uint64_t);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue