util: add _GiB for Gibibyte conversions

Introduce `operator""_GiB`, sharing the overflow-checked conversion logic with the existing `operator""_MiB`.

Use `1_GiB` in a few existing places where it is a drop-in replacement (e.g. `1024_MiB`, `1<<30`) and extend unit tests to cover boundary behavior.
This commit is contained in:
Lőrinc
2026-01-28 14:44:44 +01:00
parent ad0545ba96
commit b3edd30aa2
6 changed files with 78 additions and 29 deletions

View File

@@ -1972,7 +1972,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// On first startup, warn on low block storage space
if (!do_reindex && !do_reindex_chainstate && chain_active_height <= 1) {
uint64_t assumed_chain_bytes{chainparams.AssumedBlockchainSize() * 1024 * 1024 * 1024};
uint64_t assumed_chain_bytes{chainparams.AssumedBlockchainSize() * 1_GiB};
uint64_t additional_bytes_needed{
chainman.m_blockman.IsPruneMode() ?
std::min(chainman.m_blockman.GetPruneTarget(), assumed_chain_bytes) :