diff --git a/src/daemon/MoneroDaemonModel.cpp b/src/daemon/MoneroDaemonModel.cpp index 63ff457..7a029e3 100644 --- a/src/daemon/MoneroDaemonModel.cpp +++ b/src/daemon/MoneroDaemonModel.cpp @@ -152,7 +152,7 @@ namespace monero { if (this != self.get()) throw runtime_error("this != self"); if (self == other) return; - // merge base classes + // merge header fields MoneroBlockHeader::merge(self, other); // merge reconcilable block extensions @@ -161,9 +161,9 @@ namespace monero { // merge coinbase tx if (coinbaseTx == boost::none) coinbaseTx = other->coinbaseTx; - else if (other->coinbaseTx != boost::none) { + if (other->coinbaseTx != boost::none) { other->coinbaseTx.get()->block = self; - coinbaseTx.get()->merge(*coinbaseTx, *other->coinbaseTx); + coinbaseTx.get()->merge(coinbaseTx.get(), other->coinbaseTx.get()); } // merge non-coinbase txs @@ -385,6 +385,14 @@ namespace monero { void MoneroOutput::merge(const shared_ptr& self, const shared_ptr& other) { if (this != self.get()) throw runtime_error("this != self"); if (self == other) return; + + // merge txs if they're different which comes back to merging outputs + if (tx != other->tx) { + tx->merge(tx, other->tx); + return; + } + + // otherwise merge output fields if (keyImage == boost::none) keyImage = other->keyImage; else if (other->keyImage != boost::none) keyImage.get()->merge(keyImage.get(), other->keyImage.get()); amount = MoneroUtils::reconcile(amount, other->amount); diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index c4d0b70..c9a35d8 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -1329,7 +1329,7 @@ namespace monero { //cout << "4" << endl; - // collect unique txs + // cache unique txs and blocks uint64_t chainHeight = getChainHeight(); map> txMap; map> blockMap; @@ -1442,7 +1442,7 @@ namespace monero { tools::wallet2::transfer_container outputsW2; wallet2->get_transfers(outputsW2); - // collect unique txs and blocks + // cache unique txs and blocks map> txMap; map> blockMap; for (const auto& outputW2 : outputsW2) { @@ -1466,7 +1466,7 @@ namespace monero { } } - // remove txs without requested transfer + // remove txs without requested vout if (tx->vouts.empty() && tx->block != boost::none) tx->block.get()->txs.erase(std::remove(tx->block.get()->txs.begin(), tx->block.get()->txs.end(), tx), tx->block.get()->txs.end()); // TODO, no way to use const_iterator? } return vouts; diff --git a/src/wallet/MoneroWalletModel.cpp b/src/wallet/MoneroWalletModel.cpp index 5ca84d9..bee8ace 100644 --- a/src/wallet/MoneroWalletModel.cpp +++ b/src/wallet/MoneroWalletModel.cpp @@ -156,18 +156,6 @@ namespace monero { } } - //boost::property_tree::ptree MoneroUtils::txWalletToPropertyTree(const MoneroTxWallet& tx) { - // cout << "txWalletToPropertyTree(tx)" << endl; - // boost::property_tree::ptree txNode = txToPropertyTree(tx); - // if (!tx.vouts.empty()) throw runtime_error("not implemented"); - // if (!tx.incomingTransfers.empty()) throw runtime_error("not implemented"); - // if (tx.outgoingTransfer != boost::none) throw runtime_error("not implemented"); - // if (tx.numSuggestedConfirmations != boost::none) txNode.put("numSuggestedConfirmations", *tx.numSuggestedConfirmations); - // if (tx.note != boost::none) txNode.put("note", *tx.note); - // return txNode; - //} - // - // -------------------------- MONERO TX REQUEST ----------------------------- boost::property_tree::ptree MoneroTxRequest::toPropertyTree() const {