Skip to content

Commit 5eb52b5

Browse files
committed
Added --no-purge flag to scripts/localnet.sh to be able to save state when restarting a script.
1 parent 6c861f3 commit 5eb52b5

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

scripts/localnet.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
#!/bin/bash
22

3+
# Check if `--no-purge` passed as a parameter
4+
NO_PURGE=0
5+
for arg in "$@"; do
6+
if [ "$arg" = "--no-purge" ]; then
7+
NO_PURGE=1
8+
break
9+
fi
10+
done
11+
312
# Determine the directory this script resides in. This allows invoking it from any location.
413
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
514

@@ -32,10 +41,14 @@ echo "*** Building chainspec..."
3241
"$BASE_DIR/target/release/node-subtensor" build-spec --disable-default-bootnode --raw --chain $CHAIN >$FULL_PATH
3342
echo "*** Chainspec built and output to file"
3443

35-
echo "*** Purging previous state..."
36-
"$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path /tmp/bob --chain="$FULL_PATH" >/dev/null 2>&1
37-
"$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path /tmp/alice --chain="$FULL_PATH" >/dev/null 2>&1
38-
echo "*** Previous chainstate purged"
44+
if [ $NO_PURGE -eq 1 ]; then
45+
echo "*** Purging previous state skipped..."
46+
else
47+
echo "*** Purging previous state..."
48+
"$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path /tmp/bob --chain="$FULL_PATH" >/dev/null 2>&1
49+
"$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path /tmp/alice --chain="$FULL_PATH" >/dev/null 2>&1
50+
echo "*** Previous chainstate purged"
51+
fi
3952

4053
echo "*** Starting localnet nodes..."
4154
alice_start=(

0 commit comments

Comments
 (0)