Skip to content

Commit 094e4b3

Browse files
committed
Better document usage of SyncTransaction
1 parent 4afbde6 commit 094e4b3

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/validationinterface.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ class CValidationInterface {
5050
struct CMainSignals {
5151
/** Notifies listeners of updated block chain tip */
5252
boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> UpdatedBlockTip;
53-
/** A posInBlock value for SyncTransaction which indicates the transaction was conflicted, disconnected, or not in a block */
53+
/** A posInBlock value for SyncTransaction calls for tranactions not
54+
* included in connected blocks such as transactions removed from mempool,
55+
* accepted to mempool or appearing in disconnected blocks.*/
5456
static const int SYNC_TRANSACTION_NOT_IN_BLOCK = -1;
55-
/** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
57+
/** Notifies listeners of updated transaction data (transaction, and
58+
* optionally the block it is found in). Called with block data when
59+
* transaction is included in a connected block, and without block data when
60+
* transaction was accepted to mempool, removed from mempool (only when
61+
* removal was due to conflict from connected block), or appeared in a
62+
* disconnected block.*/
5663
boost::signals2::signal<void (const CTransaction &, const CBlockIndex *pindex, int posInBlock)> SyncTransaction;
5764
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
5865
boost::signals2::signal<void (const uint256 &)> UpdatedTransaction;

src/wallet/wallet.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,9 +1003,17 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
10031003
}
10041004

10051005
/**
1006-
* Add a transaction to the wallet, or update it.
1007-
* pblock is optional, but should be provided if the transaction is known to be in a block.
1006+
* Add a transaction to the wallet, or update it. pIndex and posInBlock should
1007+
* be set when the transaction was known to be included in a block. When
1008+
* posInBlock = SYNC_TRANSACTION_NOT_IN_BLOCK (-1) , then wallet state is not
1009+
* updated in AddToWallet, but notifications happen and cached balances are
1010+
* marked dirty.
10081011
* If fUpdate is true, existing transactions will be updated.
1012+
* TODO: One exception to this is that the abandoned state is cleared under the
1013+
* assumption that any further notification of a transaction that was considered
1014+
* abandoned is an indication that it is not safe to be considered abandoned.
1015+
* Abandoned state should probably be more carefuly tracked via different
1016+
* posInBlock signals or by checking mempool presence when necessary.
10091017
*/
10101018
bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlockIndex* pIndex, int posInBlock, bool fUpdate)
10111019
{

0 commit comments

Comments
 (0)