diff options
| author | Matt Corallo <[email protected]> | 2017-03-06 18:21:27 -0500 |
|---|---|---|
| committer | Matt Corallo <[email protected]> | 2017-04-07 11:53:43 +0200 |
| commit | b1a6d4cd560fbdb66506841860db03c08ea4bbbc (patch) | |
| tree | f43c849782eeff69536d2312ccead096621f20e2 /src/wallet/wallet.cpp | |
| parent | Use std::shared_ptr instead of boost::shared_ptr in ScriptForMining (diff) | |
| download | discoin-b1a6d4cd560fbdb66506841860db03c08ea4bbbc.tar.xz discoin-b1a6d4cd560fbdb66506841860db03c08ea4bbbc.zip | |
Take a CTransactionRef in AddToWalletIfInvolvingMe to avoid a copy
Diffstat (limited to 'src/wallet/wallet.cpp')
| -rw-r--r-- | src/wallet/wallet.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index dc145fd3d..1b92c5e74 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -966,8 +966,9 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn) * Abandoned state should probably be more carefully tracked via different * posInBlock signals or by checking mempool presence when necessary. */ -bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlockIndex* pIndex, int posInBlock, bool fUpdate) +bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const CBlockIndex* pIndex, int posInBlock, bool fUpdate) { + const CTransaction& tx = *ptx; { AssertLockHeld(cs_wallet); @@ -988,7 +989,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlockIndex if (fExisted && !fUpdate) return false; if (fExisted || IsMine(tx) || IsFromMe(tx)) { - CWalletTx wtx(this, MakeTransactionRef(tx)); + CWalletTx wtx(this, ptx); // Get merkle branch if transaction was found in a block if (posInBlock != -1) @@ -1119,7 +1120,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx) void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pindexBlockConnected, int posInBlock) { const CTransaction& tx = *ptx; - if (!AddToWalletIfInvolvingMe(tx, pindexBlockConnected, posInBlock, true)) + if (!AddToWalletIfInvolvingMe(ptx, pindexBlockConnected, posInBlock, true)) return; // Not one of ours // If a transaction changes 'conflicted' state, that changes the balance @@ -1542,7 +1543,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool f CBlock block; if (ReadBlockFromDisk(block, pindex, Params().GetConsensus())) { for (size_t posInBlock = 0; posInBlock < block.vtx.size(); ++posInBlock) { - AddToWalletIfInvolvingMe(*block.vtx[posInBlock], pindex, posInBlock, fUpdate); + AddToWalletIfInvolvingMe(block.vtx[posInBlock], pindex, posInBlock, fUpdate); } if (!ret) { ret = pindex; |