mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-16 17:04:05 +02:00
refactor: use _MiB consistently for Mebibyte conversions
Replace hard-coded MiB byte conversions (e.g. `1024*1024`, `1<<20`, `1048576`) with the existing `_MiB` literal to improve readability and avoid repeating constants.
In the few spots where arithmetic involves signed values, the result is identical to the previous code assuming those quantities never turn negative.
Also switch to brace init on every declaration assigned from `_MiB`/`_GiB` literals so a future oversized value (e.g. `unsigned int x{4096_MiB}`) becomes a compile error through the C++11 narrowing check instead of silently truncating.
Extend unit tests to cover the 32-bit `size_t` overflow boundary and to assert equivalence for integer and floating-point conversions.
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
Co-authored-by: w0xlt <94266259+w0xlt@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <tinyformat.h>
|
||||
#include <txdb.h>
|
||||
#include <uint256.h>
|
||||
#include <util/byte_units.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/log.h>
|
||||
#include <util/signalinterrupt.h>
|
||||
@@ -163,7 +164,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
|
||||
LogInfo("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.");
|
||||
} else if (chainman.m_blockman.GetPruneTarget()) {
|
||||
LogInfo("Prune configured to target %u MiB on disk for block and undo files.",
|
||||
chainman.m_blockman.GetPruneTarget() / 1024 / 1024);
|
||||
chainman.m_blockman.GetPruneTarget() / 1_MiB);
|
||||
}
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
Reference in New Issue
Block a user