aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <sipa@ulyssis.org>2012-11-01 15:52:25 +0100
committerPieter Wuille <sipa@ulyssis.org>2012-11-01 18:06:29 +0100
commit5eaf91a4286380e5db239b63477b627ab91a53e7 (patch)
tree2687b59ae9f6f97f5f7d034442bdf9a6837ac7a7
parent41db7c224a6a272c5f6fe70e17d28219fa9d66d9 (diff)
Bugfix: do not keep relaying spent wallet transactions
The original test (checking whether the transaction occurs in the txindex) is not usable anymore, as it will miss anything already fully spent. However, as merkle transactions (and by extension, wallet transactions) track which block they were last seen being included in, we can use that to determine the need for rebroadcasting.
-rw-r--r--src/wallet.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index dc6169c4b8..67b4e8f095 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -820,21 +820,17 @@ void CWallet::ReacceptWalletTransactions()
void CWalletTx::RelayWalletTransaction()
{
- CCoinsViewCache& coins = *pcoinsTip;
BOOST_FOREACH(const CMerkleTx& tx, vtxPrev)
{
- if (!tx.IsCoinBase())
- {
- uint256 hash = tx.GetHash();
- if (!coins.HaveCoins(hash))
- RelayMessage(CInv(MSG_TX, hash), (CTransaction)tx);
+ if (!tx.IsCoinBase()) {
+ if (tx.GetDepthInMainChain() == 0)
+ RelayMessage(CInv(MSG_TX, tx.GetHash()), (CTransaction)tx);
}
}
if (!IsCoinBase())
{
- uint256 hash = GetHash();
- if (!coins.HaveCoins(hash))
- {
+ if (GetDepthInMainChain() == 0) {
+ uint256 hash = GetHash();
printf("Relaying wtx %s\n", hash.ToString().substr(0,10).c_str());
RelayMessage(CInv(MSG_TX, hash), (CTransaction)*this);
}