Skip to content

Commit

Permalink
conditional peers
Browse files Browse the repository at this point in the history
  • Loading branch information
asmodat committed Apr 7, 2021
1 parent bff072e commit 09109a2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
10 changes: 8 additions & 2 deletions workstation/containers/start-priv-sentry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ cp -a -v -f "$SEEDS_PATH" "$COMMON_SEEDS_PATH"
# cleanup
rm -f -v "$COMMON_LOGS/start.log" "$COMMON_PATH/executed" "$HALT_FILE"

if [ "${EXTERNAL_SYNC,,}" == "true" ] ; then
CFG_persistent_peers="tcp://$SENTRY_SEED"
if [ "${EXTERNAL_SYNC,,}" == "true" ] ; then
if (! $(isFileEmpty $PUBLIC_SEEDS )) || (! $(isFileEmpty $PUBLIC_PEERS )) ; then
echo "INFO: Node will sync from the public sentry..."
CFG_persistent_peers="tcp://$SENTRY_SEED"
else
echo "INFO: Node will sync blocks from its own seed list..."
CFG_persistent_peers=""
fi
else
CFG_persistent_peers="tcp://$VALIDATOR_SEED"
fi
Expand Down
8 changes: 6 additions & 2 deletions workstation/containers/start-sentry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ cp -a -v -f "$SEEDS_PATH" "$COMMON_SEEDS_PATH"
rm -f -v "$COMMON_LOGS/start.log" "$COMMON_PATH/executed" "$HALT_FILE"

if [ "${EXTERNAL_SYNC,,}" == "true" ] ; then
CFG_persistent_peers="tcp://$PRIV_SENTRY_SEED"
CFG_persistent_peers=""
if (! $(isFileEmpty $PRIVATE_SEEDS )) || (! $(isFileEmpty $PRIVATE_PEERS )) ; then
echo "INFO: Node will sync from the private sentry..."
CFG_persistent_peers="tcp://$PRIV_SENTRY_SEED"
else
CFG_persistent_peers=""
fi
else
CFG_persistent_peers="tcp://$VALIDATOR_SEED"
fi
Expand Down
10 changes: 5 additions & 5 deletions workstation/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ if [ "${INFRA_MODE,,}" == "local" ] ; then
$KIRA_MANAGER/containers/start-interx.sh
$KIRA_MANAGER/containers/start-frontend.sh
elif [ "${INFRA_MODE,,}" == "sentry" ] ; then
if [[ ! -z $(grep '[^[:space:]]' $PUBLIC_SEEDS) ]] || [[ ! -z $(grep '[^[:space:]]' $PUBLIC_PEERS) ]] ; then
if (! $(isFileEmpty $PUBLIC_SEEDS )) || (! $(isFileEmpty $PUBLIC_PEERS )) ; then
# save snapshot from sentry first
$KIRA_MANAGER/containers/start-sentry.sh "true"
$KIRA_MANAGER/containers/start-priv-sentry.sh
elif [[ ! -z $(grep '[^[:space:]]' $PRIVATE_SEEDS) ]] || [[ ! -z $(grep '[^[:space:]]' $PRIVATE_PEERS) ]] ; then
elif (! $(isFileEmpty $PRIVATE_SEEDS )) || (! $(isFileEmpty $PRIVATE_PEERS )) ; then
# save snapshot from private sentry first
$KIRA_MANAGER/containers/start-priv-sentry.sh "true"
$KIRA_MANAGER/containers/start-sentry.sh
Expand All @@ -175,12 +175,12 @@ elif [ "${INFRA_MODE,,}" == "validator" ] ; then
$KIRA_MANAGER/containers/start-sentry.sh
$KIRA_MANAGER/containers/start-priv-sentry.sh
$KIRA_MANAGER/containers/start-interx.sh
else
if [[ ! -z $(grep '[^[:space:]]' $PUBLIC_SEEDS) ]] || [[ ! -z $(grep '[^[:space:]]' $PUBLIC_PEERS) ]] ; then
else
if (! $(isFileEmpty $PUBLIC_SEEDS )) || (! $(isFileEmpty $PUBLIC_PEERS )) ; then
# save snapshot from sentry first
$KIRA_MANAGER/containers/start-sentry.sh "true"
$KIRA_MANAGER/containers/start-priv-sentry.sh
elif [[ ! -z $(grep '[^[:space:]]' $PRIVATE_SEEDS) ]] || [[ ! -z $(grep '[^[:space:]]' $PRIVATE_PEERS) ]] ; then
elif (! $(isFileEmpty $PRIVATE_SEEDS )) || (! $(isFileEmpty $PRIVATE_PEERS )) ; then
# save snapshot from private sentry first
$KIRA_MANAGER/containers/start-priv-sentry.sh "true"
$KIRA_MANAGER/containers/start-sentry.sh
Expand Down
10 changes: 10 additions & 0 deletions workstation/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ function isNaturalNumber() {
fi
}

function isFileEmpty() {
if [ -z "$1" ] || [ ! -f "$1" ] ; then echo "true" ; else
if [[ ! -z $(grep '[^[:space:]]' $1) ]] ; then
echo "true"
else
echo "false"
fi
fi
}

displayAlign() {
align=$1
width=$2
Expand Down

0 comments on commit 09109a2

Please sign in to comment.