Browse Source

Better document usage of SyncTransaction

0.14
Alex Morcos 8 years ago
parent
commit
094e4b3383
  1. 11
      src/validationinterface.h
  2. 12
      src/wallet/wallet.cpp

11
src/validationinterface.h

@ -50,9 +50,16 @@ protected: @@ -50,9 +50,16 @@ protected:
struct CMainSignals {
/** Notifies listeners of updated block chain tip */
boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> UpdatedBlockTip;
/** A posInBlock value for SyncTransaction which indicates the transaction was conflicted, disconnected, or not in a block */
/** A posInBlock value for SyncTransaction calls for tranactions not
* included in connected blocks such as transactions removed from mempool,
* accepted to mempool or appearing in disconnected blocks.*/
static const int SYNC_TRANSACTION_NOT_IN_BLOCK = -1;
/** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
/** Notifies listeners of updated transaction data (transaction, and
* optionally the block it is found in). Called with block data when
* transaction is included in a connected block, and without block data when
* transaction was accepted to mempool, removed from mempool (only when
* removal was due to conflict from connected block), or appeared in a
* disconnected block.*/
boost::signals2::signal<void (const CTransaction &, const CBlockIndex *pindex, int posInBlock)> SyncTransaction;
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
boost::signals2::signal<void (const uint256 &)> UpdatedTransaction;

12
src/wallet/wallet.cpp

@ -1003,9 +1003,17 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn) @@ -1003,9 +1003,17 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
}
/**
* Add a transaction to the wallet, or update it.
* pblock is optional, but should be provided if the transaction is known to be in a block.
* Add a transaction to the wallet, or update it. pIndex and posInBlock should
* be set when the transaction was known to be included in a block. When
* posInBlock = SYNC_TRANSACTION_NOT_IN_BLOCK (-1) , then wallet state is not
* updated in AddToWallet, but notifications happen and cached balances are
* marked dirty.
* If fUpdate is true, existing transactions will be updated.
* TODO: One exception to this is that the abandoned state is cleared under the
* assumption that any further notification of a transaction that was considered
* abandoned is an indication that it is not safe to be considered abandoned.
* Abandoned state should probably be more carefuly 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)
{

Loading…
Cancel
Save