Merge pull request #1971 from sipa/bugfix_norelayspent

Bugfix: do not keep relaying spent wallet transactions
This commit is contained in:
Pieter Wuille 2012-11-03 11:51:13 -07:00
commit a56d3f8a10
1 changed files with 5 additions and 9 deletions

View File

@ -820,21 +820,17 @@ void CWallet::ReacceptWalletTransactions()
void CWalletTx::RelayWalletTransaction() void CWalletTx::RelayWalletTransaction()
{ {
CCoinsViewCache& coins = *pcoinsTip;
BOOST_FOREACH(const CMerkleTx& tx, vtxPrev) BOOST_FOREACH(const CMerkleTx& tx, vtxPrev)
{ {
if (!tx.IsCoinBase()) if (!tx.IsCoinBase()) {
{ if (tx.GetDepthInMainChain() == 0)
uint256 hash = tx.GetHash(); RelayMessage(CInv(MSG_TX, tx.GetHash()), (CTransaction)tx);
if (!coins.HaveCoins(hash))
RelayMessage(CInv(MSG_TX, hash), (CTransaction)tx);
} }
} }
if (!IsCoinBase()) if (!IsCoinBase())
{ {
uint256 hash = GetHash(); if (GetDepthInMainChain() == 0) {
if (!coins.HaveCoins(hash)) uint256 hash = GetHash();
{
printf("Relaying wtx %s\n", hash.ToString().substr(0,10).c_str()); printf("Relaying wtx %s\n", hash.ToString().substr(0,10).c_str());
RelayMessage(CInv(MSG_TX, hash), (CTransaction)*this); RelayMessage(CInv(MSG_TX, hash), (CTransaction)*this);
} }