diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2022-02-21 17:03:27 +0100 |
---|---|---|
committer | Vasil Dimov <vd@FreeBSD.org> | 2022-04-18 10:40:05 +0200 |
commit | e7a5bf6be79e341e037305a4c2d8a1a510a8d709 (patch) | |
tree | 4c0769152549886a8e215b12c93191701e37ef91 /src/policy/fees.cpp | |
parent | 2074d7df20ebc100db6a7b2c3b784ef0bdb8753f (diff) | |
download | bitcoin-e7a5bf6be79e341e037305a4c2d8a1a510a8d709.tar.xz |
fees: make the class FeeFilterRounder thread-safe
So that its methods can be called concurrently by different threads on
the same object. Currently it has just one method (`round()`).
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Diffstat (limited to 'src/policy/fees.cpp')
-rw-r--r-- | src/policy/fees.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index 6499dbd97f..9f576e738a 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -1010,8 +1010,10 @@ FeeFilterRounder::FeeFilterRounder(const CFeeRate& minIncrementalFee) CAmount FeeFilterRounder::round(CAmount currentMinFee) { std::set<double>::iterator it = feeset.lower_bound(currentMinFee); - if ((it != feeset.begin() && insecure_rand.rand32() % 3 != 0) || it == feeset.end()) { - it--; + if (it == feeset.end() || + (it != feeset.begin() && + WITH_LOCK(m_insecure_rand_mutex, return insecure_rand.rand32()) % 3 != 0)) { + --it; } return static_cast<CAmount>(*it); } |