From 3757513f622b52ddc42c9445aedbca0faa198e3a Mon Sep 17 00:00:00 2001 From: woodser Date: Tue, 11 Jun 2019 13:13:02 -0400 Subject: [PATCH] compiling with mergeTx() impl less merge() calls --- src/wallet/MoneroWallet.cpp | 56 ++++--------------------------------- 1 file changed, 5 insertions(+), 51 deletions(-) diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index e83c222..f14f875 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -209,16 +209,16 @@ namespace monero { (*tx->block)->txs = txs; (*tx->block)->height = *aTx->getHeight(); } - aTx->block->merge(tx->block); + //aTx->block->merge(tx->block); } else { - aTx->merge(*tx); + //aTx->merge(*tx); } return; } // merge common block of different txs - if (tx->getHeight() != boost::none && *tx->getHeight() == *aTx->getHeight()) - (*aTx-block)->merge(*tx->block); + if (tx->getHeight() != boost::none && *tx->getHeight() == *aTx->getHeight()) { + //(*aTx-block)->merge(*tx->block); //if (aTx.getIsConfirmed()) assertTrue(aTx.getBlock().getTxs().contains(aTx)); } } @@ -231,52 +231,6 @@ namespace monero { } } - /** - * Merges a transaction into a unique set of transactions. - * - * TODO monero-wallet-rpc: skipIfAbsent only necessary because incoming payments not returned - * when sent from/to same account - * - * @param txs are existing transactions to merge into - * @param tx is the transaction to merge into the existing txs - * @param skipIfAbsent specifies if the tx should not be added - * if it doesn't already exist. Only necessasry to handle - * missing incoming payments from #4500. // TODO - * @returns the merged tx - */ - private static void mergeTx(List txs, MoneroTxWallet tx, boolean skipIfAbsent) { - assertNotNull(tx.getId()); - for (MoneroTxWallet aTx : txs) { - - // merge tx - if (aTx.getId().equals(tx.getId())) { - - // merge blocks which only exist when confirmed - if (aTx.getBlock() != null || tx.getBlock() != null) { - if (aTx.getBlock() == null) aTx.setBlock(new MoneroBlock().setTxs(new ArrayList(Arrays.asList(aTx))).setHeight(tx.getHeight())); - if (tx.getBlock() == null) tx.setBlock(new MoneroBlock().setTxs(new ArrayList(Arrays.asList(tx))).setHeight(aTx.getHeight())); - aTx.getBlock().merge(tx.getBlock()); - } else { - aTx.merge(tx); - } - return; - } - - // merge common block of different txs - if (tx.getHeight() != null && tx.getHeight().equals(aTx.getHeight())) { - aTx.getBlock().merge(tx.getBlock()); - if (aTx.getIsConfirmed()) assertTrue(aTx.getBlock().getTxs().contains(aTx)); - } - } - - // add tx if it doesn't already exist unless skipped - if (!skipIfAbsent) { - txs.add(tx); - } else { - LOGGER.warn("WARNING: tx does not already exist"); - } - } - // ----------------------------- WALLET LISTENER ---------------------------- /** @@ -727,7 +681,7 @@ namespace monero { wallet2->get_payments(payments, minHeight, maxHeight, accountIndex, subaddressIndices); for (std::list>::const_iterator i = payments.begin(); i != payments.end(); ++i) { shared_ptr tx = buildTxWithIncomingTransfer(i->second.m_tx_hash, i->first, i->second); - mergeTx(txs, tx); // TODO + mergeTx(txs, tx, false); //txs.push_back(tx); } }