forked from axiom-team/astrXbian
reading from IPNS capsules = lower gchange usage
This commit is contained in:
parent
b8da081575
commit
47f127f6cc
@ -103,8 +103,8 @@ fi
|
|||||||
########################################################################
|
########################################################################
|
||||||
echo "####################################################
|
echo "####################################################
|
||||||
Customisation TiddlyWiki"
|
Customisation TiddlyWiki"
|
||||||
# [[ ! -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/index.html ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID} && cp ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html
|
[[ ! $(cat ~/.zen/ipfs/.${IPFSNODEID}/index.html | grep ${IPFSNODEID}) ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID} && cp ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html
|
||||||
cp ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html
|
# cp -f ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html
|
||||||
|
|
||||||
zuid="$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)"
|
zuid="$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)"
|
||||||
wiki="/home/$YOU/.zen/ipfs/.$IPFSNODEID/index.html"
|
wiki="/home/$YOU/.zen/ipfs/.$IPFSNODEID/index.html"
|
||||||
@ -174,6 +174,12 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $liking_me)
|
||||||
|
echo "Reading stars.level from Stations IPNS Capsules."
|
||||||
|
starsin=$(ipfs --timeout=10s cat /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/stars.level)
|
||||||
|
starsout=$(ipfs --timeout=10s cat /ipns/$IPFSNODEID/.$IPFSNODEID/FRIENDS/$liking_me/stars.level)
|
||||||
|
echo "I received $starsin stars while I sent $starsout stars."
|
||||||
|
|
||||||
##### CHECKING IF WE LIKE EACH OTHER (AVOID LIKING MYSELF)
|
##### CHECKING IF WE LIKE EACH OTHER (AVOID LIKING MYSELF)
|
||||||
~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $liking_me > /tmp/Gstars.json
|
~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $liking_me > /tmp/Gstars.json
|
||||||
|
|
||||||
@ -200,22 +206,26 @@ do
|
|||||||
# zuid=$(ipfs --timeout=10s cat /ipns/${ipfsnodeid}/.${ipfsnodeid}/_xbian.zuid)
|
# zuid=$(ipfs --timeout=10s cat /ipns/${ipfsnodeid}/.${ipfsnodeid}/_xbian.zuid)
|
||||||
# [[ ${zuid} ]] && touch ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/${zuid}
|
# [[ ${zuid} ]] && touch ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/${zuid}
|
||||||
|
|
||||||
|
## NOT USEFULL TRYING
|
||||||
# SEND jaklis message if tryme.addr is different from last one
|
# SEND jaklis message if tryme.addr is different from last one
|
||||||
if [[ $(diff ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr 2>&1) ]]
|
# if [[ $(diff ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr 2>&1) ]]
|
||||||
then
|
# then
|
||||||
echo "I AM $G1PUB"
|
# echo "I AM $G1PUB"
|
||||||
echo "Sending IPFSTRYME message to $liking_me"
|
# echo "Sending IPFSTRYME message to $liking_me"
|
||||||
if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ]]; then
|
#
|
||||||
~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
# if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ]]; then
|
||||||
else
|
# ~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr'
|
# else
|
||||||
fi
|
# echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr'
|
||||||
echo "$friend_of_mine" >> /tmp/friend_of_mine
|
# fi
|
||||||
else
|
# echo "$friend_of_mine" >> /tmp/friend_of_mine
|
||||||
echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me"
|
# else
|
||||||
fi
|
# echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me"
|
||||||
# MEMORIZE actual tryme.addr
|
# fi
|
||||||
|
|
||||||
|
# MEMORIZE actual tryme.addr (gchange_IPFS_swarm.sh is getting it from IPNS capsule)
|
||||||
cp -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/
|
cp -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep $((1 + RANDOM % 2)) # SLOW DOWN
|
sleep $((1 + RANDOM % 2)) # SLOW DOWN
|
||||||
|
@ -42,16 +42,25 @@ do
|
|||||||
# SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt
|
# SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt
|
||||||
# Check if my like is reverse
|
# Check if my like is reverse
|
||||||
liking_me_count=$((liking_me_count+1))
|
liking_me_count=$((liking_me_count+1))
|
||||||
|
|
||||||
|
## IPFS WAY TO DO IT (LESS STRESS ON GCHANGE)
|
||||||
|
rm /tmp/ipfstryme.$liking_me
|
||||||
|
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $liking_me)
|
||||||
|
echo "Getting /ipns/$ipfsnodeid/.$ipfsnodeid/tryme.addr ..."
|
||||||
|
ipfs --timeout=30s cat /ipns/$ipfsnodeid/.$ipfsnodeid/tryme.addr > /tmp/ipfstryme.$liking_me
|
||||||
|
|
||||||
|
if [[ ! -f /tmp/ipfstryme.$liking_me ]]; then
|
||||||
echo ">>>>>> CHECKING liking_me n° $liking_me_count : READING 'ipfstryme' message from $liking_me"
|
echo ">>>>>> CHECKING liking_me n° $liking_me_count : READING 'ipfstryme' message from $liking_me"
|
||||||
## Get "/tmp/ipfstryme.$liking_me" from Gchange "ipfstryme" message
|
## Get "/tmp/ipfstryme.$liking_me" from Gchange "ipfstryme" message
|
||||||
~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content' > /tmp/ipfstryme.$liking_me
|
~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content' > /tmp/ipfstryme.$liking_me
|
||||||
|
fi
|
||||||
|
|
||||||
## ZOMBIE NODE sends more that 300 ipfstryme ?
|
## ZOMBIE NODE sends more that 300 ipfstryme ?
|
||||||
## [[ $(cat /tmp/ipfstryme.$liking_me | sort | uniq | wc -l) -gt 300 ]] && echo "THIS NODE IS A ZOMBIE..." && rm -f /tmp/ipfstryme.$liking_me && continue
|
## [[ $(cat /tmp/ipfstryme.$liking_me | sort | uniq | wc -l) -gt 300 ]] && echo "THIS NODE IS A ZOMBIE..." && rm -f /tmp/ipfstryme.$liking_me && continue
|
||||||
|
|
||||||
# CLEAN /tmp/ipfstryme.$liking_me
|
# CLEAN /tmp/ipfstryme.$liking_me
|
||||||
> /tmp/ipfstryme.clean
|
> /tmp/ipfstryme.clean
|
||||||
for line in $(cat /tmp/ipfstryme.$liking_me);
|
for line in $(cat /tmp/ipfstryme.$liking_me | shuf);
|
||||||
do
|
do
|
||||||
ipfsnodeid=$(echo $line | rev | cut -d '/' -f 1 | rev)
|
ipfsnodeid=$(echo $line | rev | cut -d '/' -f 1 | rev)
|
||||||
[[ $ipfsnodeid == "" ]] && break
|
[[ $ipfsnodeid == "" ]] && break
|
||||||
@ -95,6 +104,7 @@ do
|
|||||||
|
|
||||||
# FRIEND ADDRESS DISCOVERY
|
# FRIEND ADDRESS DISCOVERY
|
||||||
echo "Am I friend with my FRIEND friend $whoisg1 ?"
|
echo "Am I friend with my FRIEND friend $whoisg1 ?"
|
||||||
|
# ipfs cat /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/tryme.addr # IS my own /ipns/$IPFSNODEID/.$IPFSNODEID/tryme.addr
|
||||||
friend_of_mine=$(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $whoisg1 | jq -r '.yours.pseudo'); # must contains my XZUID
|
friend_of_mine=$(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $whoisg1 | jq -r '.yours.pseudo'); # must contains my XZUID
|
||||||
if [[ "$friend_of_mine" != "null" ]]; then
|
if [[ "$friend_of_mine" != "null" ]]; then
|
||||||
if [[ ! $(grep "$ipfsnodeid" ~/.zen/A_my_swarm.txt) ]]
|
if [[ ! $(grep "$ipfsnodeid" ~/.zen/A_my_swarm.txt) ]]
|
||||||
@ -104,6 +114,8 @@ do
|
|||||||
friend_of_mine_count=$((friend_of_mine_count+1))
|
friend_of_mine_count=$((friend_of_mine_count+1))
|
||||||
echo "$peerline" >> ~/.zen/A_my_swarm.txt
|
echo "$peerline" >> ~/.zen/A_my_swarm.txt
|
||||||
ipfs bootstrap add "$peerline"
|
ipfs bootstrap add "$peerline"
|
||||||
|
## NOW USING Peers.Peering config
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "ALREADY RECORDED FRIEND"
|
echo "ALREADY RECORDED FRIEND"
|
||||||
fi
|
fi
|
||||||
@ -137,7 +149,7 @@ echo "####################################################"
|
|||||||
|
|
||||||
## SHOULD HAVE exit 0 before !!
|
## SHOULD HAVE exit 0 before !!
|
||||||
########################################################################
|
########################################################################
|
||||||
## SWARM LOST !! EMERGENCY RECOVERY !! TEST CODE
|
## SWARM LOST !! EMERGENCY RECOVERY CODE !!!
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
ipfs bootstrap > /tmp/ipfs_bootstrap
|
ipfs bootstrap > /tmp/ipfs_bootstrap
|
||||||
|
Loading…
Reference in New Issue
Block a user