Skip to content

Commit

Permalink
notify off main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Apr 12, 2021
1 parent c83ab74 commit f5f2fb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/wallet/monero_wallet_full.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,11 @@ namespace monero {

void on_spend_txs(const std::vector<std::shared_ptr<monero_tx_wallet>>& txs) {
if (m_wallet.get_listeners().empty()) return;
check_for_changed_balances();
for (const std::shared_ptr<monero_tx_wallet>& tx : txs) notify_outputs(tx);
tools::threadpool::waiter waiter(*m_notification_pool);
m_notification_pool->submit(&waiter, [this, txs]() {
check_for_changed_balances();
for (const std::shared_ptr<monero_tx_wallet>& tx : txs) notify_outputs(tx);
});
}

private:
Expand Down Expand Up @@ -955,7 +958,7 @@ namespace monero {
// notify spent outputs // TODO: this provides one input with outgoing amount like monero-wallet-rpc client, use real inputs instead
if (tx->m_outgoing_transfer != boost::none) {
std::shared_ptr<monero_output_wallet> output = std::make_shared<monero_output_wallet>();
tx->m_inputs.push_back(output);
tx->m_inputs.push_back(output); // TODO: should copy tx and block before modifying
output->m_tx = tx;
output->m_amount = tx->m_outgoing_transfer.get()->m_amount.get() + tx->m_fee.get();
output->m_account_index = tx->m_outgoing_transfer.get()->m_account_index;
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/monero_wallet_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ namespace monero {
}
}
if (src->m_outgoing_transfer != boost::none) {
std::shared_ptr<monero_outgoing_transfer> transferCopy = src->m_outgoing_transfer.get()->copy(src->m_outgoing_transfer.get(), std::make_shared<monero_outgoing_transfer>());
transferCopy->m_tx = tgt;
tgt->m_outgoing_transfer = transferCopy;
std::shared_ptr<monero_outgoing_transfer> transfer_copy = src->m_outgoing_transfer.get()->copy(src->m_outgoing_transfer.get(), std::make_shared<monero_outgoing_transfer>());
transfer_copy->m_tx = tgt;
tgt->m_outgoing_transfer = transfer_copy;
}
tgt->m_note = src->m_note;
tgt->m_is_locked = src->m_is_locked;
Expand Down

0 comments on commit f5f2fb0

Please sign in to comment.