@@ -2112,53 +2112,37 @@ bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
2112
2112
return CTransaction (tx1) == CTransaction (tx2);
2113
2113
}
2114
2114
2115
- std::vector<uint256> CWallet::ResendWalletTransactionsBefore (interfaces::Chain::Lock& locked_chain, int64_t nTime)
2116
- {
2117
- std::vector<uint256> result;
2118
-
2119
- LOCK (cs_wallet);
2120
-
2121
- // Sort them in chronological order
2122
- std::multimap<unsigned int , CWalletTx*> mapSorted;
2123
- for (std::pair<const uint256, CWalletTx>& item : mapWallet)
2124
- {
2125
- CWalletTx& wtx = item.second ;
2126
- // Don't rebroadcast if newer than nTime:
2127
- if (wtx.nTimeReceived > nTime)
2128
- continue ;
2129
- mapSorted.insert (std::make_pair (wtx.nTimeReceived , &wtx));
2130
- }
2131
- for (const std::pair<const unsigned int , CWalletTx*>& item : mapSorted)
2132
- {
2133
- CWalletTx& wtx = *item.second ;
2134
- if (wtx.RelayWalletTransaction (locked_chain)) {
2135
- result.push_back (wtx.GetHash ());
2136
- }
2137
- }
2138
- return result;
2139
- }
2140
-
2141
2115
void CWallet::ResendWalletTransactions (interfaces::Chain::Lock& locked_chain, int64_t nBestBlockTime)
2142
2116
{
2143
2117
// Do this infrequently and randomly to avoid giving away
2144
2118
// that these are our transactions.
2145
- if (GetTime () < nNextResend || !fBroadcastTransactions )
2146
- return ;
2119
+ if (GetTime () < nNextResend || !fBroadcastTransactions ) return ;
2147
2120
bool fFirst = (nNextResend == 0 );
2148
2121
nNextResend = GetTime () + GetRand (30 * 60 );
2149
- if (fFirst )
2150
- return ;
2122
+ if (fFirst ) return ;
2151
2123
2152
2124
// Only do it if there's been a new block since last time
2153
- if (nBestBlockTime < nLastResend)
2154
- return ;
2125
+ if (nBestBlockTime < nLastResend) return ;
2155
2126
nLastResend = GetTime ();
2156
2127
2157
- // Rebroadcast unconfirmed txes older than 5 minutes before the last
2158
- // block was found:
2159
- std::vector<uint256> relayed = ResendWalletTransactionsBefore (locked_chain, nBestBlockTime-5 *60 );
2160
- if (!relayed.empty ())
2161
- WalletLogPrintf (" %s: rebroadcast %u unconfirmed transactions\n " , __func__, relayed.size ());
2128
+ int relayed_tx_count = 0 ;
2129
+
2130
+ { // cs_wallet scope
2131
+ LOCK (cs_wallet);
2132
+
2133
+ // Relay transactions
2134
+ for (std::pair<const uint256, CWalletTx>& item : mapWallet) {
2135
+ CWalletTx& wtx = item.second ;
2136
+ // only rebroadcast unconfirmed txes older than 5 minutes before the
2137
+ // last block was found
2138
+ if (wtx.nTimeReceived > nBestBlockTime - 5 * 60 ) continue ;
2139
+ relayed_tx_count += wtx.RelayWalletTransaction (locked_chain) ? 1 : 0 ;
2140
+ }
2141
+ } // cs_wallet
2142
+
2143
+ if (relayed_tx_count > 0 ) {
2144
+ WalletLogPrintf (" %s: rebroadcast %u unconfirmed transactions\n " , __func__, relayed_tx_count);
2145
+ }
2162
2146
}
2163
2147
2164
2148
/* * @} */ // end of mapWallet
0 commit comments