File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed
Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -4396,7 +4396,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
43964396 int64_t timeNow = GetTimeMicros ();
43974397 if (timeNow > pto->m_tx_relay ->nextSendTimeFeeFilter ) {
43984398 static CFeeRate default_feerate (DEFAULT_MIN_RELAY_TX_FEE);
4399- static FeeFilterRounder filterRounder (default_feerate);
4399+ static const FeeFilterRounder filterRounder (default_feerate);
44004400 CAmount filterToSend = filterRounder.round (currentFilter);
44014401 // We always have a fee filter of at least minRelayTxFee
44024402 filterToSend = std::max (filterToSend, ::minRelayTxFee.GetFeePerK ());
Original file line number Diff line number Diff line change @@ -968,10 +968,11 @@ FeeFilterRounder::FeeFilterRounder(const CFeeRate& minIncrementalFee)
968968 }
969969}
970970
971- CAmount FeeFilterRounder::round (CAmount currentMinFee)
971+ CAmount FeeFilterRounder::round (CAmount currentMinFee) const
972972{
973973 std::set<double >::iterator it = feeset.lower_bound (currentMinFee);
974- if ((it != feeset.begin () && insecure_rand.rand32 () % 3 != 0 ) || it == feeset.end ()) {
974+ const uint32_t rand = WITH_LOCK (m_random_context_mutex, return m_insecure_rand.rand32 ());
975+ if ((it != feeset.begin () && rand % 3 != 0 ) || it == feeset.end ()) {
975976 it--;
976977 }
977978 return static_cast <CAmount>(*it);
Original file line number Diff line number Diff line change @@ -281,11 +281,12 @@ class FeeFilterRounder
281281 explicit FeeFilterRounder (const CFeeRate& minIncrementalFee);
282282
283283 /* * Quantize a minimum fee for privacy purpose before broadcast **/
284- CAmount round (CAmount currentMinFee);
284+ CAmount round (CAmount currentMinFee) const ;
285285
286286private:
287287 std::set<double > feeset;
288- FastRandomContext insecure_rand;
288+ mutable Mutex m_random_context_mutex;
289+ mutable FastRandomContext m_insecure_rand GUARDED_BY (m_random_context_mutex);
289290};
290291
291292#endif // BITCOIN_POLICY_FEES_H
You can’t perform that action at this time.
0 commit comments