Skip to content

Commit

Permalink
Take a CTransactionRef in AddToWalletIfInvolvingMe to avoid a copy
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt authored and furszy committed Jan 28, 2021
1 parent d77244c commit b799070
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/wallet/wallet.cpp
Expand Up @@ -1060,8 +1060,9 @@ void CWallet::AddExternalNotesDataToTx(CWalletTx& wtx) const
* 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 uint256& blockHash, int posInBlock, bool fUpdate)
bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const uint256& blockHash, int posInBlock, bool fUpdate)
{
const CTransaction& tx = *ptx;
{
AssertLockHeld(cs_wallet);

Expand Down Expand Up @@ -1242,15 +1243,14 @@ 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,
if (!AddToWalletIfInvolvingMe(ptx,
(pindexBlockConnected) ? pindexBlockConnected->GetBlockHash() : uint256(),
posInBlock,
true)) {
return; // Not one of ours
}

MarkAffectedTransactionsDirty(tx);
MarkAffectedTransactionsDirty(*ptx);
}

void CWallet::TransactionAddedToMempool(const CTransactionRef& ptx)
Expand Down Expand Up @@ -1747,7 +1747,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate, b
int posInBlock;
for (posInBlock = 0; posInBlock < (int)block.vtx.size(); posInBlock++) {
const auto& tx = block.vtx[posInBlock];
if (AddToWalletIfInvolvingMe(*tx, pindex->GetBlockHash(), posInBlock, fUpdate)) {
if (AddToWalletIfInvolvingMe(tx, pindex->GetBlockHash(), posInBlock, fUpdate)) {
myTxHashes.push_back(tx->GetHash());
ret++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.h
Expand Up @@ -604,7 +604,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
void TransactionAddedToMempool(const CTransactionRef& tx) override;
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex *pindex, const std::vector<CTransactionRef>& vtxConflicted) override;
void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock) override;
bool AddToWalletIfInvolvingMe(const CTransaction& tx, const uint256& blockHash, int posInBlock, bool fUpdate);
bool AddToWalletIfInvolvingMe(const CTransactionRef& tx, const uint256& blockHash, int posInBlock, bool fUpdate);
void EraseFromWallet(const uint256& hash);

/**
Expand Down

0 comments on commit b799070

Please sign in to comment.