Add a config option for testnet

This commit is contained in:
Prathamesh Musale 2024-06-04 12:40:03 +05:30
parent 1bdff2b22e
commit 372cace05f
2 changed files with 19 additions and 6 deletions

View File

@ -2,7 +2,8 @@ services:
bsc:
image: ghcr.io/bnb-chain/bsc:1.4.8
restart: unless-stopped
# environment:
environment:
CERC_BSC_NETWORK: ${CERC_BSC_NETWORK:-mainnet}
volumes:
- ../config/docker-entrypoint.sh:/bsc/docker-entrypoint.sh
- data:/data

View File

@ -1,18 +1,18 @@
#!/bin/bash
set -e
echo "Setting up BSC $CERC_BSC_NETWORK"
BSC_CONFIG=${BSC_HOME}/config/config.toml
BSC_GENESIS=${BSC_HOME}/config/genesis.json
# TODO: Check for testnet flag
if [ -f "$BSC_CONFIG" ]; then
echo "Config file found at $BSC_CONFIG"
else
echo "Config file not found at $BSC_CONFIG, downloading..."
echo "Config file not found at $BSC_CONFIG, downloading config for $CERC_BSC_NETWORK..."
# Download and unzip the config files
wget -O config.zip $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep mainnet |cut -d\" -f4)
wget -O config.zip $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep $CERC_BSC_NETWORK |cut -d\" -f4)
unzip config.zip -d config
fi
@ -25,4 +25,16 @@ if [ ! -d "$GETH_DIR" ]; then
fi
# TODO: Check for archive mode flag
exec "geth" "--config" ${BSC_CONFIG} "--datadir" ${DATA_DIR} "$@"
exec "geth" \
--config="${BSC_CONFIG}" \
--datadir="${DATA_DIR}" \
--http \
--http.addr="0.0.0.0" \
--http.port 8545 \
--http.vhosts="*" \
--http.corsdomain="*" \
--ws \
--ws.addr="0.0.0.0" \
--ws.port 8546 \
--ws.origins="*" \
"$@"