Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
fees.cpp
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 The Bitcoin Core developers
3// Copyright (c) 2018-2019 The Bitcoin developers
4// Distributed under the MIT software license, see the accompanying
5// file COPYING or http://www.opensource.org/licenses/mit-license.php.
6
7#include <policy/fees.h>
8
9#include <feerate.h>
10
11static std::set<Amount> MakeFeeSet(const CFeeRate &min_incremental_fee,
13 const double fee_filter_spacing) {
14 std::set<Amount> fee_set;
15
17 std::max(SATOSHI, min_incremental_fee.GetFeePerK() / 2);
18 fee_set.insert(Amount::zero());
23 }
24
25 return fee_set;
26}
27
32
35
36 auto it = m_fee_set.lower_bound(currentMinFee);
37 if (it == m_fee_set.end() ||
38 (it != m_fee_set.begin() &&
39 WITH_LOCK(m_insecure_rand_mutex, return insecure_rand.rand32()) % 3 !=
40 0)) {
41 --it;
42 }
43
44 return *it;
45}
static constexpr Amount SATOSHI
Definition amount.h:143
Fee rate in satoshis per kilobyte: Amount / kB.
Definition feerate.h:21
Fast randomness source.
Definition random.h:156
const std::set< Amount > m_fee_set
Definition fees.h:42
Amount round(const Amount currentMinFee) EXCLUSIVE_LOCKS_REQUIRED(!m_insecure_rand_mutex)
Quantize a minimum fee for privacy purpose before broadcast.
Definition fees.cpp:33
FeeFilterRounder(const CFeeRate &min_incremental_fee, FastRandomContext &rng)
Create new FeeFilterRounder.
Definition fees.cpp:28
Mutex m_insecure_rand_mutex
Definition fees.h:43
static std::set< Amount > MakeFeeSet(const CFeeRate &min_incremental_fee, const Amount &max_filter_fee_rate, const double fee_filter_spacing)
Definition fees.cpp:11
static const double FEE_SPACING
Spacing of FeeRate buckets.
Definition fees.h:27
static const Amount MAX_FEERATE(int64_t(1e7) *SATOSHI)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
static constexpr Amount zero() noexcept
Definition amount.h:32
#define AssertLockNotHeld(cs)
Definition sync.h:163
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition sync.h:357