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#include "leveldb/iterator.h"7namespace leveldb {9Iterator::Iterator() {10cleanup_head_.function = nullptr;11cleanup_head_.next = nullptr;12}14Iterator::~Iterator() {15if (!cleanup_head_.IsEmpty()) {16cleanup_head_.Run();17for (CleanupNode* node = cleanup_head_.next; node != nullptr;) {18node->Run();19CleanupNode* next_node = node->next;20delete node;21node = next_node;22}23}24}26void Iterator::RegisterCleanup(CleanupFunction func, void* arg1, void* arg2) {27assert(func != nullptr);28CleanupNode* node;29if (cleanup_head_.IsEmpty()) {30node = &cleanup_head_;31} else {32node = new CleanupNode();33node->next = cleanup_head_.next;34cleanup_head_.next = node;35}36node->function = func;37node->arg1 = arg1;38node->arg2 = arg2;39}41namespace {43class EmptyIterator : public Iterator {44public:45EmptyIterator(const Status& s) : status_(s) {}46~EmptyIterator() override = default;48bool Valid() const override { return false; }49void Seek(const Slice& target) override {}50void SeekToFirst() override {}51void SeekToLast() override {}52void Next() override { assert(false); }53void Prev() override { assert(false); }54Slice key() const override {55assert(false);56return Slice();57}58Slice value() const override {59assert(false);60return Slice();61}62Status status() const override { return status_; }64private:65Status status_;66};68} // anonymous namespace70Iterator* NewEmptyIterator() { return new EmptyIterator(Status::OK()); }72Iterator* NewErrorIterator(const Status& status) {73return new EmptyIterator(status);74}76} // namespace leveldb
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.