@@ -128,7 +128,7 @@ namespace {
128
128
129
129
// Forward reference functions defined here:
130
130
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);
132
132
133
133
// ////////////////////////////////////////////////////////////////////////////
134
134
//
@@ -157,7 +157,7 @@ struct CMainSignals {
157
157
// transaction was first seen in a block.
158
158
// Note: only notifies if the previous transaction is in the memory pool; if previous transction was in a block,
159
159
// 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;
161
161
} g_signals;
162
162
163
163
} // anon namespace
@@ -167,7 +167,7 @@ void RegisterInternalSignals() {
167
167
seed_insecure_rand ();
168
168
doubleSpendFilter = CBloomFilter (MAX_DOUBLESPEND_BLOOM, 0.01 , insecure_rand (), BLOOM_UPDATE_NONE);
169
169
170
- g_signals.DetectedDoubleSpend .connect (boost::bind (RelayableRespend , _1, _2, _3, doubleSpendFilter));
170
+ g_signals.DetectedDoubleSpend .connect (boost::bind (RelayDoubleSpend , _1, _2, _3, doubleSpendFilter));
171
171
}
172
172
173
173
@@ -934,7 +934,6 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
934
934
return false ;
935
935
936
936
// Check for conflicts with in-memory transactions
937
- bool relayableRespend = false ;
938
937
{
939
938
LOCK (pool.cs ); // protect pool.mapNextTx
940
939
for (unsigned int i = 0 ; i < tx.vin .size (); i++)
@@ -943,9 +942,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
943
942
// Does tx conflict with a member of the pool, and is it not equivalent to that member?
944
943
if (pool.mapNextTx .count (outpoint) && !tx.IsEquivalentTo (*pool.mapNextTx [outpoint].ptx ))
945
944
{
946
- relayableRespend = g_signals.DetectedDoubleSpend (outpoint, tx, false );
947
- if (!relayableRespend)
948
- return false ;
945
+ g_signals.DetectedDoubleSpend (outpoint, tx, false );
946
+ return false ;
949
947
}
950
948
}
951
949
}
@@ -1038,24 +1036,16 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
1038
1036
{
1039
1037
return error (" AcceptToMemoryPool: : ConnectInputs failed %s" , hash.ToString ());
1040
1038
}
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);
1051
1041
}
1052
1042
1053
1043
g_signals.SyncTransaction (tx, NULL );
1054
1044
1055
- return !relayableRespend ;
1045
+ return true ;
1056
1046
}
1057
1047
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)
1059
1049
{
1060
1050
// Relaying double-spend attempts to our peers lets them detect when
1061
1051
// somebody might be trying to cheat them. However, blindly relaying
@@ -1068,7 +1058,7 @@ static bool RelayableRespend(const COutPoint& outPoint, const CTransaction& doub
1068
1058
// from us they are very likely to hear about it from another peer, since
1069
1059
// each peer uses a different, randomized bloom filter.
1070
1060
1071
- if (fInBlock || filter.contains (outPoint)) return false ;
1061
+ if (fInBlock || filter.contains (outPoint)) return ;
1072
1062
1073
1063
// Apply an independent rate limit to double-spend relays
1074
1064
static double dRespendCount;
@@ -1079,7 +1069,7 @@ static bool RelayableRespend(const COutPoint& outPoint, const CTransaction& doub
1079
1069
if (RateLimitExceeded (dRespendCount, nLastRespendTime, nRespendLimit, nSize))
1080
1070
{
1081
1071
LogPrint (" mempool" , " Double-spend relay rejected by rate limiter\n " );
1082
- return false ;
1072
+ return ;
1083
1073
}
1084
1074
1085
1075
LogPrint (" mempool" , " Rate limit dRespendCount: %g => %g\n " , dRespendCount, dRespendCount+nSize);
@@ -1091,7 +1081,10 @@ static bool RelayableRespend(const COutPoint& outPoint, const CTransaction& doub
1091
1081
1092
1082
filter.insert (outPoint);
1093
1083
1094
- return true ;
1084
+ RelayTransaction (doubleSpend);
1085
+
1086
+ // Share conflict with wallet
1087
+ g_signals.SyncTransaction (doubleSpend, NULL );
1095
1088
}
1096
1089
1097
1090
0 commit comments