Load from a snapshot if provided

This commit is contained in:
Prathamesh Musale 2024-06-04 17:31:25 +05:30
parent a2abcff2a7
commit aa04f65468
2 changed files with 19 additions and 2 deletions

View File

@ -10,9 +10,11 @@ services:
- ../config/docker-entrypoint.sh:/bsc/docker-entrypoint.sh
- data:/data
- bsc:/bsc
- snapshot:/var/tmp/snapshot
ports:
- 30303:30303
- 30311:30311
- 6060:6060
- 8545:8545
- 8546:8546
healthcheck:
@ -25,3 +27,4 @@ services:
volumes:
data:
bsc:
snapshot:

View File

@ -16,9 +16,22 @@ else
unzip config.zip -d config
fi
# Use snapshot if provided
geth_dir=${DATA_DIR}/geth
snapshot_file=$((ls /var/dev/snapshot/*.tar.lz4) 2>/dev/null | head -1)
if [ ! -d "$geth_dir" ] && [ -n "$snapshot_file" ]; then
echo Using snapshot $snapshot_file
if [ "$CERC_BSC_NETWORK" = "testnet" ]; then
# snapshot dir structure for testnet different than that for mainnet
tar -C /${DATA_DIR}/ -I lz4 -xvf ${snapshot_file} --strip-components=3 server/testnet/dataseed/geth
else
tar -C /${DATA_DIR}/ -I lz4 -xvf ${snapshot_file} --strip-components=2 server/data-seed/geth
fi
fi
# Init genesis state if geth sub dir does not exist
GETH_DIR=${DATA_DIR}/geth
if [ ! -d "$GETH_DIR" ]; then
if [ ! -d "$geth_dir" ]; then
STATE_SCHEME_OPTS=""
if [ "$CERC_GETH_GCMODE" = "archive" ]; then
# Archive mode only works with state.scheme set to hash
@ -34,6 +47,7 @@ fi
exec "geth" \
--config="${BSC_CONFIG}" \
--datadir="${DATA_DIR}" \
--rpc.allow-unprotected-txs \
--http \
--http.addr="0.0.0.0" \
--http.port 8545 \