From ab831e23bc8aaf9690df598004bbf29ee142e1ea Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 11 Jan 2021 09:29:57 -0500 Subject: [PATCH] fix occasional RangeError caused by merging when outputs confirmed --- src/daemon/monero_daemon_model.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/daemon/monero_daemon_model.cpp b/src/daemon/monero_daemon_model.cpp index 68e9118..987fc41 100644 --- a/src/daemon/monero_daemon_model.cpp +++ b/src/daemon/monero_daemon_model.cpp @@ -404,20 +404,15 @@ namespace monero { if (this != self.get()) throw std::runtime_error("this != self"); if (self == other) return; - // merge blocks if they're different which comes back to merging txs + // merge blocks if they're different if (m_block != other->m_block) { if (m_block == boost::none) { - m_block = std::make_shared(); - m_block.get()->m_txs.push_back(self); - m_block.get()->m_height = other->get_height(); + m_block = other->m_block; + std::replace(m_block.get()->m_txs.begin(), m_block.get()->m_txs.end(), other, self); // update block to point to this tx + } else if (other->m_block == boost::none) { + m_block.get()->merge(m_block.get(), other->m_block.get()); // comes back to merging txs + return; } - if (other->m_block == boost::none) { - other->m_block = std::make_shared(); - other->m_block.get()->m_txs.push_back(other); - other->m_block.get()->m_height = self->get_height(); - } - m_block.get()->merge(m_block.get(), other->m_block.get()); - return; } // otherwise merge tx fields