Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/run-network
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ if ! test -e /data/db/protocolMagicId; then
esac
if [[ ${__skip} != true ]]; then
export GENESIS_VERIFICATION_KEY=$(</opt/cardano/config/${NETWORK}/genesis.vkey)
export ANCILLARY_VERIFICATION_KEY=$(</opt/cardano/config/${NETWORK}/ancillary.vkey)
export AGGREGATOR_ENDPOINT=https://aggregator.${__path}.api.mithril.network/aggregator
export SNAPSHOT_DIGEST=$(mithril-client cardano-db snapshot list --json | jq -r '.[0].digest')
mkdir -p /data
cd /data
echo "Starting: /usr/local/bin/mithril-client cardano-db download ${SNAPSHOT_DIGEST}"
echo "Starting: /usr/local/bin/mithril-client cardano-db download ${SNAPSHOT_DIGEST} ${ANCILLARY_VERIFICATION_KEY:+--include-ancillary}"
# Handle SIGTERM during initial sync
trap 'kill -TERM $(pidof mithril-client)' TERM
# Run mithril-client in the background so we can capture the PID and wait
mithril-client cardano-db download ${SNAPSHOT_DIGEST} &
mithril-client cardano-db download "${SNAPSHOT_DIGEST}" ${ANCILLARY_VERIFICATION_KEY:+--include-ancillary} &
_mithril_pid=$!
wait $_mithril_pid || exit $?
# Reset signal handler and wait again (to avoid race condition)
Expand Down
11 changes: 8 additions & 3 deletions bin/run-node
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ case ${CARDANO_NETWORK} in
esac
AGGREGATOR_ENDPOINT=${AGGREGATOR_ENDPOINT:-https://aggregator.${__path}.api.mithril.network/aggregator}
GENESIS_VERIFICATION_KEY_PATH=${GENESIS_VERIFICATION_KEY_PATH:-${CARDANO_CONFIG_BASE}/${CARDANO_NETWORK}/genesis.vkey}
ANCILLARY_VERIFICATION_KEY_PATH=${ANCILLARY_VERIFICATION_KEY_PATH:-${CARDANO_CONFIG_BASE}/${CARDANO_NETWORK}/ancillary.vkey}
if [[ -z $GENESIS_VERIFICATION_KEY && -f $GENESIS_VERIFICATION_KEY_PATH ]]; then
GENESIS_VERIFICATION_KEY=$(<${GENESIS_VERIFICATION_KEY_PATH})
fi
if [[ -z $ANCILLARY_VERIFICATION_KEY && -f $ANCILLARY_VERIFICATION_KEY_PATH ]]; then
ANCILLARY_VERIFICATION_KEY=$(<${ANCILLARY_VERIFICATION_KEY_PATH})
fi
SNAPSHOT_DIGEST=${SNAPSHOT_DIGEST:-latest}
RESTORE_SNAPSHOT=${RESTORE_SNAPSHOT:-true}

Expand Down Expand Up @@ -112,6 +116,7 @@ fi

echo AGGREGATOR_ENDPOINT=${AGGREGATOR_ENDPOINT}
echo GENESIS_VERIFICATION_KEY=${GENESIS_VERIFICATION_KEY}
echo ANCILLARY_VERIFICATION_KEY=${ANCILLARY_VERIFICATION_KEY}
echo SNAPSHOT_DIGEST=${SNAPSHOT_DIGEST}
echo RESTORE_SNAPSHOT=${RESTORE_SNAPSHOT}

Expand All @@ -123,15 +128,15 @@ if ! test -e ${CARDANO_DATABASE_PATH}/protocolMagicId; then
if [[ ${RESTORE_SNAPSHOT} == true ]]; then
mkdir -p $(dirname ${CARDANO_DATABASE_PATH})
cd $(dirname ${CARDANO_DATABASE_PATH})
export AGGREGATOR_ENDPOINT GENESIS_VERIFICATION_KEY SNAPSHOT_DIGEST
echo "Starting: /usr/local/bin/mithril-client cardano-db download ${SNAPSHOT_DIGEST}"
export AGGREGATOR_ENDPOINT GENESIS_VERIFICATION_KEY ANCILLARY_VERIFICATION_KEY SNAPSHOT_DIGEST
echo "Starting: /usr/local/bin/mithril-client cardano-db download ${SNAPSHOT_DIGEST} ${ANCILLARY_VERIFICATION_KEY:+--include-ancillary}"
if [[ $(cd ${CARDANO_DATABASE_PATH} 2>/dev/null; pwd -P) != $(pwd -P)/db ]]; then
rm -rf db/*
fi
# Handle SIGTERM during initial sync
trap 'kill -TERM $(pidof mithril-client)' TERM
# Run mithril-client in the background so we can capture the PID and wait
mithril-client cardano-db download ${SNAPSHOT_DIGEST} &
mithril-client cardano-db download "${SNAPSHOT_DIGEST}" ${ANCILLARY_VERIFICATION_KEY:+--include-ancillary} &
_mithril_pid=$!
wait $_mithril_pid || exit $?
# Reset signal handler and wait again (to avoid race condition)
Expand Down
Loading