mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 19:37:27 -03:00
contrib: add script dump_to_sqlite.sh for direct SQLite3 UTXO dump
This commit is contained in:
parent
15e917c930
commit
59df8480be
2 changed files with 36 additions and 0 deletions
|
@ -51,3 +51,7 @@ UTXO Set Tools
|
||||||
This script converts a compact-serialized UTXO set (as generated by Bitcoin Core with `dumptxoutset`)
|
This script converts a compact-serialized UTXO set (as generated by Bitcoin Core with `dumptxoutset`)
|
||||||
to a SQLite3 database. For more details like e.g. the created table name and schema, refer to the
|
to a SQLite3 database. For more details like e.g. the created table name and schema, refer to the
|
||||||
module docstring on top of the script, which is also contained in the command's `--help` output.
|
module docstring on top of the script, which is also contained in the command's `--help` output.
|
||||||
|
|
||||||
|
### [Dump-to-SQLite](/contrib/utxo-tools/dump_to_sqlite.sh) ###
|
||||||
|
This script creates an UTXO set dump in SQLite3 format on the fly from a running bitcoind instance,
|
||||||
|
i.e. with the intermediate step of storing the compact-serialized UTXO set on disk is skipped.
|
||||||
|
|
32
contrib/utxo-tools/dump_to_sqlite.sh
Executable file
32
contrib/utxo-tools/dump_to_sqlite.sh
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright (c) 2024-present The Bitcoin Core developers
|
||||||
|
# Distributed under the MIT software license, see the accompanying
|
||||||
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
export LC_ALL=C
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $# -ne 2 ]; then
|
||||||
|
echo "Usage: $0 <bitcoin-cli-path> <output-file>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BITCOIN_CLI=$1
|
||||||
|
OUTPUT_FILE=$2
|
||||||
|
UTXO_TO_SQLITE=$(dirname "$0")/utxo_to_sqlite.py
|
||||||
|
|
||||||
|
# create named pipe in unique temporary folder
|
||||||
|
TEMPPATH=$(mktemp -d)
|
||||||
|
FIFOPATH=$TEMPPATH/utxos.fifo
|
||||||
|
mkfifo "$FIFOPATH"
|
||||||
|
|
||||||
|
# start dumping UTXO set to the pipe in background
|
||||||
|
$BITCOIN_CLI dumptxoutset "$FIFOPATH" latest &
|
||||||
|
BITCOIN_CLI_PID=$!
|
||||||
|
|
||||||
|
# start UTXO to SQLite conversion tool, reading from pipe
|
||||||
|
$UTXO_TO_SQLITE "$FIFOPATH" "$OUTPUT_FILE"
|
||||||
|
|
||||||
|
# wait and cleanup
|
||||||
|
wait $BITCOIN_CLI_PID
|
||||||
|
rm -r "$TEMPPATH"
|
Loading…
Reference in a new issue