1219 | @@ -1220,10 +1220,10 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
1220 | }
1221 |
1222 | bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
1223 | - bool* pfMissingInputs, bool fOverrideMempoolLimit, bool fRejectAbsurdFee)
1224 | + bool* pfMissingInputs, bool fOverrideMempoolLimit, const CAmount nAbsurdFee)
Any specific reason for making this pass-by-value argument const? (also below in AcceptToMemoryPool)
or did you mean const CAmount& nAbsurdFee?
I don't have background in cpp but isn't this considered best practice? (Fiddling with nAbsurdFee here would give error: assignment of read-only parameter ‘nAbsurdFee’).
Pass by reference is not mentioned in /doc/developer-notes.md and I don't like doing this for basic types but I am happy to change if that's something we do.
Having pass-by-value args const is something we don't do anywhere, whereas there are many places where CAmount is passed by reference (as a git grep shows me). The idea is that CAmount is not a basic type in some derived code.
IMHO extra const is never a bad thing.
In this case, if CAmount is not considered a basic enough type, then sure, const CAmount&.
FWIW, I didn't know that const-by-value could be ever considered worse than regular by-value either.
@laanwj can you extend on this or were you just pointing at the fact that you can always turn a const-by-value into a const-by-ref unless you want to avoid the warning you'll get with basic types?
@jtimon I never said it was worse, it is just a convention we use nowhere else, whereas const CAmount& someAmount is a common convention (according to git grep).
There's no deep reason not to make pass-by-value arguments to a function const. On the other hand, it is only a programmer convention for marking a value as "Do not change this!". The compiler will still happily push a copy on the stack.
So usually that means someone made a typo. If this is intentional I'm fine with it, I didn't intend for this to become a whole argument.