Extract CWallet::MarkInputsDirty
To avoid repeated implementations.
This commit is contained in:
parent
619cd29393
commit
b7f5650942
2 changed files with 16 additions and 21 deletions
|
@ -1107,6 +1107,16 @@ bool CWallet::TransactionCanBeAbandoned(const uint256& hashTx) const
|
|||
return wtx && !wtx->isAbandoned() && wtx->GetDepthInMainChain() == 0 && !wtx->InMempool();
|
||||
}
|
||||
|
||||
void CWallet::MarkInputsDirty(const CTransactionRef& tx)
|
||||
{
|
||||
for (const CTxIn& txin : tx->vin) {
|
||||
auto it = mapWallet.find(txin.prevout.hash);
|
||||
if (it != mapWallet.end()) {
|
||||
it->second.MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CWallet::AbandonTransaction(const uint256& hashTx)
|
||||
{
|
||||
LOCK2(cs_main, cs_wallet);
|
||||
|
@ -1155,13 +1165,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
|
|||
}
|
||||
// If a transaction changes 'conflicted' state, that changes the balance
|
||||
// available of the outputs it spends. So force those to be recomputed
|
||||
for (const CTxIn& txin : wtx.tx->vin)
|
||||
{
|
||||
auto it = mapWallet.find(txin.prevout.hash);
|
||||
if (it != mapWallet.end()) {
|
||||
it->second.MarkDirty();
|
||||
}
|
||||
}
|
||||
MarkInputsDirty(wtx.tx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1217,31 +1221,19 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
|
|||
}
|
||||
// If a transaction changes 'conflicted' state, that changes the balance
|
||||
// available of the outputs it spends. So force those to be recomputed
|
||||
for (const CTxIn& txin : wtx.tx->vin) {
|
||||
auto it = mapWallet.find(txin.prevout.hash);
|
||||
if (it != mapWallet.end()) {
|
||||
it->second.MarkDirty();
|
||||
}
|
||||
}
|
||||
MarkInputsDirty(wtx.tx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pindex, int posInBlock, bool update_tx) {
|
||||
const CTransaction& tx = *ptx;
|
||||
|
||||
if (!AddToWalletIfInvolvingMe(ptx, pindex, posInBlock, update_tx))
|
||||
return; // Not one of ours
|
||||
|
||||
// If a transaction changes 'conflicted' state, that changes the balance
|
||||
// available of the outputs it spends. So force those to be
|
||||
// recomputed, also:
|
||||
for (const CTxIn& txin : tx.vin) {
|
||||
auto it = mapWallet.find(txin.prevout.hash);
|
||||
if (it != mapWallet.end()) {
|
||||
it->second.MarkDirty();
|
||||
}
|
||||
}
|
||||
MarkInputsDirty(ptx);
|
||||
}
|
||||
|
||||
void CWallet::TransactionAddedToMempool(const CTransactionRef& ptx) {
|
||||
|
|
|
@ -706,6 +706,9 @@ private:
|
|||
/* Mark a transaction (and its in-wallet descendants) as conflicting with a particular block. */
|
||||
void MarkConflicted(const uint256& hashBlock, const uint256& hashTx);
|
||||
|
||||
/* Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed */
|
||||
void MarkInputsDirty(const CTransactionRef& tx);
|
||||
|
||||
void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>);
|
||||
|
||||
/* Used by TransactionAddedToMemorypool/BlockConnected/Disconnected/ScanForWalletTransactions.
|
||||
|
|
Loading…
Reference in a new issue