Skip to content

Commit

Permalink
mechanism to have same peerId for node and go-fula
Browse files Browse the repository at this point in the history
adding mechanism to create the node-key from the identity of go-fula
  • Loading branch information
ehsan6sha committed Nov 10, 2023
1 parent 32a542f commit e41254a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 11 additions & 0 deletions docker/go-fula/go-fula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ wap_pid=$!
while true; do
if check_internet && check_files_exist; then
echo "Internet connected and necessary files exist. Running /app."
node_key_file="/internal/.secrets/node_key.txt"
mkdir -p /internal/.secrets
# Generate the node key
new_key=$(/app --generateNodeKey)
# Check if the node_key file exists and has different content
if [ ! -f "$node_key_file" ] || [ "$new_key" != "$(cat $node_key_file)" ]; then
echo "$new_key" > "$node_key_file"
echo "Node key saved to $node_key_file"
else
echo "Node key file already exists and is up to date."
fi

/app --config /internal/config.yaml
break
Expand Down
7 changes: 4 additions & 3 deletions docker/sugarfunge-node/run_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ while ! check_writable; do
sleep 5
done

# Wait indefinitely until the password file and /uniondrive folder are available
while [ ! -f "/internal/box_props.json" ] || [ ! -d "/uniondrive" ]; do
# Wait indefinitely until the password file and /uniondrive folder are available from go-fule docker
while [ ! -f "/internal/box_props.json" ] || [ ! -d "/uniondrive" ] || [ ! -f "/internal/.secrets/node_key.txt" ]; do
sleep 3
[ ! -f "/internal/box_props.json" ] && echo "Waiting for /internal/box_props.json to become available..."
[ ! -d "/uniondrive" ] && echo "Waiting for /uniondrive to become available..."
[ ! -f "/internal/.secrets/node_key.txt" ] && echo "Waiting for /internal/.secrets/node_key.txt to become available..."
done

# Read blox_seed from JSON file
Expand All @@ -61,7 +62,7 @@ fi

#save the node key
# Generate the node key only under specific conditions
if [ ! -f "/internal/.secrets/node_key.txt" ] || [ "$blox_seed_changed" -ne 0 ]; then
if [ ! -f "/internal/.secrets/node_key.txt" ]; then
output=$(/sugarfunge-node key generate-node-key 2>&1)
echo "$output"
node_key=$(echo "$output" | tr ' ' '\n' | tail -n 1)
Expand Down

0 comments on commit e41254a

Please sign in to comment.