Commit 3904bf5 Jan
authored
1 parent bb186ef commit 3904bf5 Copy full SHA for 3904bf5
File tree 1 file changed +9
-11
lines changed
1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 11
11
12
12
CFeeRate::CFeeRate (const CAmount& nFeePaid, uint32_t num_bytes)
13
13
{
14
- assert (num_bytes <= uint64_t (std::numeric_limits< int64_t >:: max ())) ;
15
- int64_t nSize = int64_t (num_bytes);
14
+ const int64_t nSize{num_bytes} ;
15
+
16
16
if (nSize > 0 ) {
17
17
nSatoshisPerK = nFeePaid * 1000 / nSize;
18
18
} else {
19
19
nSatoshisPerK = 0 ;
20
- }
20
+ }
21
21
}
22
22
23
23
CAmount CFeeRate::GetFee (uint32_t num_bytes) const
24
24
{
25
- assert (num_bytes <= uint64_t (std::numeric_limits< int64_t >:: max ())) ;
26
- int64_t nSize = int64_t (num_bytes);
25
+ const int64_t nSize{num_bytes} ;
26
+
27
27
CAmount nFee{static_cast <CAmount>(std::ceil (nSatoshisPerK * nSize / 1000.0 ))};
28
+
28
29
if (nFee == 0 && nSize != 0 ) {
29
- if (nSatoshisPerK > 0 ) {
30
- nFee = CAmount (1 );
31
- }
32
- if (nSatoshisPerK < 0 ) {
33
- nFee = CAmount (-1 );
34
- }
30
+ if (nSatoshisPerK > 0 ) nFee = CAmount (1 );
31
+ if (nSatoshisPerK < 0 ) nFee = CAmount (-1 );
35
32
}
33
+
36
34
return nFee;
37
35
}
38
36
You can’t perform that action at this time.
0 commit comments