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) 2012 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 <stdio.h>7#include "leveldb/dumpfile.h"8#include "leveldb/env.h"9#include "leveldb/status.h"11namespace leveldb {12namespace {14class StdoutPrinter : public WritableFile {15public:16Status Append(const Slice& data) override {17fwrite(data.data(), 1, data.size(), stdout);18return Status::OK();19}20Status Close() override { return Status::OK(); }21Status Flush() override { return Status::OK(); }22Status Sync() override { return Status::OK(); }23std::string GetName() const override { return "[stdout]"; }24};26bool HandleDumpCommand(Env* env, char** files, int num) {27StdoutPrinter printer;28bool ok = true;29for (int i = 0; i < num; i++) {30Status s = DumpFile(env, files[i], &printer);31if (!s.ok()) {32fprintf(stderr, "%s\n", s.ToString().c_str());33ok = false;34}35}36return ok;37}39} // namespace40} // namespace leveldb42static void Usage() {43fprintf(stderr,44"Usage: leveldbutil command...\n"45" dump files... -- dump contents of specified files\n");46}48int main(int argc, char** argv) {49leveldb::Env* env = leveldb::Env::Default();50bool ok = true;51if (argc < 2) {52Usage();53ok = false;54} else {55std::string command = argv[1];56if (command == "dump") {57ok = leveldb::HandleDumpCommand(env, argv + 2, argc - 2);58} else {59Usage();60ok = false;61}62}63return (ok ? 0 : 1);64}
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.