Skip to content
Snippets Groups Projects
Commit 33f2043e authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Move loop control into libbfa.sh itself

parent b83efbd6
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# Robert Martin-Legene <robert@nic.ar>
# Don't let us call ourselves
if [ -n "$LOOPCONTROL_GENESISCREATE" ]
then
export LOOPCONTROL_GENESISCREATE=1
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
if [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ]
then
echo "Node is not initialised. Initialising with genesis."
geth --cache 0 --datadir "${BFANODEDIR}" --networkid ${BFANETWORKID} init "${BFANETWORKDIR}/genesis.json"
fi
if [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ]
then
echo "Node is not initialised. Initialising with genesis."
geth --cache 0 --datadir "${BFANODEDIR}" --networkid ${BFANETWORKID} init "${BFANETWORKDIR}/genesis.json"
fi
unset LOOPCONTROL_GENESISCREATE
......@@ -157,39 +157,49 @@ function contractSendTx
echo "contract.${func}.sendTransaction(${args} {from: eth.accounts[0], gas: 1000000} )"
}
###############
# bfainit #
test -n "${BFAHOME}" -a \
-d "${BFAHOME}" ||
fatal "\$BFAHOME in your environment must point to a directory."
#
# BFANETWORKID
test -n "${BFANETWORKID}" || BFANETWORKID=47525974938
#
# BFANETWORKDIR
test -n "${BFANETWORKDIR}" || BFANETWORKDIR="${BFAHOME}/network"
mkdir -p "${BFANETWORKDIR}"
test -d "${BFANETWORKDIR}" || fatal "\$BFANETWORKDIR (\"${BFANETWORKDIR}\") not found."
#
# BFANODEDIR
test -n "$BFANODEDIR" || BFANODEDIR="${BFANETWORKDIR}/node"
if [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ]
function bfainit
{
###############
# bfainit #
test -n "${BFAHOME}" -a \
-d "${BFAHOME}" ||
fatal "\$BFAHOME in your environment must point to a directory."
#
# BFANETWORKID
test -n "${BFANETWORKID}" || BFANETWORKID=47525974938
#
# BFANETWORKDIR
test -n "${BFANETWORKDIR}" || BFANETWORKDIR="${BFAHOME}/network"
mkdir -p "${BFANETWORKDIR}"
test -d "${BFANETWORKDIR}" || fatal "\$BFANETWORKDIR (\"${BFANETWORKDIR}\") not found."
#
# BFANODEDIR
test -n "$BFANODEDIR" || BFANODEDIR="${BFANETWORKDIR}/node"
if [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ]
then
generate-genesis-block.sh
fi
#
# Default to IPC connections, because we have more geth modules available.
true ${BFASOCKETTYPE:=ipc}
case "${BFASOCKETTYPE}" in
ipc)
true ${BFASOCKETURL:="ipc:${BFANODEDIR}/geth.ipc"}
;;
http)
true ${BFASOCKETURL:="http://127.0.0.1:8545"}
;;
ws)
true ${BFASOCKETURL:="ws://127.0.0.1:8546"}
;;
*)
echo "Unknown socket type. Supported types are http, ws, ipc" >&2
exit 1
esac
}
if [ -z "$SOURCED_BFAINIT_SH" ]
then
generate-genesis-block.sh
SOURCED_BFAINIT_SH=yes
bfainit
fi
true ${BFASOCKETTYPE:=ipc}
case "${BFASOCKETTYPE}" in
ipc)
test ${BFASOCKETURL:="ipc:${BFANODEDIR}/geth.ipc"}
;;
http)
test ${BFASOCKETURL:="http://127.0.0.1:8545"}
;;
ws)
test ${BFASOCKETURL:="ws://127.0.0.1:8546"}
;;
*)
echo "Unknown socket type. Supported types are http, ws, ipc" >&2
exit 1
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment