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

Streamlining things a bit more.

parent 08fe2453
No related branches found
No related tags found
No related merge requests found
......@@ -4,5 +4,4 @@
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
bfaconfig node
geth attach ipc:${BFANODEDIR}/geth.ipc
geth_attach
......@@ -6,31 +6,36 @@ source ${BFAHOME}/bin/libbfa.sh || exit 1
function create
{
workdir=$( bfamktemp -p . -d )
json=$( solc --optimize --combined-json abi,bin $filename ); test $? eq 0
abi=$( echo "$json" | jq -rM ".contracts.${prefix}.abi" ); test $? eq 0
bin=$( echo "$json" | jq -rM ".contracts.${prefix}.bin" ); test $? eq 0
workdir=$( mktemp -p . -d )
cleanup "$workdir"
json=$( solc --optimize --combined-json abi,bin $filename ); test $? = 0
prefix=$( echo "$json" | jq -M '.contracts | keys | .[0]' );
abi=$( echo "$json" | jq -rM ".contracts.${prefix}.abi" ); test $? = 0
bin=$( echo "$json" | jq -rM ".contracts.${prefix}.bin" ); test $? = 0
# Save abi for future use
echo $abi > ${workdir}/abi
# We could save the bin, but we don't actually use it later, plus
# it gets stored in the blockchain
#echo $bin > ${workdir}/bin
js=$( bfamktemp )
js=$( mktemp )
cleanup "$js"
cat > $js <<EOT
var mycontract = eth.contract(JSON.parse($abi))
var mycontract = eth.contract($abi)
var transaction = mycontract.new( { from: eth.accounts[0], data: "0x${bin}", gas: 1000000 } )
var rcpt
while ( !rcpt )
{
admin.sleepBlocks( 1 );
rcpt = eth.getTransactionReceipt( transaction.transactionHash );
admin.sleepBlocks( 1 )
rcpt = eth.getTransactionReceipt( transaction.transactionHash )
}
var address = rcpt.contractAddress;
var pubcontract = mycontract.at(address);
console.log( pubcontract.address );
var address = rcpt.contractAddress
var pubcontract = mycontract.at(address)
console.log( pubcontract.address )
EOT
echo '*** Creating contract. This will take at least 16 seconds.'
outfile=$( geth_exec_js $js )
outfile=$( bfamktemp )
cleanup "$outfile"
geth_exec_js $js > $outfile
if [ ` wc -l < $outfile ` = 2 -a `tail -1 < $outfile` = "true" ]
then
addr=` head -1 < $outfile `
......
......@@ -32,25 +32,16 @@ function cleanup
rm -rf $cleanup_files
}
# calls mktemp and then cleanup - makes other scripts more compact
function bfamktemp
{
local file=$( mktemp "$@" )
cleanup $file
echo $file
}
function geth_attach
{
geth "$@" attach ipc:node1/geth.ipc
bfaconfig node
geth --cache 256 "$@" attach ipc:${BFANODEDIR}/geth.ipc
}
function geth_exec_js
{
test -r "$1"
local out=$( bfamktemp )
geth_attach --exec "loadScript(\"$1\")" > $out
echo $out
geth_attach --exec "loadScript(\"$1\")"
}
function getnetworkid
......@@ -126,6 +117,12 @@ function nodedir
fatal "$BFANODEDIR is not a directory."
test -d "${BFANODEDIR}/geth/chaindata" ||
fatal "Node is not initialised. Consider running: geth --datadir $BFANODEDIR init ${BFANETWORKDIR}/genesis.json"
# Support migrating from "former" setups
if [ -r "${BFANODEDIR}/port" -a ! -r "${BFANODEDIR}/netport" ]
then
mv "${BFANODEDIR}/port" "${BFANODEDIR}/netport"
fi
#
test -r "${BFANODEDIR}/netport" ||
echo $(( $RANDOM / 2 + 12345 )) > ${BFANODEDIR}/netport
netport=$( cat ${BFANODEDIR}/netport )
......@@ -133,6 +130,10 @@ function nodedir
test -r "${BFANODEDIR}/rpcport" ||
echo $(( $RANDOM / 2 + 12345 )) > ${BFANODEDIR}/rpcport
rpcport=$( cat ${BFANODEDIR}/rpcport )
# something uniqueish
local iphash=$( ip addr show scope global | awk '/^ *inet /{print $2}' | sed 's,/.*,,' | sha256sum )
BFAEXTRADATA="${USER}@${HOSTNAME} ${iphash}"
BFAEXTRADATA="${BFAEXTRADATA:0:32}"
}
function account
......
......@@ -84,6 +84,12 @@ bfaconfig max
--syncmode full \
--nousb \
--bootnodes "${bootnodes}" \
--txpool.nolocals \
--txpool.accountslots 128 \
--txpool.globalslots 32768 \
--txpool.accountqueue 512 \
--txpool.globalqueue 8192 \
--extradata "${BFAEXTRADATA}" \
--gcmode archive \
--cache 512 \
--verbosity 3
......
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