Skip to content

Commit cd057bf

Browse files
committed
Revert "Check signatures before respend relay"
This reverts commit 88dd359.
1 parent 67cc8f2 commit cd057bf

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

src/main.cpp

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ namespace {
128128

129129
// Forward reference functions defined here:
130130
static const unsigned int MAX_DOUBLESPEND_BLOOM = 1000;
131-
static bool RelayableRespend(const COutPoint& outPoint, const CTransaction& doubleSpend, bool fInBlock, CBloomFilter& filter);
131+
static void RelayDoubleSpend(const COutPoint& outPoint, const CTransaction& doubleSpend, bool fInBlock, CBloomFilter& filter);
132132

133133
//////////////////////////////////////////////////////////////////////////////
134134
//
@@ -157,7 +157,7 @@ struct CMainSignals {
157157
// transaction was first seen in a block.
158158
// Note: only notifies if the previous transaction is in the memory pool; if previous transction was in a block,
159159
// then the double-spend simply fails when we try to lookup the inputs in the current UTXO set.
160-
boost::signals2::signal<bool (const COutPoint&, const CTransaction&, bool)> DetectedDoubleSpend;
160+
boost::signals2::signal<void (const COutPoint&, const CTransaction&, bool)> DetectedDoubleSpend;
161161
} g_signals;
162162

163163
} // anon namespace
@@ -167,7 +167,7 @@ void RegisterInternalSignals() {
167167
seed_insecure_rand();
168168
doubleSpendFilter = CBloomFilter(MAX_DOUBLESPEND_BLOOM, 0.01, insecure_rand(), BLOOM_UPDATE_NONE);
169169

170-
g_signals.DetectedDoubleSpend.connect(boost::bind(RelayableRespend, _1, _2, _3, doubleSpendFilter));
170+
g_signals.DetectedDoubleSpend.connect(boost::bind(RelayDoubleSpend, _1, _2, _3, doubleSpendFilter));
171171
}
172172

173173

@@ -934,7 +934,6 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
934934
return false;
935935

936936
// Check for conflicts with in-memory transactions
937-
bool relayableRespend = false;
938937
{
939938
LOCK(pool.cs); // protect pool.mapNextTx
940939
for (unsigned int i = 0; i < tx.vin.size(); i++)
@@ -943,9 +942,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
943942
// Does tx conflict with a member of the pool, and is it not equivalent to that member?
944943
if (pool.mapNextTx.count(outpoint) && !tx.IsEquivalentTo(*pool.mapNextTx[outpoint].ptx))
945944
{
946-
relayableRespend = g_signals.DetectedDoubleSpend(outpoint, tx, false);
947-
if (!relayableRespend)
948-
return false;
945+
g_signals.DetectedDoubleSpend(outpoint, tx, false);
946+
return false;
949947
}
950948
}
951949
}
@@ -1038,24 +1036,16 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
10381036
{
10391037
return error("AcceptToMemoryPool: : ConnectInputs failed %s", hash.ToString());
10401038
}
1041-
1042-
if (relayableRespend)
1043-
{
1044-
RelayTransaction(tx);
1045-
}
1046-
else
1047-
{
1048-
// Store transaction in memory
1049-
pool.addUnchecked(hash, entry);
1050-
}
1039+
// Store transaction in memory
1040+
pool.addUnchecked(hash, entry);
10511041
}
10521042

10531043
g_signals.SyncTransaction(tx, NULL);
10541044

1055-
return !relayableRespend;
1045+
return true;
10561046
}
10571047

1058-
static bool RelayableRespend(const COutPoint& outPoint, const CTransaction& doubleSpend, bool fInBlock, CBloomFilter& filter)
1048+
static void RelayDoubleSpend(const COutPoint& outPoint, const CTransaction& doubleSpend, bool fInBlock, CBloomFilter& filter)
10591049
{
10601050
// Relaying double-spend attempts to our peers lets them detect when
10611051
// somebody might be trying to cheat them. However, blindly relaying
@@ -1068,7 +1058,7 @@ static bool RelayableRespend(const COutPoint& outPoint, const CTransaction& doub
10681058
// from us they are very likely to hear about it from another peer, since
10691059
// each peer uses a different, randomized bloom filter.
10701060

1071-
if (fInBlock || filter.contains(outPoint)) return false;
1061+
if (fInBlock || filter.contains(outPoint)) return;
10721062

10731063
// Apply an independent rate limit to double-spend relays
10741064
static double dRespendCount;
@@ -1079,7 +1069,7 @@ static bool RelayableRespend(const COutPoint& outPoint, const CTransaction& doub
10791069
if (RateLimitExceeded(dRespendCount, nLastRespendTime, nRespendLimit, nSize))
10801070
{
10811071
LogPrint("mempool", "Double-spend relay rejected by rate limiter\n");
1082-
return false;
1072+
return;
10831073
}
10841074

10851075
LogPrint("mempool", "Rate limit dRespendCount: %g => %g\n", dRespendCount, dRespendCount+nSize);
@@ -1091,7 +1081,10 @@ static bool RelayableRespend(const COutPoint& outPoint, const CTransaction& doub
10911081

10921082
filter.insert(outPoint);
10931083

1094-
return true;
1084+
RelayTransaction(doubleSpend);
1085+
1086+
// Share conflict with wallet
1087+
g_signals.SyncTransaction(doubleSpend, NULL);
10951088
}
10961089

10971090

0 commit comments

Comments
 (0)