Skip to content

Commit 7517126

Browse files
committed
init: Use size_t consistently for cache sizes
This avoids having to rely on implicit casts when passing them to the various functions allocating the caches. Also take this opportunity to make the total amounts of cache in the chainstate manager a size_t too
1 parent 9f55bd4 commit 7517126

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/kernel/caches.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ static constexpr int64_t MAX_COINS_DB_CACHE{8};
1717

1818
namespace kernel {
1919
struct CacheSizes {
20-
int64_t block_tree_db;
21-
int64_t coins_db;
22-
int64_t coins;
20+
size_t block_tree_db;
21+
size_t coins_db;
22+
size_t coins;
2323

2424
CacheSizes(int64_t total_cache)
2525
{

src/node/caches.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ static constexpr int64_t DEFAULT_DB_CACHE{DEFAULT_KERNEL_CACHE};
2020

2121
namespace node {
2222
struct IndexCacheSizes {
23-
int64_t tx_index;
24-
int64_t filter_index;
23+
size_t tx_index;
24+
size_t filter_index;
2525
};
2626
std::tuple<IndexCacheSizes, kernel::CacheSizes> CalculateCacheSizes(const ArgsManager& args, size_t n_indexes = 0);
2727
} // namespace node

src/node/chainstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static ChainstateLoadResult CompleteChainstateInitialization(
4646
try {
4747
pblocktree = std::make_unique<BlockTreeDB>(DBParams{
4848
.path = chainman.m_options.datadir / "blocks" / "index",
49-
.cache_bytes = static_cast<size_t>(cache_sizes.block_tree_db),
49+
.cache_bytes = cache_sizes.block_tree_db,
5050
.memory_only = options.block_tree_db_in_memory,
5151
.wipe_data = options.wipe_block_tree_db,
5252
.options = chainman.m_options.block_tree_db});

src/test/util/setup_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ ChainTestingSetup::ChainTestingSetup(const ChainType chainType, TestOpts opts)
252252
LOCK(m_node.chainman->GetMutex());
253253
m_node.chainman->m_blockman.m_block_tree_db = std::make_unique<BlockTreeDB>(DBParams{
254254
.path = m_args.GetDataDirNet() / "blocks" / "index",
255-
.cache_bytes = static_cast<size_t>(m_kernel_cache_sizes.block_tree_db),
255+
.cache_bytes = m_kernel_cache_sizes.block_tree_db,
256256
.memory_only = true,
257257
});
258258
};

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,11 +1067,11 @@ class ChainstateManager
10671067

10681068
//! The total number of bytes available for us to use across all in-memory
10691069
//! coins caches. This will be split somehow across chainstates.
1070-
int64_t m_total_coinstip_cache{0};
1070+
size_t m_total_coinstip_cache{0};
10711071
//
10721072
//! The total number of bytes available for us to use across all leveldb
10731073
//! coins databases. This will be split somehow across chainstates.
1074-
int64_t m_total_coinsdb_cache{0};
1074+
size_t m_total_coinsdb_cache{0};
10751075

10761076
//! Instantiate a new chainstate.
10771077
//!

0 commit comments

Comments
 (0)