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.5#ifndef STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_6#define STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_8#include <stdint.h>10#include <vector>12#include "leveldb/slice.h"14namespace leveldb {16struct Options;18class BlockBuilder {19public:20explicit BlockBuilder(const Options* options);22BlockBuilder(const BlockBuilder&) = delete;23BlockBuilder& operator=(const BlockBuilder&) = delete;25// Reset the contents as if the BlockBuilder was just constructed.26void Reset();28// REQUIRES: Finish() has not been called since the last call to Reset().29// REQUIRES: key is larger than any previously added key30void Add(const Slice& key, const Slice& value);32// Finish building the block and return a slice that refers to the33// block contents. The returned slice will remain valid for the34// lifetime of this builder or until Reset() is called.35Slice Finish();37// Returns an estimate of the current (uncompressed) size of the block38// we are building.39size_t CurrentSizeEstimate() const;41// Return true iff no entries have been added since the last Reset()42bool empty() const { return buffer_.empty(); }44private:45const Options* options_;46std::string buffer_; // Destination buffer47std::vector<uint32_t> restarts_; // Restart points48int counter_; // Number of entries emitted since restart49bool finished_; // Has Finish() been called?50std::string last_key_;51};53} // namespace leveldb55#endif // STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_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.