forked from STI/Astroport.ONE
get "onchain" duniter GVA node
This commit is contained in:
parent
47764387cc
commit
36b000426b
@ -70,7 +70,7 @@ JSONUPLANET="${HOME}/.zen/tmp/${MOATS}/ONEuplanet.json"
|
|||||||
[[ ! -s ${JSONUPLANET} ]] && echo "NO tag[ForkUPlanetZERO] for $PLAYER" && exit 0
|
[[ ! -s ${JSONUPLANET} ]] && echo "NO tag[ForkUPlanetZERO] for $PLAYER" && exit 0
|
||||||
|
|
||||||
UPNAME=$(cat ${JSONUPLANET} | jq -r ".title") # What name is given ?
|
UPNAME=$(cat ${JSONUPLANET} | jq -r ".title") # What name is given ?
|
||||||
[[ "${UPNAME}" == "null" || "${UPNAME}" == "" ]] && echo "FATAL ERROR UPNAME .title MISSING" && exit 1
|
[[ "${UPNAME}" == "null" || "${UPNAME}" == "" ]] && echo "NO FORK UPLANET NAME .title MISSING" && exit 1
|
||||||
HASH=$(cat ${JSONUPLANET} | jq -r ".hash") ## What text hash it has ?
|
HASH=$(cat ${JSONUPLANET} | jq -r ".hash") ## What text hash it has ?
|
||||||
SECRET=$(cat ${JSONUPLANET} | jq -r ".secret") ## What is secret ?
|
SECRET=$(cat ${JSONUPLANET} | jq -r ".secret") ## What is secret ?
|
||||||
|
|
||||||
@ -87,9 +87,9 @@ AHAH=$(echo $CONTRACT | sha512sum | cut -d ' ' -f 1)
|
|||||||
[[ ! -s $HOME/.zen/game/players/${PLAYER}/.ipfs/${UPNAME}.swarm.key ]] \
|
[[ ! -s $HOME/.zen/game/players/${PLAYER}/.ipfs/${UPNAME}.swarm.key ]] \
|
||||||
&& MSG=$MSG" ${PLAYER}/.ipfs/${UPNAME}.swarm.key NOT FOUND" && ERR="NO LOCAL KEY"
|
&& MSG=$MSG" ${PLAYER}/.ipfs/${UPNAME}.swarm.key NOT FOUND" && ERR="NO LOCAL KEY"
|
||||||
|
|
||||||
## CREATE 64 bit swarm.key ( maximum individual Fork 1,844674407×10¹⁹ )
|
## CREATE 32 octets swarm.key ( maximum individual Fork 7,922816251×10²⁸ )
|
||||||
echo -e '/key/swarm/psk/1.0.0/\n/base16/' > $HOME/.zen/tmp/${MOATS}/swarm.key
|
echo -e '/key/swarm/psk/1.0.0/\n/base16/' > $HOME/.zen/tmp/${MOATS}/swarm.key
|
||||||
head -c 64 /dev/urandom | od -t x1 -A none - | tr -d '\n ' >> $HOME/.zen/tmp/${MOATS}/swarm.key
|
head -c 32 /dev/urandom | od -t x1 -A none - | tr -d '\n ' >> $HOME/.zen/tmp/${MOATS}/swarm.key
|
||||||
echo '' >> $HOME/.zen/tmp/${MOATS}/swarm.key
|
echo '' >> $HOME/.zen/tmp/${MOATS}/swarm.key
|
||||||
|
|
||||||
## EXTRACT CURRENT SECRET FROM JSONUPLANET
|
## EXTRACT CURRENT SECRET FROM JSONUPLANET
|
||||||
@ -144,15 +144,19 @@ echo "${ENCODING}"
|
|||||||
#################################################################
|
#################################################################
|
||||||
## MAKE SAME ENCODING FOR FRIENDS
|
## MAKE SAME ENCODING FOR FRIENDS
|
||||||
friends=($(ls ~/.zen/game/players/${PLAYER}/FRIENDS | grep "@" 2>/dev/null))
|
friends=($(ls ~/.zen/game/players/${PLAYER}/FRIENDS | grep "@" 2>/dev/null))
|
||||||
|
howmuch=0
|
||||||
for f in ${friends[@]};
|
for f in ${friends[@]};
|
||||||
do
|
do
|
||||||
## Extract FRIENDG1PUB from TW (Astroport Tiddler)
|
## Extract FRIENDG1PUB from TW (Astroport Tiddler)
|
||||||
ftw=${HOME}/.zen/game/players/${PLAYER}/FRIENDS/${f}/index.html
|
ftw=${HOME}/.zen/game/players/${PLAYER}/FRIENDS/${f}/index.html
|
||||||
tiddlywiki --load ${ftw} --output ~/.zen/tmp/${MOATS} --render '.' "${f}_Astroport.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport'
|
tiddlywiki --load ${ftw} --output ~/.zen/tmp/${MOATS} --render '.' "${f}_Astroport.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport'
|
||||||
FRIENDG1PUB=$(cat ~/.zen/tmp/${MOATS}/${f}_Astroport.json | jq -r .[].g1pub)
|
FRIENDG1PUB=$(cat ~/.zen/tmp/${MOATS}/${f}_Astroport.json | jq -r .[].g1pub)
|
||||||
|
ASTROPORT=$(cat ~/.zen/tmp/${MOATS}/${f}_Astroport.json | jq -r .[].astroport)
|
||||||
|
[[ ${ASTROPORT} != "/ipns/${IPFSNODEID}" ]] && echo "FOREIGN ASTROPORT=${ASTROPORT}" && foreign="YES"
|
||||||
echo "$f : $FRIENDG1PUB"
|
echo "$f : $FRIENDG1PUB"
|
||||||
if [[ ${FRIENDG1PUB} ]]; then
|
|
||||||
|
if [[ ${FRIENDG1PUB} && ${FRIENDG1PUB} != "null" ]]; then
|
||||||
|
|
||||||
#~ CHECK IF ALREADY IN JSON
|
#~ CHECK IF ALREADY IN JSON
|
||||||
echo "cat ${JSONUPLANET} | jq -r '.\"${f}\"'"
|
echo "cat ${JSONUPLANET} | jq -r '.\"${f}\"'"
|
||||||
FRIENDIN=$(cat ${JSONUPLANET} | jq -r '."${f}"')
|
FRIENDIN=$(cat ${JSONUPLANET} | jq -r '."${f}"')
|
||||||
@ -171,11 +175,27 @@ do
|
|||||||
&& mv ~/.zen/tmp/${MOATS}/json.up ${JSONUPLANET}
|
&& mv ~/.zen/tmp/${MOATS}/json.up ${JSONUPLANET}
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "- ERROR - Friend TW copy is broken !!"
|
echo "- FATAL ERROR - Friend TW ${ftw} is broken !!"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
## CHECK IF FRIEND HAVE THE SAME ${UPNAME} tiddler
|
||||||
|
if [[ ${foreign} == "YES" ]]; then
|
||||||
|
howmuch=$(( howmuch + 1 ))
|
||||||
|
|
||||||
|
## SEARCH FOR ${UPNAME} tiddler IN FRIEND TW
|
||||||
|
tiddlywiki --load ${ftw} --output ~/.zen/tmp/${MOATS} --render '.' "${f}_${UPNAME}.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' "${UPNAME}"
|
||||||
|
cat ~/.zen/tmp/${MOATS}/${f}_${UPNAME}.json | jq -r '[]."${PLAYER}"'
|
||||||
|
|
||||||
|
## CONTROL KEY DECODING
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "<<< MY FRIENDS ARE LOCATED IN $howmuch FOREIGN ASTROPORT >>>"
|
||||||
|
|
||||||
## UPDATE JSONUPLANET
|
## UPDATE JSONUPLANET
|
||||||
cat ${JSONUPLANET} | jq '. | ."UPname" = "_UPNAME_"' > ~/.zen/tmp/${MOATS}/json.up \
|
cat ${JSONUPLANET} | jq '. | ."UPname" = "_UPNAME_"' > ~/.zen/tmp/${MOATS}/json.up \
|
||||||
&& sed -i 's/_UPNAME_/'"$UPNAME"'/g' ~/.zen/tmp/${MOATS}/json.up \
|
&& sed -i 's/_UPNAME_/'"$UPNAME"'/g' ~/.zen/tmp/${MOATS}/json.up \
|
||||||
|
@ -196,6 +196,8 @@ while read LINE; do
|
|||||||
&& echo "REDISTRIBUTION DONE" \
|
&& echo "REDISTRIBUTION DONE" \
|
||||||
&& echo "$TXIDATE" > ~/.zen/game/players/${PLAYER}/.atdate
|
&& echo "$TXIDATE" > ~/.zen/game/players/${PLAYER}/.atdate
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
|
||||||
done < ~/.zen/tmp/${MOATS}/myPalPay.json
|
done < ~/.zen/tmp/${MOATS}/myPalPay.json
|
||||||
|
|
||||||
echo "====(•‿‿•)======= %%%%% (°▃▃°) %%%%%%% ======(•‿‿•)========"
|
echo "====(•‿‿•)======= %%%%% (°▃▃°) %%%%%%% ======(•‿‿•)========"
|
||||||
|
@ -149,7 +149,7 @@ for SECTOR in ${SECTORS[@]}; do
|
|||||||
|
|
||||||
## IF NOT UPDATED FOR TOO LONG : STRAPS[0] get key control
|
## IF NOT UPDATED FOR TOO LONG : STRAPS[0] get key control
|
||||||
[ ${DIFF_SECONDS} -gt $(( 26 * 60 * 60 )) ] \
|
[ ${DIFF_SECONDS} -gt $(( 26 * 60 * 60 )) ] \
|
||||||
&& echo "More than 26H update" \
|
&& echo ">>>>>>>>>>>>>> More than 26H update - BOOSTRAP 0 ACTION -" \
|
||||||
&& ACTINGNODE=${STRAPS[0]}
|
&& ACTINGNODE=${STRAPS[0]}
|
||||||
|
|
||||||
echo "* ACTINGNODE=${ACTINGNODE}"
|
echo "* ACTINGNODE=${ACTINGNODE}"
|
||||||
@ -170,8 +170,7 @@ for SECTOR in ${SECTORS[@]}; do
|
|||||||
mv ${UREFRESH}.shuf ${UREFRESH}
|
mv ${UREFRESH}.shuf ${UREFRESH}
|
||||||
echo "SETTING NEXT REFRESHER : $(cat ${UREFRESH} | head -n 1)"
|
echo "SETTING NEXT REFRESHER : $(cat ${UREFRESH} | head -n 1)"
|
||||||
|
|
||||||
|
############ 101 ZEN (11.1 G1) REFILL ?!
|
||||||
############ 101 ZEN REFILL ?!
|
|
||||||
CURRENT=$(readlink ~/.zen/game/players/.current | rev | cut -d '/' -f 1 | rev)
|
CURRENT=$(readlink ~/.zen/game/players/.current | rev | cut -d '/' -f 1 | rev)
|
||||||
[[ ${COINS} == "" || ${COINS} == "null" ]] \
|
[[ ${COINS} == "" || ${COINS} == "null" ]] \
|
||||||
&& [[ ${ZEN} -lt 100 && ${CURRENT} != "" ]] \
|
&& [[ ${ZEN} -lt 100 && ${CURRENT} != "" ]] \
|
||||||
|
@ -164,7 +164,7 @@ for UMAP in ${unique_combined[@]}; do
|
|||||||
|
|
||||||
## IF NOT UPDATED FOR TOO LONG
|
## IF NOT UPDATED FOR TOO LONG
|
||||||
[[ ${DIFF_SECONDS} -gt $(( 26 * 60 * 60 )) || ${DIFF_SECONDS} -eq 0 ]] \
|
[[ ${DIFF_SECONDS} -gt $(( 26 * 60 * 60 )) || ${DIFF_SECONDS} -eq 0 ]] \
|
||||||
&& echo "More than 26H update - BOOSTRAP 0 ACTION -" \
|
&& echo ">>>>>>>>>>>>>> More than 26H update - BOOSTRAP 0 ACTION -" \
|
||||||
&& ACTINGNODE=${STRAPS[0]}
|
&& ACTINGNODE=${STRAPS[0]}
|
||||||
|
|
||||||
echo "* ACTINGNODE=${ACTINGNODE}"
|
echo "* ACTINGNODE=${ACTINGNODE}"
|
||||||
@ -191,7 +191,7 @@ for UMAP in ${unique_combined[@]}; do
|
|||||||
echo ">> NEXT REFRESHER WILL BE $(cat ${UREFRESH} | head -n 1)"
|
echo ">> NEXT REFRESHER WILL BE $(cat ${UREFRESH} | head -n 1)"
|
||||||
######################################################## # NODE SELECTION in UMAP.refresher
|
######################################################## # NODE SELECTION in UMAP.refresher
|
||||||
|
|
||||||
############ 101 ZEN REFILL ?!
|
############ 101 ZEN (11.1 G1) REFILL ?!
|
||||||
CURRENT=$(readlink ~/.zen/game/players/.current | rev | cut -d '/' -f 1 | rev)
|
CURRENT=$(readlink ~/.zen/game/players/.current | rev | cut -d '/' -f 1 | rev)
|
||||||
[[ ${COINS} == "" || ${COINS} == "null" ]] \
|
[[ ${COINS} == "" || ${COINS} == "null" ]] \
|
||||||
&& [[ ${ZEN} -lt 100 && ${CURRENT} != "" ]] \
|
&& [[ ${ZEN} -lt 100 && ${CURRENT} != "" ]] \
|
||||||
|
@ -44,6 +44,7 @@ checkonenode()
|
|||||||
# The node is a watched node, add some bold
|
# The node is a watched node, add some bold
|
||||||
n="\e[1m$n\e[0m"
|
n="\e[1m$n\e[0m"
|
||||||
fi
|
fi
|
||||||
|
echo "$node : $cur"
|
||||||
# Put the result into the file
|
# Put the result into the file
|
||||||
echo "$cur $n">$outfile
|
echo "$cur $n">$outfile
|
||||||
# Notify that we're done here
|
# Notify that we're done here
|
||||||
@ -51,25 +52,21 @@ checkonenode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Temp dir where results are stored
|
# Temp dir where results are stored
|
||||||
rm -Rf /tmp/zen/gnodewatch
|
rm -Rf ~/.zen/tmp/gnodewatch
|
||||||
DIR=/tmp/zen/gnodewatch
|
DIR=~/.zen/tmp/gnodewatch
|
||||||
export DIR
|
export DIR
|
||||||
mkdir -p $DIR/chains
|
mkdir -p $DIR/chains
|
||||||
# TODO: REMOVE 777 PATCH, ACTIVATE ramdisk
|
|
||||||
# sudo mkdir /mnt/ramdisk
|
|
||||||
# sudo mount -t tmpfs -o size=50m tmpfs /mnt/ramdisk
|
|
||||||
chmod -R 777 /tmp/zen/
|
|
||||||
|
|
||||||
# KEEP /tmp/zen/current.duniter for 5 mn
|
# KEEP ~/.zen/tmp/current.duniter for 5 mn
|
||||||
find /tmp/zen/ -mmin +5 -type f -name "current.duniter" -exec rm -f '{}' \;
|
#~ find ~/.zen/tmp/ -mmin +5 -type f -name "current.duniter" -exec rm -f '{}' \;
|
||||||
[[ -f /tmp/zen/current.duniter ]] && cat /tmp/zen/current.duniter && exit 0
|
#~ [[ -f ~/.zen/tmp/current.duniter ]] && cat ~/.zen/tmp/current.duniter && exit 0
|
||||||
|
|
||||||
##### $DIR/duniter_nodes.txt REFRESH after 20 minutes #####
|
##### $DIR/duniter_nodes.txt REFRESH after 20 minutes #####
|
||||||
find $DIR/ -mmin +20 -type f -name "duniter_*" -exec rm -f '{}' \;
|
find $DIR/ -mmin +20 -type f -name "duniter_*" -exec rm -f '{}' \;
|
||||||
if [[ ! -f $DIR/duniter_nodes.txt ]]; then
|
if [[ ! -f $DIR/duniter_nodes.txt ]]; then
|
||||||
# Get New BMAS known Nodes list from shuffle one $DIR/good.nodes.txt
|
# Get New BMAS known Nodes list from shuffle one $DIR/good.nodes.txt
|
||||||
[[ -f $DIR/good.nodes.txt ]] && DUNITER=$(shuf -n 1 $DIR/good.nodes.txt) || DUNITER="duniter-g1.p2p.legal:443"
|
[[ -f $DIR/good.nodes.txt ]] && DUNITER=$(shuf -n 1 $DIR/good.nodes.txt) || DUNITER="g1.copylaradio.com:443"
|
||||||
curl -s https://$DUNITER/network/peers | jq '.peers[] | .endpoints' | grep BMAS | awk '{print $2,$3}' | sed s/\"//g | sed s/\,//g | sed s/\ /:/g | sort -u > $DIR/duniter_nodes.txt
|
curl -s https://$DUNITER/network/peers | jq '.peers[] | .endpoints' | grep GVA | awk '{print $3,$4}' | sed s/\"//g | sed s/\,//g | sed s/\ /:/g | sort -u > $DIR/duniter_nodes.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Grab the nodes we are actively watching - they will be in bold in the final output
|
# Grab the nodes we are actively watching - they will be in bold in the final output
|
||||||
@ -84,7 +81,9 @@ rm $DIR/*out $DIR/*done $DIR/chains/* $DIR/NODE.* 2>/dev/null
|
|||||||
# Query all nodes in parallel
|
# Query all nodes in parallel
|
||||||
for node in $nodes
|
for node in $nodes
|
||||||
do
|
do
|
||||||
checkonenode $node "$watched" $DIR/$index.out &
|
#~ echo "checkonenode $node "$watched" $DIR/$index.out"
|
||||||
|
checkonenode $node "$watched" $DIR/$index.out
|
||||||
|
#~ cat $DIR/$index.out
|
||||||
((index++))
|
((index++))
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -110,23 +109,34 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
longchain=$(ls -S $DIR/chains/ | head -n 1)
|
longchain=$(ls -S $DIR/chains/ | head -n 1)
|
||||||
|
echo "CHAIN:$chains"
|
||||||
# WRITE OUT shuffle Duniter Node Sync with longest chain
|
# WRITE OUT shuffle Duniter Node Sync with longest chain
|
||||||
cp $DIR/chains/$longchain $DIR/good.nodes.txt
|
cat $DIR/chains/$longchain | shuf > $DIR/good.nodes.txt
|
||||||
|
|
||||||
## TEST if server is really running Duniter
|
## TEST if server is really running Duniter
|
||||||
Dtest=""; IDtest=""; lastresult=""; loop=0
|
Dtest=""; IDtest=""; lastresult=""; loop=0
|
||||||
while [[ $Dtest != "duniter" ]]; do
|
while read lastresult;
|
||||||
while [[ $lastresult == $result && $loop -lt 7 ]]; do result=$(shuf -n 1 $DIR/good.nodes.txt); ((loop++)); done
|
do
|
||||||
lastresult=$result
|
|
||||||
Dtest=$(curl -s https://$lastresult | jq -r .duniter.software)
|
|
||||||
## CHECK if server is not too slow
|
## CHECK if server is not too slow
|
||||||
[[ $Dtest == "duniter" ]] && IDtest=$(silkaj -p $lastresult id Fred)
|
echo "curl -s -m 5 https://$lastresult | jq -r .duniter.software"
|
||||||
[[ $IDtest == "" ]] && Dtest=""
|
Dtest=$(curl -s -m 5 https://$lastresult | jq -r .duniter.software)
|
||||||
[[ $loop -eq 8 ]] && result="duniter-g1.p2p.legal:443" && break
|
echo "$Dtest"
|
||||||
|
gvaserver=$(echo $lastresult | sed "s~:443~/gva~g" )
|
||||||
|
[[ "$Dtest" == "duniter" ]] \
|
||||||
|
&& echo "jaklis -n https://$gvaserver balance -p DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech" \
|
||||||
|
&& IDtest=$(jaklis -n https://$gvaserver balance -p DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech 2>/dev/null)
|
||||||
|
|
||||||
|
echo $IDtest
|
||||||
|
|
||||||
|
[[ $IDtest != "" && $IDtest != "null" ]] && result="https://$gvaserver" && break
|
||||||
|
|
||||||
|
[[ $loop -eq 8 ]] \
|
||||||
|
&& result="g1.copylaradio.com:443" && break
|
||||||
|
|
||||||
((loop++))
|
((loop++))
|
||||||
done
|
done < $DIR/good.nodes.txt
|
||||||
|
|
||||||
|
|
||||||
echo "$result" > /tmp/zen/current.duniter
|
echo "$result" > ~/.zen/tmp/current.duniter
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
|
Loading…
Reference in New Issue
Block a user