Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2011 The LevelDB Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file. See the AUTHORS file for names of contributors.4//5// Thread-safe (provides internal synchronization)7#ifndef STORAGE_LEVELDB_DB_TABLE_CACHE_H_8#define STORAGE_LEVELDB_DB_TABLE_CACHE_H_10#include <stdint.h>12#include <string>14#include "db/dbformat.h"15#include "leveldb/cache.h"16#include "leveldb/table.h"17#include "port/port.h"19namespace leveldb {21class Env;23class TableCache {24public:25TableCache(const std::string& dbname, const Options& options, int entries);26~TableCache();28// Return an iterator for the specified file number (the corresponding29// file length must be exactly "file_size" bytes). If "tableptr" is30// non-null, also sets "*tableptr" to point to the Table object31// underlying the returned iterator, or to nullptr if no Table object32// underlies the returned iterator. The returned "*tableptr" object is owned33// by the cache and should not be deleted, and is valid for as long as the34// returned iterator is live.35Iterator* NewIterator(const ReadOptions& options, uint64_t file_number,36uint64_t file_size, Table** tableptr = nullptr);38// If a seek to internal key "k" in specified file finds an entry,39// call (*handle_result)(arg, found_key, found_value).40Status Get(const ReadOptions& options, uint64_t file_number,41uint64_t file_size, const Slice& k, void* arg,42void (*handle_result)(void*, const Slice&, const Slice&));44// Evict any entry for the specified file number45void Evict(uint64_t file_number);47private:48Status FindTable(uint64_t file_number, uint64_t file_size, Cache::Handle**);50Env* const env_;51const std::string dbname_;52const Options& options_;53Cache* cache_;54};56} // namespace leveldb58#endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.