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 #!/bin/bash
# Robert Martin-Legene <robert@nic.ar> # Robert Martin-Legene <robert@nic.ar>
# Don't let us call ourselves if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
if [ -n "$LOOPCONTROL_GENESISCREATE" ] source ${BFAHOME}/bin/libbfa.sh || exit 1
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 [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ] if [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ]
then then
echo "Node is not initialised. Initialising with genesis." echo "Node is not initialised. Initialising with genesis."
geth --cache 0 --datadir "${BFANODEDIR}" --networkid ${BFANETWORKID} init "${BFANETWORKDIR}/genesis.json" geth --cache 0 --datadir "${BFANODEDIR}" --networkid ${BFANETWORKID} init "${BFANETWORKDIR}/genesis.json"
fi
fi fi
unset LOOPCONTROL_GENESISCREATE
...@@ -157,39 +157,49 @@ function contractSendTx ...@@ -157,39 +157,49 @@ function contractSendTx
echo "contract.${func}.sendTransaction(${args} {from: eth.accounts[0], gas: 1000000} )" echo "contract.${func}.sendTransaction(${args} {from: eth.accounts[0], gas: 1000000} )"
} }
############### function bfainit
# bfainit # {
test -n "${BFAHOME}" -a \ ###############
-d "${BFAHOME}" || # bfainit #
fatal "\$BFAHOME in your environment must point to a directory." test -n "${BFAHOME}" -a \
# -d "${BFAHOME}" ||
# BFANETWORKID fatal "\$BFAHOME in your environment must point to a directory."
test -n "${BFANETWORKID}" || BFANETWORKID=47525974938 #
# # BFANETWORKID
# BFANETWORKDIR test -n "${BFANETWORKID}" || BFANETWORKID=47525974938
test -n "${BFANETWORKDIR}" || BFANETWORKDIR="${BFAHOME}/network" #
mkdir -p "${BFANETWORKDIR}" # BFANETWORKDIR
test -d "${BFANETWORKDIR}" || fatal "\$BFANETWORKDIR (\"${BFANETWORKDIR}\") not found." test -n "${BFANETWORKDIR}" || BFANETWORKDIR="${BFAHOME}/network"
# mkdir -p "${BFANETWORKDIR}"
# BFANODEDIR test -d "${BFANETWORKDIR}" || fatal "\$BFANETWORKDIR (\"${BFANETWORKDIR}\") not found."
test -n "$BFANODEDIR" || BFANODEDIR="${BFANETWORKDIR}/node" #
if [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ] # 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 then
generate-genesis-block.sh SOURCED_BFAINIT_SH=yes
bfainit
fi 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