Skip to content

Commit

Permalink
fix: update subnet assignment math
Browse files Browse the repository at this point in the history
  • Loading branch information
anomit committed Oct 9, 2024
1 parent 64b5491 commit 8e83e2d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ fi

source .env
export DOCKER_NETWORK_NAME="snapshotter-lite-v2-${SLOT_ID}"
SUBNET_SECOND_OCTET=$((16 + (SLOT_ID / 65536) % 16))
SUBNET_THIRD_OCTET=$(((SLOT_ID / 256) % 256))
SUBNET_SECOND_OCTET=$((16 + (SLOT_ID / 256) % 240))
SUBNET_THIRD_OCTET=$((SLOT_ID % 256))
# Always use 0 for the fourth octet to ensure a valid subnet
export DOCKER_NETWORK_SUBNET="172.${SUBNET_SECOND_OCTET}.${SUBNET_THIRD_OCTET}.0/24"

Expand All @@ -60,8 +60,8 @@ test_subnet_calculation() {
local expected_third_octet=$3

SLOT_ID=$test_slot_id
SUBNET_SECOND_OCTET=$((16 + (SLOT_ID / 65536) % 16))
SUBNET_THIRD_OCTET=$(((SLOT_ID / 256) % 256))
SUBNET_SECOND_OCTET=$((16 + (SLOT_ID / 256) % 240))
SUBNET_THIRD_OCTET=$((SLOT_ID % 256))
SUBNET="172.${SUBNET_SECOND_OCTET}.${SUBNET_THIRD_OCTET}.0/24"

if [ $SUBNET_SECOND_OCTET -eq $expected_second_octet ] &&
Expand Down

0 comments on commit 8e83e2d

Please sign in to comment.