notify off main thread

This commit is contained in:
woodser
2021-04-12 15:43:28 -04:00
parent c83ab742bf
commit f5f2fb0f9b
2 changed files with 9 additions and 6 deletions
+6 -3
View File
@@ -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:
@@ -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;
+3 -3
View File
@@ -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;