Changeset View
Changeset View
Standalone View
Standalone View
src/policy/fees.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
Lint: Code style violation: '/Users/shammah/repos/bitcoin-abc/src/policy/fees.cpp' has code style errors. | |||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "policy/fees.h" | #include "policy/fees.h" | ||||
#include "policy/policy.h" | #include "policy/policy.h" | ||||
#include "amount.h" | #include "amount.h" | ||||
▲ Show 20 Lines • Show All 327 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
CBlockPolicyEstimator::CBlockPolicyEstimator(const CFeeRate &_minRelayFee) | CBlockPolicyEstimator::CBlockPolicyEstimator(const CFeeRate &_minRelayFee) | ||||
: nBestSeenHeight(0), trackedTxs(0), untrackedTxs(0) { | : nBestSeenHeight(0), trackedTxs(0), untrackedTxs(0) { | ||||
static_assert(MIN_FEERATE > 0, "Min feerate must be nonzero"); | static_assert(MIN_FEERATE > 0, "Min feerate must be nonzero"); | ||||
minTrackedFee = _minRelayFee < CFeeRate(MIN_FEERATE) ? CFeeRate(MIN_FEERATE) | minTrackedFee = _minRelayFee < CFeeRate(MIN_FEERATE) ? CFeeRate(MIN_FEERATE) | ||||
: _minRelayFee; | : _minRelayFee; | ||||
std::vector<double> vfeelist; | std::vector<double> vfeelist; | ||||
for (double bucketBoundary = minTrackedFee.GetFeePerK(); | for (double bucketBoundary = (double)minTrackedFee.GetFeePerK(); | ||||
bucketBoundary <= MAX_FEERATE; bucketBoundary *= FEE_SPACING) { | bucketBoundary <= MAX_FEERATE; bucketBoundary *= FEE_SPACING) { | ||||
vfeelist.push_back(bucketBoundary); | vfeelist.push_back(bucketBoundary); | ||||
} | } | ||||
vfeelist.push_back(INF_FEERATE); | vfeelist.push_back(INF_FEERATE); | ||||
feeStats.Initialize(vfeelist, MAX_BLOCK_CONFIRMS, DEFAULT_DECAY); | feeStats.Initialize(vfeelist, MAX_BLOCK_CONFIRMS, DEFAULT_DECAY); | ||||
} | } | ||||
void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry &entry, | void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry &entry, | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | void CBlockPolicyEstimator::Read(CAutoFile &filein, int nFileVersion) { | ||||
if (nFileVersion < 139900) { | if (nFileVersion < 139900) { | ||||
TxConfirmStats priStats; | TxConfirmStats priStats; | ||||
priStats.Read(filein); | priStats.Read(filein); | ||||
} | } | ||||
} | } | ||||
FeeFilterRounder::FeeFilterRounder(const CFeeRate &minIncrementalFee) { | FeeFilterRounder::FeeFilterRounder(const CFeeRate &minIncrementalFee) { | ||||
CAmount minFeeLimit = | CAmount minFeeLimit = | ||||
std::max(CAmount(1), minIncrementalFee.GetFeePerK() / 2); | CAmount(std::max(1LL, minIncrementalFee.GetFeePerK() / 2)); | ||||
feeset.insert(0); | feeset.insert(0); | ||||
for (double bucketBoundary = minFeeLimit; bucketBoundary <= MAX_FEERATE; | for (double bucketBoundary = (double)minFeeLimit; bucketBoundary <= MAX_FEERATE; | ||||
bucketBoundary *= FEE_SPACING) { | bucketBoundary *= FEE_SPACING) { | ||||
feeset.insert(bucketBoundary); | feeset.insert(bucketBoundary); | ||||
} | } | ||||
} | } | ||||
CAmount FeeFilterRounder::round(CAmount currentMinFee) { | CAmount FeeFilterRounder::round(CAmount currentMinFee) { | ||||
std::set<double>::iterator it = feeset.lower_bound(currentMinFee); | std::set<double>::iterator it = feeset.lower_bound((double)currentMinFee); | ||||
if ((it != feeset.begin() && insecure_rand.rand32() % 3 != 0) || | if ((it != feeset.begin() && insecure_rand.rand32() % 3 != 0) || | ||||
it == feeset.end()) { | it == feeset.end()) { | ||||
it--; | it--; | ||||
} | } | ||||
return *it; | return *it; | ||||
} | } |
'/Users/shammah/repos/bitcoin-abc/src/policy/fees.cpp' has code style errors.