diff --git a/bin/start.sh b/bin/start.sh index c475e22b34d69f64404de648ecc9470ce8837314..9a71f30c81e2bc24110621eeccf3493a6010cd6e 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -11,65 +11,73 @@ bootnodes="enode://${bootnodeid}@[$bootnodev6]:${bootnodeport},enode://${bootnod bfaconfig max -accts= -for file in ${BFANODEDIR}/keystore/*--* -do +function startgeth +{ + while : + do + echo + echo '***' + echo + set -x + geth \ + --datadir ${BFANODEDIR} \ + $( accountlist ) \ + $( miner ) \ + --networkid $BFANETWORKID \ + --rpc \ + --rpcport $rpcport \ + --rpcapi "eth,net,web3,admin,clique,miner" \ + --port $netport \ + --syncmode full \ + --nousb \ + --bootnodes "${bootnodes}" \ + --txpool.nolocals \ + --txpool.accountslots 128 \ + --txpool.globalslots 32768 \ + --txpool.accountqueue 512 \ + --txpool.globalqueue 8192 \ + --extradata "${BFAEXTRADATA}" \ + --cache 512 \ + --verbosity 3 & + set +x + echo $! > ${BFANODEDIR}/geth.pid + wait + sleep 60 + done +} + +function accountlist +{ + local accts= + for file in ${BFANODEDIR}/keystore/*--* + do if [ -r "$file" ] then - acct=$( echo $file | sed 's/^.*--//' ) - accts="${accts},${acct}" + acct=$( echo $file | sed 's/^.*--//' ) + accts="${accts},${acct}" fi -done -# also, strip first comma -accts="--unlock ${accts:1}" + done + # strip first comma + echo "--password /dev/null --unlock ${accts:1}" +} + # touch the "miner" file if you are authorized to mine # If you don't want to restart after touching the file, # you can use attach.sh and issue the command: # miner.start() -miner= -if [ -e "${BFANODEDIR}/miner" ] -then - miner="--miner" -fi -( - echo - echo '***' - echo - # Start the miner. - test -e "${BFANODEDIR}/geth.pid" || - touch ${BFANODEDIR}/geth.pid - set -x - flock --nonblock --exclusive ${BFANODEDIR}/geth.pid \ - geth \ - --datadir ${BFANODEDIR} \ - $accts \ - --password /dev/null \ - $miner \ - --networkid $BFANETWORKID \ - --rpc \ - --rpcport $rpcport \ - --rpcapi "eth,net,web3,admin,clique,miner" \ - --port $netport \ - --syncmode full \ - --nousb \ - --bootnodes "${bootnodes}" \ - --txpool.nolocals \ - --txpool.accountslots 128 \ - --txpool.globalslots 32768 \ - --txpool.accountqueue 512 \ - --txpool.globalqueue 8192 \ - --extradata "${BFAEXTRADATA}" \ - --cache 512 \ - --verbosity 3 & - set +x - pid_flock=$! - pid_geth=$( ps -eo ppid,pid | awk "/$pid_flock /{print \$2}" | tail -1 ) - if [ -n "$pid_geth" ] - then - echo $pid_geth > ${BFANODEDIR}/geth.pid - fi -) 2>&1 | +function miner +{ + if [ -e "${BFANODEDIR}/miner" ] + then + echo -- "--miner" + fi +} + +# Start the miner. +test -e "${BFANODEDIR}/geth.pid" || + touch ${BFANODEDIR}/geth.pid +flock --nonblock --exclusive ${BFANODEDIR}/geth.pid startgeth 2>&1 | ${BFAHOME}/bin/log.sh ${BFANODEDIR}/log & if [ -t 1 ] then