Add config for geth dir path in snapshot archive #2
@ -5,6 +5,7 @@ services:
|
||||
environment:
|
||||
CERC_BSC_NETWORK: ${CERC_BSC_NETWORK:-mainnet}
|
||||
CERC_USE_SNAPSHOT: ${CERC_USE_SNAPSHOT:-false}
|
||||
CERC_SNAPSHOT_GETH_PATH: ${CERC_SNAPSHOT_GETH_PATH}
|
||||
CERC_FAST_NODE: ${CERC_FAST_NODE:-false}
|
||||
CERC_GETH_GCMODE: ${CERC_GETH_GCMODE:-full}
|
||||
CERC_GETH_VERBOSITY: ${CERC_GETH_VERBOSITY:-3}
|
||||
|
@ -28,20 +28,23 @@ ADDITIONAL_FLAGS=""
|
||||
if [ ! -d "$geth_dir" ] && [ "${CERC_USE_SNAPSHOT}" = "true" ] && [ -n "$snapshot_file" ]; then
|
||||
echo "Using snapshot $snapshot_file"
|
||||
|
||||
if [ -z "$CERC_SNAPSHOT_GETH_PATH" ]; then
|
||||
echo CERC_SNAPSHOT_GETH_PATH not set
|
||||
exit 1
|
||||
else
|
||||
# Remove any trailing / from the given path
|
||||
archive_geth_path=$(echo "$CERC_SNAPSHOT_GETH_PATH" | sed 's:/*$::')
|
||||
|
||||
# Determine strip-components count from the geth dir path
|
||||
to_strip=$(echo "$archive_geth_path" | grep -o '/' | wc -l)
|
||||
fi
|
||||
|
||||
case $snapshot_file in
|
||||
*.lz4)
|
||||
# Determine where geth dir is located
|
||||
archive_geth_path=$(lz4 -c -d $snapshot_file | tar -tf - | grep -m1 -E 'geth/?$')
|
||||
|
||||
# Determine strip-components count from the path
|
||||
to_strip=$(($(echo "$archive_geth_path" | grep -o '/' | wc -l) - 1))
|
||||
|
||||
# Extract geth data directly to destination directory
|
||||
lz4 -c -d $snapshot_file | tar -C ${DATA_DIR}/ -xvf - --strip-components=$to_strip $archive_geth_path
|
||||
;;
|
||||
*.zst)
|
||||
archive_geth_path=$(zstd -c -d $snapshot_file | tar -tf - | grep -m1 -E 'geth/?$')
|
||||
to_strip=$(($(echo "$archive_geth_path" | grep -o '/' | wc -l) - 1))
|
||||
|
||||
zstd -c -d $snapshot_file | tar -C ${DATA_DIR}/ -xvf - --strip-components=$to_strip $archive_geth_path
|
||||
;;
|
||||
*)
|
||||
|
@ -64,6 +64,10 @@ Instructions for running a BSC node
|
||||
# Requires snapshot file with extension .tar.lz4 or .tar.zst to be placed in the snapshot directory
|
||||
CERC_USE_SNAPSHOT=
|
||||
|
||||
# Path where geth dir is located in the snapshot archive
|
||||
# Required when using a snapshot; example: "server/data-seed/geth"
|
||||
CERC_SNAPSHOT_GETH_PATH=
|
||||
|
||||
# Whether to run as a fast node (true | false) (default: false)
|
||||
# Fast node does not generate trie data when syncing
|
||||
CERC_FAST_NODE=
|
||||
|
Loading…
Reference in New Issue
Block a user