Skip to content

Commit

Permalink
Add skip_sim_create option to bypass some of the sim setup process.
Browse files Browse the repository at this point in the history
Requires both .chia and .chia_keys to be mounted into the container the proper locations with all required files, or else the simulator will not start
can help startup time at the expensive of being a bit more fragile, so its opt in only
  • Loading branch information
cmmarslender committed Feb 23, 2024
1 parent 392160e commit b1920b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea/*
sim-root
sim-keys
28 changes: 15 additions & 13 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@ if [ -z "${service##*simulator*}" ]; then
export CHIA_ROOT=/root/.chia/simulator/main
export self_hostname="0.0.0.0"

if [ -f /root/.chia/simulator/mnemonic ]; then
echo "Using provided mnemonic from /root/.chia/simulator/mnemonic"
# Use awk to trim leading and trailing whitespace while preserving internal spaces
mnemonic=$(awk '{$1=$1};1' /root/.chia/simulator/mnemonic)
if [[ ${skip_sim_create} != 'true' ]]; then
if [ -f /root/.chia/simulator/mnemonic ]; then
echo "Using provided mnemonic from /root/.chia/simulator/mnemonic"
# Use awk to trim leading and trailing whitespace while preserving internal spaces
mnemonic=$(awk '{$1=$1};1' /root/.chia/simulator/mnemonic)
fi

if [ -n "$mnemonic" ]; then # Check if mnemonic is non-empty after trimming
chia dev sim create --docker-mode --mnemonic "${mnemonic}"
else
chia dev sim create --docker-mode
fi

chia stop -d all
chia keys show --show-mnemonic-seed --json | jq -r '.keys[0].mnemonic' > /root/.chia/simulator/mnemonic
fi

if [ -n "$mnemonic" ]; then # Check if mnemonic is non-empty after trimming
chia dev sim create --docker-mode --mnemonic "${mnemonic}"
else
chia dev sim create --docker-mode
fi

chia stop -d all
chia keys show --show-mnemonic-seed --json | jq -r '.keys[0].mnemonic' > /root/.chia/simulator/mnemonic
fi

# shellcheck disable=SC2086
Expand Down

0 comments on commit b1920b0

Please sign in to comment.