Skip to content

Commit d0cd0bd

Browse files
committed
Make CWallet::SyncTransactions() interface friendlier
1 parent 714e4ad commit d0cd0bd

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/wallet/wallet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,10 +1118,10 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
11181118
}
11191119
}
11201120

1121-
void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pindexBlockConnected, int posInBlock) {
1121+
void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pindex, int posInBlock) {
11221122
const CTransaction& tx = *ptx;
11231123

1124-
if (!AddToWalletIfInvolvingMe(ptx, pindexBlockConnected, posInBlock, true))
1124+
if (!AddToWalletIfInvolvingMe(ptx, pindex, posInBlock, true))
11251125
return; // Not one of ours
11261126

11271127
// If a transaction changes 'conflicted' state, that changes the balance
@@ -1136,7 +1136,7 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pin
11361136

11371137
void CWallet::TransactionAddedToMempool(const CTransactionRef& ptx) {
11381138
LOCK2(cs_main, cs_wallet);
1139-
SyncTransaction(ptx, NULL, -1);
1139+
SyncTransaction(ptx);
11401140
}
11411141

11421142
void CWallet::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex *pindex, const std::vector<CTransactionRef>& vtxConflicted) {
@@ -1150,7 +1150,7 @@ void CWallet::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const
11501150
// the notification that the conflicted transaction was evicted.
11511151

11521152
for (const CTransactionRef& ptx : vtxConflicted) {
1153-
SyncTransaction(ptx, NULL, -1);
1153+
SyncTransaction(ptx);
11541154
}
11551155
for (size_t i = 0; i < pblock->vtx.size(); i++) {
11561156
SyncTransaction(pblock->vtx[i], pindex, i);
@@ -1161,7 +1161,7 @@ void CWallet::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock) {
11611161
LOCK2(cs_main, cs_wallet);
11621162

11631163
for (const CTransactionRef& ptx : pblock->vtx) {
1164-
SyncTransaction(ptx, NULL, -1);
1164+
SyncTransaction(ptx);
11651165
}
11661166
}
11671167

src/wallet/wallet.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,9 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
659659

660660
void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>);
661661

662-
/* Used by TransactionAddedToMemorypool/BlockConnected/Disconnected */
663-
void SyncTransaction(const CTransactionRef& tx, const CBlockIndex *pindexBlockConnected, int posInBlock);
662+
/* Used by TransactionAddedToMemorypool/BlockConnected/Disconnected.
663+
* Should be called with pindexBlock and posInBlock if this is for a transaction that is included in a block. */
664+
void SyncTransaction(const CTransactionRef& tx, const CBlockIndex *pindex = NULL, int posInBlock = 0);
664665

665666
/* the HD chain data model (external chain counters) */
666667
CHDChain hdChain;

0 commit comments

Comments
 (0)