diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..6caa8cf --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,15 @@ +# INSTALLATION + +```sh +git_url="git@git.toptal.com:screening/Michel-Combes" +git clone --recursive $git_url toychain +cd toychain +gpg --decrypt local.key.asc | git-crypt unlock - +. rc.sh +# install perl modules from modules.deps +sh install.sh +# initialize config and keys +sh init.sh + +bin/toychain start +``` diff --git a/bin/apirun.pl b/bin/apirun.pl new file mode 100755 index 0000000..8280e64 --- /dev/null +++ b/bin/apirun.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl -w +# +# Intent: testing the API server +# + +use lib 'lib'; +use toychain; +use API qw(apigw_run); + +apigw_run(); + + +exit $?; + +1; # $Source: /my/perl/script/testapi.pl $ + + + diff --git a/setidentity.pl b/bin/setidentity.pl old mode 100644 new mode 100755 similarity index 100% rename from setidentity.pl rename to bin/setidentity.pl diff --git a/bin/toychain b/bin/toychain index 5564cb9..6babe91 100755 --- a/bin/toychain +++ b/bin/toychain @@ -63,6 +63,7 @@ tcconfigure() { tcstart() { echo "$pgm: starting daemon ..." + perl -S apirun.pl echo "---" } diff --git a/curltest.sh b/curltest.sh new file mode 100644 index 0000000..c7b8a10 --- /dev/null +++ b/curltest.sh @@ -0,0 +1,12 @@ +# + +#curl http://127.0.0.1:8089/api/0.0/version +#curl http://127.0.0.1:8089/api/0.0/audit +curl http://127.0.0.1:8089/api/0.0/getheight +echo '' +curl http://127.0.0.1:8089/api/0.0/getchain +echo '' +curl -s http://127.0.0.1:8089/api/0.0/getblock?n=30 +echo '' +curl -s http://127.0.0.1:8089/api/0.0/gettx?txaddr=Z123 +echo '' diff --git a/init.sh b/init.sh index 66a8965..9885acd 100644 --- a/init.sh +++ b/init.sh @@ -1,20 +1,23 @@ # -i="$1" +i="$1:-1" top=$(git rev-parse --show-toplevel) export SITE=$top export PATH=$top/bin:$PATH +port=$(expr 8089 + 2 \* $i ) echo "node$i: port=$port" sed -e "s/port: .*/port: $port/" config0.yml > config$i.yml +rm config.yml +ln -s config$i.yml config.yml gpg --decrypt local.key.asc | git-crypt unlock - cp -p secrets/keys0.yml secrets/keys.yml echo "your name ?" read name -perl setidentity.pl "$name" +perl -S setidentity.pl "$name (node$i)" diff --git a/lib b/lib index d4c8a3d..dd52265 160000 --- a/lib +++ b/lib @@ -1 +1 @@ -Subproject commit d4c8a3dee208e00b768607978228d1b01979988c +Subproject commit dd522659e0e9a66aef4c6b22105847df427f2dea diff --git a/nodes/cloneit.sh b/nodes/cloneit.sh index 7e25146..73d129a 100644 --- a/nodes/cloneit.sh +++ b/nodes/cloneit.sh @@ -8,7 +8,8 @@ echo create node$i #git clone --recursive git@git.toptal.com:screening/Michel-Combes node$i port=$(expr 8089 + 2 \* $i ) echo "node$i: port=$port" -sed -e "s/port: .*/port: $port/" $node$i/config0.yml > $node$i/config$i.yml +rm node$i/config.yml +sed -e "s/port: .*/port: $port/" node$i/config0.yml > node$i/config.yml cd node$i gpg --decrypt local.key.asc | git-crypt unlock - diff --git a/post.sh b/post.sh new file mode 100644 index 0000000..19e09c6 --- /dev/null +++ b/post.sh @@ -0,0 +1,11 @@ +# + +url="$1" +file="$2" + +sed -e 's/$/%0a/g' $file > $file.post +curl -s -X POST "$url" --data @$file.post + +exit $?; + +true; diff --git a/t/genesis.t b/t/genesis.t new file mode 100644 index 0000000..627fa3a --- /dev/null +++ b/t/genesis.t @@ -0,0 +1,23 @@ +# + +BEGIN { if (-e $ENV{SITE}.'/lib') { use lib $ENV{SITE}.'/lib'; } } + +use toychain; +use DAG qw(DAGRead); + + +my $headblock = $toychain::HEADs[0]; +my $headhash = $headblock->{bkhash}; +my $headaddr = $headblock->{bkaddr}; +printf "headhash%s\n",$headhash; +printf "headaddr%s\n",$headaddr; + +my $blk = &DAGRead($headhash,'blocks'); +#printf "--- blk %s...\n",Dump($blk); + +&displayBlock($blk); + +exit $?; + +1; +