LCOV - code coverage report
Current view: top level - src/node - caches.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 21 21 100.0 %
Date: 2022-04-21 14:51:19 Functions: 1 1 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 4 4 100.0 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2021 The Bitcoin Core developers
#       2                 :            : // Distributed under the MIT software license, see the accompanying
#       3                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#       4                 :            : 
#       5                 :            : #include <node/caches.h>
#       6                 :            : 
#       7                 :            : #include <txdb.h>
#       8                 :            : #include <util/system.h>
#       9                 :            : #include <validation.h>
#      10                 :            : 
#      11                 :            : namespace node {
#      12                 :            : CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
#      13                 :        949 : {
#      14                 :        949 :     int64_t nTotalCache = (args.GetIntArg("-dbcache", nDefaultDbCache) << 20);
#      15                 :        949 :     nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
#      16                 :        949 :     nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greater than nMaxDbcache
#      17                 :        949 :     CacheSizes sizes;
#      18                 :        949 :     sizes.block_tree_db = std::min(nTotalCache / 8, nMaxBlockDBCache << 20);
#      19                 :        949 :     nTotalCache -= sizes.block_tree_db;
#      20         [ +  + ]:        949 :     sizes.tx_index = std::min(nTotalCache / 8, args.GetBoolArg("-txindex", DEFAULT_TXINDEX) ? nMaxTxIndexCache << 20 : 0);
#      21                 :        949 :     nTotalCache -= sizes.tx_index;
#      22                 :        949 :     sizes.filter_index = 0;
#      23         [ +  + ]:        949 :     if (n_indexes > 0) {
#      24                 :         33 :         int64_t max_cache = std::min(nTotalCache / 8, max_filter_index_cache << 20);
#      25                 :         33 :         sizes.filter_index = max_cache / n_indexes;
#      26                 :         33 :         nTotalCache -= sizes.filter_index * n_indexes;
#      27                 :         33 :     }
#      28                 :        949 :     sizes.coins_db = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache
#      29                 :        949 :     sizes.coins_db = std::min(sizes.coins_db, nMaxCoinsDBCache << 20); // cap total coins db cache
#      30                 :        949 :     nTotalCache -= sizes.coins_db;
#      31                 :        949 :     sizes.coins = nTotalCache; // the rest goes to in-memory cache
#      32                 :        949 :     return sizes;
#      33                 :        949 : }
#      34                 :            : } // namespace node

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a