0
Referring to the function CAmount CFeeRate::GetFee(size_t nBytes_) in feerate.cpp:
If I pass in say 2000 as the nBytes argument, what will this function return as the fee nFee? I don't understand how nSatoshisPerK is defined. Also, curious as to why this is used instead of letting miners determine this fee through selective mining.
CAmount CFeeRate::GetFee(size_t nBytes_) const
{
assert(nBytes_ <= uint64_t(std::numeric_limits<int64_t>::max()));
int64_t nSize = int64_t(nBytes_);
CAmount nFee = nSatoshisPerK * nSize / 1000;
if (nFee == 0 && nSize != 0) {
if (nSatoshisPerK > 0)
nFee = CAmount(1);
if (nSatoshisPerK < 0)
nFee = CAmount(-1);
}
return nFee;
}
Ok so this definition
CFeeRate(const I _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK)infeerate.hlooks like the one being used invalidation.cpphere:CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);, which would setnSatoshisPerKtoDEFAULT_MIN_RELAY_TX_FEE. Is that what you're saying? Also, it seems that this is enforced invalidation.cppI thought these validations were run on all incoming blocks. – JBaczuk – 2018-07-03T19:45:31.9931There are multiple fee rates used for different purposes. One of them is the minimum relay fee (which is what you are looking at) which is the minimum fee that a transaction must pay in order for it to be accepted to the node's mempool and relayed. Yes. that particular fee rate in validation.cpp sets nSatoshisPerK for that fee rate object to the DEFAULT_MIN_RELAY_TX_FEE. – Andrew Chow – 2018-07-03T19:52:27.350