Merge pull request #31 from ShyftNetwork/greg/cli

Greg/cli
This commit is contained in:
Tim Williams 2018-06-04 10:41:20 -04:00 committed by GitHub
commit d24335048a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 98 additions and 14 deletions

View file

@ -277,6 +277,16 @@ Which will start mining blocks and transactions on a single CPU thread, creditin
the account specified by `--etherbase`. You can further tune the mining by changing the default gas the account specified by `--etherbase`. You can further tune the mining by changing the default gas
limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`). limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`).
## SHYFT NOTES
#### CLI
Run `./shyft-geth.sh` with one of the following flags:
- `--setup` - Setups postgres and the shyft chain db.
- `--start` - Starts geth.
- `--reset` - Drops postgress and chain db, and reinstantiates both.
- `--js [web3 filename]` - Executes web3 calls with a passed file name. If the file name is `sendTransactions.js`, `./shyft-geth.sh --js sendTransactions`.
## Contribution ## Contribution
Thank you for considering to help out with the source code! We welcome contributions from Thank you for considering to help out with the source code! We welcome contributions from

View file

@ -45,7 +45,7 @@ HTTPHost = "127.0.0.1"
HTTPPort = 8545 HTTPPort = 8545
HTTPCors = ["*"] HTTPCors = ["*"]
HTTPVirtualHosts = ["localhost"] HTTPVirtualHosts = ["localhost"]
HTTPModules = ["net", "web3", "eth", "shh"] HTTPModules = ["net", "web3", "eth", "shh", "admin", "debug"]
WSPort = 8546 WSPort = 8546
WSModules = ["net", "web3", "eth", "shh"] WSModules = ["net", "web3", "eth", "shh"]

View file

@ -42,8 +42,3 @@ CREATE TABLE IF NOT EXISTS accounts (
CREATE TABLE IF NOT EXISTS contracts ( CREATE TABLE IF NOT EXISTS contracts (
txHash text txHash text
); );
CREATE TABLE IF NOT EXISTS mined_blocks (
blockNumber bigint,
addr text
);

View file

@ -2,4 +2,3 @@ DROP TABLE txs;
DROP TABLE blocks; DROP TABLE blocks;
DROP TABLE accounts; DROP TABLE accounts;
DROP TABLE contracts; DROP TABLE contracts;
DROP TABLE mined_blocks;

View file

@ -1 +1,4 @@
#!/bin/bash
cd ./shyft-cli/postgres_setup
psql -U postgres -d shyftdb -f drop_tables.psql psql -U postgres -d shyftdb -f drop_tables.psql

View file

@ -1 +1,4 @@
#!/bin/bash
cd ./shyft-cli/postgres_setup
psql -U postgres -d shyftdb -f create_tables.psql psql -U postgres -d shyftdb -f create_tables.psql

View file

@ -0,0 +1,4 @@
#!/bin/bash
cd ./shyft-cli/postgres_setup
psql -U postgres -f create_shyftdb.psql

View file

@ -1,4 +1,4 @@
file=$1 file=$1
echo $file echo Executing "${file}"...
runthing="./build/bin/geth --exec 'loadScript(\""$file"\")' attach http://127.0.0.1:8545" runthing="./build/bin/geth --exec 'loadScript(\""$file"\")' attach http://127.0.0.1:8545"
eval $runthing eval $runthing

17
shyft-cli/setup.sh Normal file
View file

@ -0,0 +1,17 @@
#!/bin/bash
if ! psql -lqt | cut -d \| -f 1 | grep -qw shyftdb; then # Check if db is instantiated
echo Creating postgres db...
sh ./shyft-cli/postgres_setup/initdb.sh && # Init DB
echo Successfully created postgres db! &&
sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables
sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data
sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth
else
echo Postgres DB found!
sh ./shyft-cli/postgres_setup/drop_tables.sh && # Drop tables
sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables
sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data
sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth
fi

View file

@ -0,0 +1,12 @@
#!/bin/bash
if ! psql -lqt | cut -d \| -f 1 | grep -qw shyftdb; then
echo Creating postgres db...
sh ./shyft-cli/postgres_setup/initdb.sh &&
echo Successfully created postgres db!
fi
sh ./shyft-cli/postgres_setup/drop_tables.sh && # Drop tables
sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables
sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data
sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth

47
shyft-geth.sh Executable file
View file

@ -0,0 +1,47 @@
#!/bin/bash
if [[ $# -lt 1 ]]; then
echo
echo Shyft-Geth: No flags detected, see help:
echo
echo " --setup: Setups postgres and the shyft chain db."
echo " --start: Starts geth."
echo " --reset: Drops postgress and chain db, and reinstantiates both."
echo " --js [filename]: Executes web3 calls with a passed file name. If the file name is sendTransactions.js, $ ./shyft-geth.sh --js sendTransactions"
echo
exit 1
fi
illegalCommands=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--setup)
sh ./shyft-cli/setup.sh
shift # past argument
;;
--start)
sh ./shyft-cli/startShyftGeth.sh
shift # past argument
;;
--js)
sh ./shyft-cli/runJs.sh ./shyft-cli/web3/$2.js
shift # past argument
shift # past argument
;;
--reset)
sh ./shyft-cli/shyftFullReset.sh
shift # past argument
;;
*) # unknown option
illegalCommands+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
if [[ "${#illegalCommands[@]}" -gt "0" ]]; then
echo Shyft-Geth: The following commands are not supported: "${illegalCommands[*]}"
fi

View file

@ -1 +0,0 @@
psql -U postgres -f create_shyftdb.psql

View file

@ -1,5 +0,0 @@
cd ./shyftDb/postgres_setup
sh drop_tables.sh && sh init_tables.sh
cd ..
cd ..
sh resetShyftGeth.sh && sh initShyftGeth.sh